NvBuffer to cpu memory

Hi folks,
I am using multimedia API with R28.1 for my TX2. I tried to capture raw frames to CPU memory after scaling. In example “camera_v4l2_cuda”. I can successfully get a frame from conv0’s capture NvBuffer’s planes[0] without mmap the buffer to userspace. Is the buffer data pointer is already been “mmap” to userspace before “conv_capture_dqbuf_thread_callback” function been called? I just get confused about it.

Just to clarify, is this the right way to capture a raw frame? Please specify the right way to get a frame if it is not.

Thanks.

Kevin

Hi,
Yes, it is mapped by default.

int setupPlane(enum v4l2_memory mem_type, uint32_t num_buffers, bool map, bool allocate);
// Allocate VIC capture plane
    if (ctx->conv->capture_plane.setupPlane(V4L2_MEMORY_MMAP,
                V4L2_BUFFERS_NUM, true, false) < 0)
        ERROR_RETURN("Failed to allocate VIC capture plane");

Hi DaneLLL,

When delete the video conveter at the end, the example camera_v4l2_cuda get segmentation fault. I use R28.1.

Kevin

It looks that R28.2.1 have fixed the problem. But the changes from R28.2.1 to R28.1 are huge. Can we use push r28.2.1’s multimedia api to r28.1? Otherwise the patches is another way for us to fix the problem within R28.1’s multimedia api.

Please try attachment.

libv4l2_nvvidconv_r28_1.zip (13 KB)

Thanks DaneLLL,
I debugged with the dumped core, and error is pointing to libv4l2_nvvidconv.so. So I back porting both “libv4l2_nvvideocodec.so” and "libv4l2_nvvidconv.so form R28.2.1. and then work fine. Are there have any differences between the file you provide? We will put this code in our final product, so it is Ok use this patched R28.1, right? Since we do not have any plan moving to R28.2.1 for our current release.

Hi,
We suggest use attachment in #5
It is built based on r28.1 + fix of this issue.

Hi DaneLLL,

Thank you for your support. We notice tearing issue if the camera source captured at lower rate, Our USB camera only stream at 60fps 1080p. It seems OK to set the rendering rate at 60fps, with “camera_v4l2_cuda” default 30fps, we always notice tearing. Which mean for the VIC output plane, it can get buffer at 60fps, and the VIC queues is synced at capture side at 30fps. Is this will be the a problem?

Thanks

Hi,
Please implement the logic in start_Capture() and try again. The framerate is expected to be matched, so for the mismatched-framerate case you describe, it may hit race condition that the buffer is queued back while VIC is still processing it.

//
            // Enqueue camera buff
            // It might be more reasonable to wait for the completion of
            // VIC processing before enqueue current buff. But VIC processing
            // time is far less than camera frame interval, so we probably
            // don't need such synchonization.
            if (ioctl(ctx->cam_fd, VIDIOC_QBUF, &v4l2_buf))
                ERROR_RETURN("Failed to queue camera buffers: %s (%d)",
                        strerror(errno), errno);

Hi DaneLLL,
Yes, that’s works, Thank you for pointing out.