Issue getting frame data on Jetson (DS 4.0.2)

Platform: Jetson
DS: 4.0.2
Jetpack: 4.3
TensorRT: 6.0

I’m encountering an odd issue with the data size for the frame. The exact same code works perfectly fine on a dGPU, but on Jetson it gives slight off values.

For example, if I print out the dataSize of the surface object


Using: nvbufsurface_create_params.colorFormat = NVBUF_COLOR_FORMAT_RGB

dGPU: 6220800 bytes (1920x1080x3)
Jetson: 6422528 byte (can’t figure out what this resolves to with resolution x channels)

Additionally, I get the following error on Jetson, but not on a dGPU:

NvBufSurfTransform failed with error -2 while converting buffer
nvbufsurface: Wrong buffer index (0)

If I use: nvbufsurface_create_params.colorFormat = NVBUF_COLOR_FORMAT_RGBA

dGPU: 8294400 bytes (1920x1080x4)
Jetson: 8388608 bytes (this also doesn’t align with any combination of resolution x channels)

With NVBUF_COLOR_FORMAT_RGBA I do not get any errors regarding nvbufsurface, but I can’t seem to resolve the colour space to get a proper image. I can get a garbled one though.

Here’s the section for setting the NvBufSurfaceCreateParams:

NvBufSurfaceCreateParams nvbufsurface_create_params;
/* An intermediate buffer for NV12/RGBA to BGR conversion will be
** required. Can be skipped if custom algorithm can work directly on NV12/RGBA. */
nvbufsurface_create_params.gpuId = surface->gpuId;
nvbufsurface_create_params.width = (gint) surface->surfaceList[0].width;
nvbufsurface_create_params.height = (gint) surface->surfaceList[0].height;
nvbufsurface_create_params.size = 0;
nvbufsurface_create_params.colorFormat = NVBUF_COLOR_FORMAT_RGBA;
nvbufsurface_create_params.layout = NVBUF_LAYOUT_PITCH;

#ifdef IS_TEGRA
nvbufsurface_create_params.memType = NVBUF_MEM_DEFAULT;
nvbufsurface_create_params.memType = NVBUF_MEM_CUDA_UNIFIED;

Have you tried with NVBUF_LAYOUT_BLOCK_LINEAR for the layout in Tegra?

Gave it a shot. No change, same errors.

Thanks for the suggestion though.

Edit: Actually, the size of the frame is now 6684672 bytes (using NVBUF_COLOR_FORMAT_RGB). Which if I divide by 1920 and 1080, it gives me 3.2237. Not exactly an even 3 or 4 channels. I’m pretty sure it’s not getting the frame data at all and that’s just some default value the pointer is picking up.

NVBUF_COLOR_FORMAT_RGB is supported on desktop GPU. Not supported on Jetson platforms. On Jetson platforms, please use NVBUF_COLOR_FORMAT_RGBA.

@DaneLLL Thank you for the input. I was able to resolve my issue. Now that I know that NVBUF_COLOR_FORMAT_RGBA is the format I need to resolve on the Jetson I was able to perform the correct colour conversion and get sane frame data.