How to implement cv::imdecode with VPI 2.0.14?

In OpencV, data in memory is usually decoded this way:

// get raw data in memory 
std::vector<uchar> vec_data_encode;

// decode by opencv
cv::Mat mat_decode = cv::imdecode(vec_data_encode, cv::IMREAD_COLOR);
cv::imwrite("./mat_decode.png", mat_decode);

How to implement cv::imdecode with VPI 2.0.14?
Can vpiSubmitConvertImageFormat do this?


Hello @yangshuai7,

Your issue looks to be posted in the wrong category, you posted in the Software and Drivers section of Networking. Can you please provide more information on your issue, and I can move it to the proper forum.


My hardware is Jetson AGX Orin, and I want to replace part of OpenCV’s interface with VPI ( Vision Programming Interface, a computer vision library by NVIDIA ).

I have moved it to Computer Vision & Image Processing.

1 Like

vpiSubmitConvertImageFormat converts between vpi formats.
In all the examples they create a cv::Mat and then convert it to a VPIImage with vpiImageCreateOpenCVMatWrapper/vpiImageSetWrappedOpenCVMat
There is a function that takes a pointer (vpiImageCreate) but I’m not sure if it can take just any pointer.

I don’t think cv::imdecode can be implemented in VPI.
I’m currently trying jetson_multimedia_api.

I found jpeg_encode sample in jpeg_encode sample, and can generate image use command:
$ ./jpeg_encode ../../data/Picture/nvidia-logo.yuv 1920 1080 test.jpg

But how to convert std::vector<uchar> to *.yuv ? Do you have any idea?