I am following the opencv_npp_interop example as reference to convert an OpenCv Mat to vx_image but the example only shows for greyscale image (single channel). So I have tried to modify it for 3-channel (RGB) Mat to vx_image (RGB).
vx_image createRGBImageFromRGBMat(vx_context& context, cv::Mat& mat)
{
vx_imagepatch_addressing_t src_addr = {
mat.cols, mat.rows, sizeof(vx_uint8)*3, mat.cols * sizeof(vx_uint8)*3, VX_SCALE_UNITY, VX_SCALE_UNITY, 1, 1 };
void* src_ptr = mat.data;
vx_image image = vxCreateImageFromHandle(context, VX_DF_IMAGE_RGB, &src_addr, &src_ptr, VX_IMPORT_TYPE_HOST);
return image;
}
If I query number of planes attribute for the returned vx_image, I only shows 1 plane. Whereas I am assuming it should be 3-plane (RGB).
Secondly, if I now convert this returned supposedly RGB image to YUV and query for planes, I get 3 planes but when I extract separate channels, I am only able to extract "Y" channel, other two vxuChannelExtract calls result in a "-10 : invalid params".
So I am assuming the source of the problem is still the RGB conversion. What did I do wrong ?