Im developing in android, and want to convert the byte-array from the camera's previewCallback, which is in YUV-format, to rgb-format.
I have used the function given in this answer: Getting frames from Video Image in Android
It works perfectly in java, but my problem is that I want to make the function in c++ (I'm using the ndk, and not very familiar with c++).
I have tried to create the function in c++, but it always makes strange results (eg the picture is all green).
Does anyone have a similar function or this function working in c++?
Thanks.
Look at this: http://pastebin.com/mDcwqJV3
Fixed-point conversion from YUYV to RGB24
Also, some cameras return raw images in 'UYVY' byte orger, so make corresponding changes in the conversion function.
Conversion from YUYV to RGB in C++:
This method assumes that your yuyv_image is an unsigned char* as well.
More information on YUYV can be found here
And for more clarification on YUYV --> RGB check out this