[VPI] vpiImageDataImportOpenCVMat vs vpiImageSetWrappedOpenCVMat

Hi,

I am writing a simple application on jetson orin using the latest VPI (3.2).

The application is loading video image data as cv::Mat and passing it to VPI for further processing. I’m unclear on details of how to do it properly.

I see there are two methods:

  • lockImageData and vpiImageDataImportOpenCVMat
  • vpiImageSetWrappedOpenCVMat
    Which one is preferred, is there difference at all? The documentation seems to be unclear on it.

Another question, looking at the examples (VPI - Vision Programming Interface: Pyramidal LK Optical Flow), they tend to use vpiImageSetWrappedOpenCVMat and load data into a VPI wrapped cv::Mat without locking the VpiImage that is wrapping the cv::Mat. Is this safe to do? As I understand, when writing to cv::Mat that is wrapped the wrapper should be locked to block async access to the image when writing.

Thanks!

Hi,

You can import an OpenCV image to VPI with vpiImageCreateWrapperOpenCVMat.
No need to lock image data. The API is usually used when you need to access VPI image data.

You can find a sample below:

As you mentioned, the wrap doesn’t allocate memory so you will need to take care of it.

We also have another API called vpiImageDataExportOpenCVMat, which will copy the data from VPI into OpenCV.

Thanks.

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