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.
Transform YUV to RGB
Posted: Sun, 2015-06-21 23:58
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;
fcvColorYUV420toRGB565u8(pJimgData,w,h,(uint32_t*)dstData);
Mat mRgba = Mat(w,h,CV_32FC3,&dstData);
}
dstData should be allocated 2*w*h bytes since each pixel has 2 bytes.
Cheers,
-Jeff