'OpenVX read NV21 image raw data into vx_image type

I am learning programming using openVX API's and was trying to create a simple application as follows

read nv21 raw data from disk --> use openVX color convert node to convert from nv21 to rgb --> read back rgb and dump.

Consider following sample code

unsigned char * inputNV21 = (unsigned char*)malloc(((imgW*imgH*3)>>1)*sizeof(unsigned char));
FILE *fp = fopen("lena.yuv", "rb");
fread(inputNV21, ((imgW*imgH*3)>>1), 1, fp));
fclose(fp);

vx_context contextVX = vxCreateContext();
vx_image imageVXNV21 = vxCreateImage(contextVX, imgW, imgH, VX_DF_IMAGE_NV21);

now I am not able to figure out how to put the raw data I have in inputNV21 into imageVXNV21

I have read various openVX sample codes and writing to a rgb vx_image is clear but I am not able to figure out how to deal with the VU channel of NV21 image.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source