Visionworks: write to image created from handle

I want to use nvxuSemiGlobalMatching on custom image buffers. Therefore I mapped the buffers to an vx_image using the vxCreateImageFromHandle function:

vx_imagepatch_addressing_t addrLeft[1];
addrLeft[0].dim_x = width;
addrLeft[0].dim_y = height;
addrLeft[0].stride_x = sizeof(uint8_t);
addrLeft[0].stride_y = width*sizeof(uint8_t);

vx_imagepatch_addressing_t addrRight[1];
addrRight[0].dim_x = width;
addrRight[0].dim_y = height;
addrRight[0].stride_x = sizeof(uint8_t);
addrRight[0].stride_y = width*sizeof(uint8_t);

vx_imagepatch_addressing_t addrDisp[1];
addrDisp[0].dim_x = width;
addrDisp[0].dim_y = height;
addrDisp[0].stride_x = sizeof(int16_t);
addrDisp[0].stride_y = width*sizeof(int16_t);

// dataLeft, dataRight, dataDisp are pointers to allocated cuda memory
void *ptrsLeft[1] = { dataLeft };
void *ptrsRight[1] = { dataRight };
void *ptrsDisp[1] = { dataDisp };

auto vxImageLeft = vxCreateImageFromHandle(context, VX_DF_IMAGE_U8, addrLeft, ptrsLeft, NVX_MEMORY_TYPE_CUDA);
auto vxImageRight = vxCreateImageFromHandle(context, VX_DF_IMAGE_U8, addrRight, ptrsRight, NVX_MEMORY_TYPE_CUDA);
auto vxDisparity = vxCreateImageFromHandle(context, VX_DF_IMAGE_S16, addrDisp, ptrsDisp, NVX_MEMORY_TYPE_CUDA);

After that I call the nvxuSemiGlobalMatching function using these images. Somehow the output in vxDisparity is rubbish.

The weird thing is that when I create a temporary vxDisparityTemp, pass that image to nvxuSemiGlobalMatching and then copy that image using nvxuCopyImage to vxDisparity, the result looks good.

What could be the reason for that? Why can nvxuCopyImage write into vxDisparity and nvxuSemiGlobalMatching not? Do I miss something?



Do you use the same way to create vxDisparityTemp?
Suppose you should get the same result with vxDisparity and vxDisparityTemp.


Hi AstaLLL,

I don’t know why but it seems to work now. Maybe something went wrong with the memory in the stages before. Nevertheless thanks for your help!


Good to hear this!

Ok, the issue comes up again but I don’t know why. Again, creating a new image vxDisparityTemp and copy it after processing to vxDisparity works. Passing vxDisparity directly to nvxuSemiGlobalMatching does not work. Does anyone has an idea or similar problems?

hi MarkusHess:
here is sample for nvxuSemiGlobalMatching, please reference , release var at the end of program