ORIN VPI Error

I am working with VPI.
I run the following code on ORIN, but get an error. I don’t know why. can somebody help me?
VPI_ERROR_INVALID_ARGUMENT: Plane row stride must be greater or equal row length in bytes

int w_img = 480;
int h_img = 270;
VPIImage imgInput = NULL;
VPIImageData imgData;
memset(&imgData, 0, sizeof(imgData));
imgData.bufferType = VPI_IMAGE_BUFFER_HOST_PITCH_LINEAR;
imgData.buffer.pitch.format = VPI_IMAGE_FORMAT_NV12;
imgData.buffer.pitch.numPlanes = 2;
imgData.buffer.pitch.planes[0].width = w_img;
imgData.buffer.pitch.planes[0].height = h_img;
imgData.buffer.pitch.planes[0].pitchBytes = w_img;
imgData.buffer.pitch.planes[0].data = dst.data;

imgData.buffer.pitch.planes[1].width      = w_img;
imgData.buffer.pitch.planes[1].height     = h_img/2;
imgData.buffer.pitch.planes[1].pitchBytes = w_img;
imgData.buffer.pitch.planes[1].data       = dst.data + (w_img*h_img);
CHECK_STATUS(vpiImageCreateWrapper(&imgData, nullptr, 0, &imgInput));

where dst is opencv Mat

Hi,

There is an API to wrap an OpenCV image into a VPI image.
Would you mind using it instead?

https://docs.nvidia.com/vpi/group__VPI__OpenCVInterop.html#ga5773833fea8b2b3607751cf9b1087209

Thanks.

It works, thank you.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.