L4T Multimedia API Reference

32.3.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 * A USB camera suppporting YUYV output format is plugged into your target.
27 
28 
29 ### To build
30 * Enter:
31 
32  $ cd v4l2cuda
33  $ make
34 
35 ### To clean up all generated files
36 * Enter
37 
38  make clean
39 
40 ### To run
41 * Enter:
42 
43  $ ./capture-cuda [options]
44 
45 ### To view supported options
46 * Enter:
47 
48  $ ./capture-cuda --help
49 
50 
51 <a name="flow">
52 - - - - - - - - - - - - - - -
53 ##Flow
54 
55 This is the overall process flow of capture-cuda:
56 
57  V4L2 CUDA
58  USB camera ------> captured image (YUYV) ------> converted image (RGB)
59 
60 
61 As shown in the following diagrams, the buffer flow differs depending on V4L2
62 capturing modes and CUDA memory management.
63 
64 V4L2 memory-mapped buffers (V4L2_MEMORY_MMAP) are allocated in kernel space. The
65 application maps them in user space and copies them to the CUDA device allocated
66 memory for CUDA processing.
67 
68 The application allocates V4L2 user-space buffers (V4L2_MEMORY_USERPTR). In
69 this situation, the driver directly fills in the user-space memory. When you allocate
70 CUDA-mappable memory (with `cudaHostAlloc`), the CUDA device can access the V4L2
71 captured buffer without memory copy.
72 
73 ### Using Memory-Mapped Buffers (-m option)
74 
75  $ ./capture-cuda -d /dev/video0 -m
76 
77  _ _ _ _
78  | | mmap copy | | convert | | copy | | write
79  |_| ------> ptr ------> |_| =========> |_| ------> |_| -------> file
80  |
81  kernel | user
82 
83 ### Using Memory-Mapped Buffers and Zero-Copy CUDA Memory (-m and -z options)
84 
85  $ ./capture-cuda -d /dev/video0 -m -z
86 
87  _ _ _
88  | | mmap copy | | convert | | write
89  |_| ------> ptr ------> |_| =========> |_| -------> file
90  |
91  kernel | user
92 
93 ### Using Application-Allocated Buffers (-u option)
94 
95  $ ./capture-cuda -d /dev/video0 -u
96 
97  _ _ _ _
98  userptr | | copy | | convert | | copy | | write
99  ---------> |_| ------> |_| =========> |_| ------> |_| -------> file
100  |
101  kernel | user
102 
103 ### Using Application-Allocated Buffers and Zero-Copy CUDA Memory (-u and -z options)
104 
105  $ ./capture-cuda -d /dev/video0 -u -z
106 
107  _ _
108  userptr | | convert | | write
109  ---------> |_| =========> |_| -------> file
110  |
111  kernel | user
112 
113 @}