Gstreamer userptr usecase

Hi all,

I’m trying to use gstreamer v4l2src userptr io-mode for image handling with cuda process.
I found v4l2cuda sample application from nvidia download center and it helps me to understand how can I use userptr for cuda processing.
But in my case, I’m running my camera with c++ gstreamer application.
V4l2cuda sample application runs camera with xioctl command.

So my question is how can I use userptr with my gstreamer application. How can I assign cuda buffer to my gstreamer pipeline. I can alloc cuda buffer but I don’t know how can I assign this buffer to gst pipeline.

Thanks in advance.

Hi,
We have implemented nvv4l2camerasrc plugin for capturing frames into NVMM buffers(NvBuffer). You can get CUDA pointer through NvBuffer APIs. May check if it can be applied to your usecase. If you would like to do customization, you can download the source code. it is in the package:
https://developer.nvidia.com/embedded/l4t/r32_release_v5.1/r32_release_v5.1/sources/t186/public_sources.tbz2

Hi @DaneLLL

Thank you for your reply.
I checked nvv4l2camerasrc and it’s little bit different from what expect.

I want to allocate memory in my application with cudaMallocManaged for zero copy cuda processing.
So I need to apply cudaMallocManaged buffer to my gstreamer pipeline by using userptr io-mode.
Could you let me know if you have any idea or sample codes to do this?

Thanks,
Dongjin Ha.

Hi,
On Jetson platforms, we would suggest use NvBuffer since you can get CUDA pointer through NvBuffer APIs. If you have to allocate buffers with cudaMallocManaged, may start with nvv4l2camerasrc. Or you can download source code of v4l2src and check if it is more suitable for the customization.

Hi @DaneLLL
I wish to use cudaMallocManaged because I need to implement zero copy for image processing.
BTW, do I need to download v4l2src and customize it for using cudaMallocManaged buffer?
I thought v4l2src has userptr io-mode and I could use it for cudaMallocManaged buffer without customize v4l2src plugin. I just don’t know how to assign that buffer to v4l2 userptr.

Thanks,
Dongjin Ha.

Hi,
Please go to gstreamer forum to get more information. We don’t have much experience in launching v4l2src with GST_V4L2_IO_USERPTR. Users in the forum are more experienced.

One possible solution we can think of is to use appsrc. You can do capture like v4l2cuda and feed into a pipeline like appsrc ! video/x-raw ! ….

Hi,

I think appsrc with vl42cuda sources can be a way to use cudaMallocManaged.
Thank you for your support.