How to convert NvBufSurface to cv::cuda::GpuMat?

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU): GeForce RTX 3090
• DeepStream Version: 6.1
• TensorRT Version: 8.2
• NVIDIA GPU Driver Version (valid for GPU only): 510
• Issue Type( questions, new requirements, bugs): Questions

I want to do colour detection on detected objects using OpenCV. Using OpenCV CPU imposed significant overhead so I want to switch to OpenCV CUDA in hope of seeing better real-time performance. There are examples on how to convert NvBufSurface to cv::Mat but I couldn’t find any example on how to convert NvBufSurface to cv::cuda::GpuMat. So how do I use OpenCV CUDA with Deepstream buffer to improve performance?

please refer to NvBufSurface and OpenCV

1 Like

Hi @fanzh,

Thank you for your response, I have read the thread and the document it links to. I have a follow-up question, why do I have to run cv::cuda::swapChannels(gpuMat, aDstOrder); with const int aDstOrder[] = {2,0,1,3};, what is the original colour space and what is the new colour space? Are we doing RGBA to BRGA?

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

It’s only a sample, please convert as needed, the origin is RGBA. please refer to cv::cuda::swapChannels in OpenCV: Color space processing

1 Like

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