VPI thread safe

Is vpiImageLockData and vpiImageDataExportOpenCVMat in VPI 2.3.9 thread safe?

The VPI documentation mentioned that “All API functions are thread-safe”.

I tested it a few times showing that it might not.

I run these two functions in my thread pool, showing that it might cause a segmentation fault program. Once I add a mutex to ensure the vpiImageLockData and vpiImageDataExportOpenCVMat are not running in parallel, no segmentation happens anymore.

Steps to reproduce the problem

// Note: You need to create a vpiImage first.

  // Step 1: Get the VPIImage data
  VPIImageData vpiImageData;
  checkVPIErrors(vpiImageLockData(vpiImage, VPI_LOCK_READ, VPI_IMAGE_BUFFER_HOST_PITCH_LINEAR, &vpiImageData));

  // Step 2: Convert VPIImageData to OpenCV Mat
  cv::Mat cvImage;
  checkVPIErrors(vpiImageDataExportOpenCVMat(vpiImageData, &cvImage));

  // Step 3: Just clone the image
  // Segmentation fault happens here.
  cv::Mat tmp = cvImage.clone();

  // Step 4: Unlock the VPIImage
  checkVPIErrors(vpiImageUnlock(vpiImage));

Put the above code into a multithreading function and keep calling it.

There is no update from you for a period, assuming this is not an issue any more.
Hence we are closing this topic. If need further support, please open a new one.
Thanks

Hi,

Would you mind sharing a complete sample so we can test it?
Thanks.