Convert from LINEAR to PITCH for nvdcf tracker

Please provide complete information as applicable to your setup.

**• x86_64 Ubuntu 18.04**
**• Deepstream 4.0**
**• Driver 430.64**
**• CUDA 10.1**


So I’m using OpenCV to create a RGB image and then running it through gstreamer to convert the frame to NV12 for me. The problem is that I’m having trouble sending the NV12 frame as an input to the tracker and getting results from it. I think this is because I’m not transforming the NV12 frame properly to the pitch layout that NvBufSurface expects. How do I achieve this?

This is what I tried:

NvBufSurfaceCreateParams surfaceCreateParams;
surfaceCreateParams.layout = NVBUF_LAYOUT_PITCH;
surfaceCreateParams.colorFormat = NVBUF_COLOR_FORMAT_NV12;
surfaceCreateParams.width = 512;
surfaceCreateParams.height = 512;
surfaceCreateParams.isContiguous = true;
surfaceCreateParams.size = 0;
surfaceCreateParams.gpuId = 0;
surfaceCreateParams.memType = _query.memType;

auto _nvBufSurface = new NvBufSurface();
NvBufSurfaceCreate(&_nvBufSurface, 1, &surfaceCreateParams);
NvBufSurfaceMap(_nvBufSurface, 0, -1, NvBufSurfaceMemMapFlags::NVBUF_MAP_READ_WRITE);

// Then When I get a new NV12 frame in CPU space from gstreamer, I do:

// I have also tried doing a direct map like:

you can use nvvideoconvert plugin to convert CPU NV12 data to nvmm NV12 data. So basically internally it will transform CPU memory to CUDA memory.
Also, pls use DS 5.0 since there are some DCF related issues fixed in the version.

Hey @bcao,

I understand I can use the gstreamer to do this. I’m wondering how I can get the CPU NV12 from gstreamers regular “videoconvert” plugin into aligned properly in cuda memory manually using the CUDA API that the DCF tracker can take.

I have not played around using “nvvidconv” or “nvvideoconvert” yet so I don’t want to add that complexity yet.

videoconvert is not owned by nvidia, we are not responsible for that.

We will add a sample code for this convertion later, currently I still suggest you to use nvvideoconvert as comment 2 said.