How to access the data in NvBufSurface using jetson multimedia API for JPEG decoding


I am using jetson multimedia api to decode a jpeg image with the hardware decoder on the Jetson AGX Orin.

The current flow is as follows

  1. Use NvJPEGDecoder::decodetoFd to decode the JPEG image to hardware buffer (this is in YUV format)
  2. Transform from YUV to BGRA with NvBufSurface::NvTransform.
  3. Use NvBufSurfaceFromFd to get the pointer to the NV buffer surface.
  4. Map the hardware buffer to CPU with NvBufSurfaceMap and use the surfaceList.mappedAddr.addr to access the data from the NvBufSurface.

In order to avoid the overhead of CPU mapping, I want to access the buffer data from the NvBufSurface directly (from the GPU memory) to create a torch tensor out of it. Does anyone know how to achieve this?

Thank you in advance.

For getting GPU pointer of NvBufSurface, please refer to this patch:
How to create opencv gpumat from nvstream? - #18 by DaneLLL

You can get the pointer by the function calls:


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