Forums - Transform YUV to RGB

2 posts / 0 new
Last post
Transform YUV to RGB
Join Date: 20 Jun 15
Posts: 5
Posted: Sun, 2015-06-21 23:58

i am trying to transform the YUV data to RGB by using fcvColorYUV420toRGB565u8. But it doesn't work. Here is my code, and I think the probelm should be related with the width and height, because the size of srcData and dstData is different.

JNIEXPORT jfloatArray JNICALL Java_com_example_hch_1hw2_CameraPreview2_ldbstasm(JNIEnv* env, jobject, jbyteArray buffer, int w, int h)
jbyte*            jimgData = NULL;
jboolean          isCopy = 0;
uint8_t*          dstData= (uint8_t *)fcvMemAlloc(w*h, 16);
uint8_t*          srcData = (uint8_t *)fcvMemAlloc(w*h*3/2, 16);
jimgData = env->GetByteArrayElements( buffer, &isCopy );
uint8_t* pJimgData    = (uint8_t*)jimgData;
memcpy( srcData, jimgData, w*h*3/2 );
pJimgData = srcData;
Mat mRgba = Mat(w,h,CV_32FC3,&dstData);
  • Up0
  • Down0
jeff4s Moderator
Join Date: 4 Nov 12
Posts: 106
Posted: Sun, 2015-07-05 12:03

dstData should be allocated 2*w*h bytes since each pixel has 2 bytes.



  • Up0
  • Down0
or Register

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.