Hi,
I want to convert a CUeglFrame (produced by libargus) to a vx_image. The source image type is NV12 and the target image type should be RGB. My first approach was to create vx_image of type VX_DF_IMAGE_NV12 using the vxCreateImageFromHandle function and use vxuConvertColor to covert it to RGB:
vx_image imageRGB = vxCreateImage(vxContext, eglFrame.width, eglFrame.height, VX_DF_IMAGE_RGB);
void * ptrs[] = { eglFrame.frame.pArray[0], eglFrame.frame.pArray[1]};
vx_image imageHandle = vxCreateImageFromHandle(vxContext, VX_DF_IMAGE_NV12, NULL, ptrs, NVX_MEMORY_TYPE_CUDA_ARRAY);
vxuColorConvert(vxContext, imageHandle, imageRGB);
Unfortunately, this gives me an image where the left half looks good, but the right half is coloured pink. I tried a lot of things and could fix this issue by copying the referenced image to a new image first and do the color conversion afterwards using the copied image:
vx_image imageRGB = vxCreateImage(vxContext, eglFrame.width, eglFrame.height, VX_DF_IMAGE_RGB);
void * ptrs[] = { eglFrame.frame.pArray[0], eglFrame.frame.pArray[1]};
vx_image imageHandle = vxCreateImageFromHandle(vxContext, VX_DF_IMAGE_NV12, NULL, ptrs, NVX_MEMORY_TYPE_CUDA_ARRAY);
// Copy referenced image
vx_image imageNV12 = vxCreateImage(m_vxContext, width(), height(), VX_DF_IMAGE_NV12);
nvxuCopyImage(vxContext, imageHandle, imageNV12);
// use the copied image
vxuColorConvert(vxContext, imageNV12, imageRGB);
I do not understand the reason for this behavior. Is it somehow possible to do the color conversion directliy with the referenced EGL frame to avoid the additional copy operation?