L4T Multimedia API Reference

28.1 Release

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
multimedia_api/ll_samples/docs/l4t_mm_v4l2cuda.md
Go to the documentation of this file.
1 Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved.
2 
3 @page l4t_mm_v4l2cuda_group v4l2cuda (capture-cuda)
4 @{
5 
6  - [Overview](#overview)
7  - [Building and Running](#build_and_run)
8  - [Flow](#flow)
9  - [Key Classes and Methods](#key)
10 
11 - - - - - - - - - - - - - - -
12 <a name="overview">
13 ## Overview ##
14 
15 This sample uses V4L2 image capturing with
16 NVIDIA<sup>&reg;</sup> CUDA<sup>&reg;</sup> format conversion.
17 
18 
19 <a name="build_and_run">
20 ## Building and Running ##
21 
22 #### Prerequisites ####
23 * You have followed Steps 1-3 in @ref mmapi_build.
24 * You have installed:
25  * CUDA Toolkit
26  * OpenCV4Tegra
27 * A USB camera suppporting YUYV output format is plugged into your target.
28 
29 
30 ### To build
31 * Enter:
32 
33  $ cd v4l2cuda
34  $ make
35 
36 ### To clean up all generated files
37 * Enter
38 
39  make clean
40 
41 ### To run
42 * Enter:
43 
44  $ ./capture-cuda [options]
45 
46 ### To view supported options
47 * Enter:
48 
49  $ ./capture-cuda --help
50 
51 
52 <a name="flow">
53 - - - - - - - - - - - - - - -
54 ##Flow
55 
56 This is the overall process flow of capture-cuda:
57 
58  V4L2 CUDA
59  USB camera ------> captured image (YUYV) ------> converted image (RGB)
60 
61 
62 As shown in the following diagrams, the buffer flow differs depending on V4L2
63 capturing modes and CUDA memory management.
64 
65 V4L2 memory-mapped buffers (V4L2_MEMORY_MMAP) are allocated in kernel space. The
66 application maps them in user space and copies them to the CUDA device allocated
67 memory for CUDA processing.
68 
69 The application allocates V4L2 user-space buffers (V4L2_MEMORY_USERPTR). In
70 this situation, the driver directly fills in the user-space memory. When you allocate
71 CUDA-mappable memory (with `cudaHostAlloc`), the CUDA device can access the V4L2
72 captured buffer without memory copy.
73 
74 ### Using Memory-Mapped Buffers (-m option)
75 
76  $ ./capture-cuda -d /dev/video0 -m
77 
78  _ _ _ _
79  | | mmap copy | | convert | | copy | | write
80  |_| ------> ptr ------> |_| =========> |_| ------> |_| -------> file
81  |
82  kernel | user
83 
84 ### Using Memory-Mapped Buffers and Zero-Copy CUDA Memory (-m and -z options)
85 
86  $ ./capture-cuda -d /dev/video0 -m -z
87 
88  _ _ _
89  | | mmap copy | | convert | | write
90  |_| ------> ptr ------> |_| =========> |_| -------> file
91  |
92  kernel | user
93 
94 ### Using Application-Allocated Buffers (-u option)
95 
96  $ ./capture-cuda -d /dev/video0 -u
97 
98  _ _ _ _
99  userptr | | copy | | convert | | copy | | write
100  ---------> |_| ------> |_| =========> |_| ------> |_| -------> file
101  |
102  kernel | user
103 
104 ### Using Application-Allocated Buffers and Zero-Copy CUDA Memory (-u and -z options)
105 
106  $ ./capture-cuda -d /dev/video0 -u -z
107 
108  _ _
109  userptr | | convert | | write
110  ---------> |_| =========> |_| -------> file
111  |
112  kernel | user
113 
114 @}