• Hardware Platform Jetson
• DeepStream Version 6
• JetPack Version 4.6
• TensorRT Version 8
• Issue Type questions
I am following the instructions from the documentation to access the frames from the NvBufSurface
’s surfaceList
. The documentation suggests using dataPtr
, but in nvbfsurface.h
we can find this comment for the field:
/** Holds a pointer to allocated memory. Not valid for
\ref NVBUF_MEM_SURFACE_ARRAY or \ref NVBUF_MEM_HANDLE. */
void * dataPtr;
SInce NVBUF_MEM_SURFACE_ARRAY
is the default for Tegra, how should I access the memory on a Jetson?
Then, the second suggested option for creating a cv::cuda::GpuMat
uses the pitch
. In that case, the documentation tells to use cv::cuda::swapChannels
with a weird destination order. What are the original and the destination color formats here, and why do we have to do this?
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);
# OR
gpuMat = cv::cuda::GpuMat(height, width, CV_8UC4,
(void *) input_buf->surfaceList[index].dataPtr,
input_buf->surfaceList[index].pitch);
cv::cuda::swapChannels(gpuMat, aDstOrder);