![]() |
Jetson Linux Multimedia API Reference32.4.2 Release |
This sample uses V4L2 image capturing with NVIDIA® CUDA® format conversion.
$ cd v4l2cuda $ make
Enter
make clean
$ ./capture-cuda [options]
$ ./capture-cuda --help
This is the overall process flow of capture-cuda:
V4L2 CUDA USB camera ------> captured image (YUYV) ------> converted image (RGB)
As shown in the following diagrams, the buffer flow differs depending on V4L2 capturing modes and CUDA memory management.
V4L2 memory-mapped buffers (V4L2_MEMORY_MMAP) are allocated in kernel space. The application maps them in user space and copies them to the CUDA device allocated memory for CUDA processing.
The application allocates V4L2 user-space buffers (V4L2_MEMORY_USERPTR). In this situation, the driver directly fills in the user-space memory. When you allocate CUDA-mappable memory (with cudaHostAlloc
), the CUDA device can access the V4L2 captured buffer without memory copy.
$ ./capture-cuda -d /dev/video0 -m _ _ _ _ | | mmap copy | | convert | | copy | | write |_| ------> ptr ------> |_| =========> |_| ------> |_| -------> file | kernel | user
$ ./capture-cuda -d /dev/video0 -m -z _ _ _ | | mmap copy | | convert | | write |_| ------> ptr ------> |_| =========> |_| -------> file | kernel | user
$ ./capture-cuda -d /dev/video0 -u _ _ _ _ userptr | | copy | | convert | | copy | | write ---------> |_| ------> |_| =========> |_| ------> |_| -------> file | kernel | user
$ ./capture-cuda -d /dev/video0 -u -z _ _ userptr | | convert | | write ---------> |_| =========> |_| -------> file | kernel | user