NvBuffer mapping to GpuMat

I’m developing video streaming application, one important part is video processing.
I use Argus framework to capture video. All the frame processing is done in GPU, so, I want to minimize data transfers as much as possible.
I’m able to access NvBufer from CPU via NvBufferMemMap and NvBufferMemSyncForCpu, but it requires data transfer (convert cv::Mat to cv::cuda::GpuMat).
The second option is to create EGLImage via NvEGLImageFromFd, but as far as I understand this requires data copy from DMA buffer.

I also found NvBufferMemSyncForDevice, but I doesn’t work as I expect (it can’t be used to access data from GPU like it can be done from CPU via NvBufferMemSyncForCpu).

I also found this topic, but there was no direct solution to this problem.

As far as I know, Jetson Nano shares the same physical memory for CPU and GPU, so it seems like there is no fundamental limitation to directly map DMA buffer to GPU.

Please refer to the patch:
LibArgus EGLStream to nvivafilter - #14 by DaneLLL

This patch still uses NvEGLImageFromFd. Is it true, that creation of EGLImage from NVBuffer implies a copy?


No, it doesn’t copy the frame data. It is more like to wrap NvBuffer into EGLImage. To fill in data structure of EGLImage and frame data is in same memory.

Do I understand you correctly?

When I capture the frame - it lives in DMA buffer. NvBuffer is some kind of wrapper around DMA buffer. Then I create EGLImage from NVBuffer - still the same memory. Then pass EGLImage to GpuMat - it uses the same buffer.

So, pipeline Capture → NvBuffer → EGLImage → GpuMat doesn’t perform any copies of memory and everything is the same piece of memory. Is it right?

Yes, it is correct.

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