Reading R,G,B values for specific pixel from NvBufSurface Using Cuda APIs

• Hardware Platform - Jetson
• DeepStream Version - 5.1
• TensorRT Version - 7.1.3
• NVIDIA GPU Driver Version - cuda10.2
• Reading data from NvBufSurface
• Requirement details

I’m currently trying to access the RGB values of a single pixel located at a predetermined location in a frame of video. NvBufSurface stores the video frame data. After referring to the documentation here, I was able to read the NVBufSurface from GPU memory using cv::cuda::GpuMat .

cv::cuda::GpuMat gpuMat;
const int aDstOrder[] = {2,0,1,3};
unsigned int index = 0;   // Index of the buffer in the batch.
unsigned int width, height; // set width and height of buffer
NvBufSurface *input_buf; // Pointer to input NvBufSurface

gpuMat = cv::cuda::GpuMat(height, width, CV_8UC4,
(void *)input_buf->surfaceList[index].dataPtr);

When using this approach I faced the following error:

what(): OpenCV(4.1.1) /home/nvidia/host/build_opencv/nv_opencv/modules/core/include/opencv2/core/private.cuda.hpp:107: error: (-216:No CUDA support) The library is compiled without CUDA support in function 'throw_no_cuda'

It seems this approach requires OpenCV with GPU support. Rebuilding OpenCV with GPU support is not viable option for my application.

Is there any approach to read NvBufsurface using Cuda APIs or any pointers to which specific Cuda APIs I should look into ?

Please find my related post in DeepStream SDK forum for reference. @Fiona.Chen suggested this can be achieved with Cuda APIs and recommended to check this forum.