OpenCV and nvbufsurface: mapping of memory type (2) not supported Error

Please provide complete information as applicable to your setup.

• GPU: GTX 1660ti
• Deepstream Version: 7.1
• Nvidia-Driver Version: 566.14 | CUDA Version: 12.7
• OS: Windows 11 (WSL)

I am running my custom solution inside docker desktop and the enginer being utilized is WSL.

I have modified the deepstream-test5-app to generate base64 encoded frames via a custom function. I have also modified the Makefile to include openCV for usage in the deepstream_nvdsanalytics.cpp file in which the custom function is defined.

My objective is to extract each frame, encode it in base64 to send over kafka.

Whenever I call this function however I get the following error:

terminate called after throwing an instance of 'cv::Exception'
  what():  OpenCV(3.4.18) /opencv/modules/core/src/matrix.cpp:428: error: (-215:Assertion failed) total() == 0 || data != NULL in function 'Mat'
Aborted (core dumped)

I have tried all supported values for nvbuf-memory-type in my config file, ranging from 0-4 for all elements, but none seems to work.

Kindly let me know what I am doing wrong, as the application works perfectly otherwise.
Here are my custom application files:
custom_solution.zip (21.5 KB)

I have shifted from building deepstream solutions in python to C, so please forgive my lack of understanding, but any help will be really appreciated :)

Please make sure you follow DeepStream On WSL — DeepStream documentation to setup the WSL2 environment first.

Hello Fiona,
Thank you for responding to my query.
So I already have followed this and setup deepstream properly, and it works very well with all the default pre-built applications on my PC and WSL environment.

My problem is that I am trying to run a custom function to extract and encode base64 images. To do that I need to use access a different type of memory and use opencv.

I have added opencv to my make file but when I try to run it I get the following error:

  what():  OpenCV(3.4.18) /opencv/modules/core/src/matrix.cpp:428: error: (-215:Assertion failed) total() == 0 || data != NULL in function 'Mat'
Aborted (core dumped)

I feel like I might be accessing the memory incorrectly.
I have already attached my code. Can you please tell me what I am doing wrong?

@Fiona.Chen
Any update on this?

There is already sample of using opencv to handle the data inside NvBufSurface.I’ve tried the sample in WSL2, it works. Please refer to /opt/nvidia/deepstream/deepstream/sources/apps/sample_apps/deepstream-opencv-test

The keys:

  1. Enable opencv function of “gst-dsexample” first, please refer to /opt/nvidia/deepstream/deepstream/sources/gst-plugins/gst-dsexample/README.
  2. The dsexample can also be used with test5 sample app. You only need to add the following configuration in your deepstream-test5-app configuration YAML file
ds-example:
  enable: 1
  full-frame: 0
  blur-objects: 1
  processing-width: 720
  processing-height: 576
  unique-id: 78
  gpu-id: 0
  nvbuf-memory-type: 1
  1. gst-dsexample is open source, you may refer to the implementation of /opt/nvidia/deepstream/deepstream/sources/gst-plugins/gst-dsexample/gstdsexample.cpp and /opt/nvidia/deepstream/deepstream/sources/apps/apps-common/src/deepstream_dsexample.c for how to transfer the correct NvBufSurface buffer to opencv

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