I’m trying to implement Nvidia VPI Convert Image Format algorithm. When my output image is in a PitchLinear format, I’m not having any issue, I am able to access raw data of image correctly, either by using .buffer.pitch or by exporting to a cvMat and working with cvMat.data (when viable conversion).
On the other hand, when using some BlockLinear output, I have not found a way to access raw data in images (either to export it to a cv mat or to store it in another place)(the “common” and “most seen” way is locking image using vpiImageLockData, but this is only compatible with Pitch Linear bufferTypes, not BL), I took a look at documentation, and I did not really find anything useful that may help me with this.
My simplified code to convert from BGR to NV12_ER_BL looks like:
void BGRToNV12_ER_BL(const cv::Mat& cvIn, cv::Mat& cvOut)
{
VPIContext context;
vpiContextCreate(0, &context);
vpiContextSetCurrent(context);
VPIStream stream;
vpiStreamCreate(0, &stream);
VPIImage input;
vpiImageCreateWrapperOpenCVMat(cvIn, 0, &input);
VPIImage middle;
vpiImageCreate(w, h, VPI_IMAGE_FORMAT_BGRA8, 0, &middle);
VPIImage output;
vpiImageCreate(w, h, VPI_IMAGE_FORMAT_NV12_ER_BL, 0, &output); //also this could be with VPI_RESTRICT_MEM_USAGE instead of 0 flag to restrict locking image
vpiSubmitConvertImageFormat(stream, VPI_BACKEND_CUDA, input, middle, NULL);
vpiSubmitConvertImageFormat(stream, VPI_BACKEND_VIC, middle, output, NULL);
vpiStreamSync(stream);
/*
Here, I don't know how to lock output image to retrieve its data from VIC memory,
considering it is NV12_ER_BL, that does not use pitch
and considering that vpiImageLockData does not support
VPI_IMAGE_BUFFER_CUDA_ARRAY, only VPI_IMAGE_BUFFER_HOST_PITCH_LINEAR
and VPI_IMAGE_BUFFER_CUDA_PITCH_LINEAR, which are not
suitable here, since I want Block Linear
*/
VPIImageData outData;
}
Any ideas?