Add next and previous navigation links to all tutorials
[platform/upstream/opencv.git] / doc / tutorials / introduction / building_tegra_cuda / building_tegra_cuda.markdown
1 Building OpenCV for Tegra with CUDA {#tutorial_building_tegra_cuda}
2 ===================================
3
4 @prev_tutorial{tutorial_arm_crosscompile_with_cmake}
5 @next_tutorial{tutorial_display_image}
6
7
8 @tableofcontents
9
10 OpenCV with CUDA for Tegra
11 ==========================
12
13 This document is a basic guide to building the OpenCV libraries with CUDA support for use in the Tegra environment. It covers the basic elements of building the version 3.1.0 libraries from source code for three (3) different types of platforms:
14
15 * NVIDIA DRIVE™ PX 2 (V4L)
16 * NVIDIA<sup>&reg;</sup> Tegra<sup>&reg;</sup> Linux Driver Package (L4T)
17 * Desktop Linux (Ubuntu 14.04 LTS and 16.04 LTS)
18
19 This document is not an exhaustive guide to all of the options available when building OpenCV. Specifically, it covers the basic options used when building each platform but does not cover any options that are not needed (or are unchanged from their default values). Additionally, the installation of the CUDA toolkit is not covered here.
20
21 This document is focused on building the 3.1.0 version of OpenCV, but the guidelines here may also work for building from the master branch of the git repository. There are differences in some of the CMake options for builds of the 2.4.13 version of OpenCV, which are summarized below in the @ref tutorial_building_tegra_cuda_opencv_24X section.
22
23 Most of the configuration commands are based on the system having CUDA 8.0 installed. In the case of the Jetson TK1, an older CUDA is used because 8.0 is not supported for that platform. These instructions may also work with older versions of CUDA, but are only tested with 8.0.
24
25 ### A Note on Native Compilation vs. Cross-Compilation
26
27 The OpenCV build system supports native compilation for all the supported platforms, as well as cross-compilation for platforms such as ARM and others. The native compilation process is simpler, whereas the cross-compilation is generally faster.
28
29 At the present time, this document focuses only on native compilation.
30
31 Getting the Source Code {#tutorial_building_tegra_cuda_getting_the_code}
32 =======================
33
34 There are two (2) ways to get the OpenCV source code:
35
36 * Direct download from the [OpenCV downloads](http://opencv.org/releases.html) page
37 * Cloning the git repositories hosted on [GitHub](https://github.com/opencv)
38
39 For this guide, the focus is on using the git repositories. This is because the 3.1.0 version of OpenCV will not build with CUDA 8.0 without applying a few small upstream changes from the git repository.
40
41 OpenCV
42 ------
43
44 Start with the `opencv` repository:
45
46     # Clone the opencv repository locally:
47     $ git clone https://github.com/opencv/opencv.git
48
49 To build the 3.1.0 version (as opposed to building the most-recent source), you must check out a branch based on the `3.1.0` tag:
50
51     $ cd opencv
52     $ git checkout -b v3.1.0 3.1.0
53
54 __Note:__ This operation creates a new local branch in your clone's repository.
55
56 There are some upstream changes that must be applied via the `git cherry-pick` command. The first of these is to apply a fix for building specifically with the 8.0 version of CUDA that was not part of the 3.1.0 release:
57
58     # While still in the opencv directory:
59     $ git cherry-pick 10896
60
61 You will see the following output from the command:
62
63     [v3.1.0 d6d69a7] GraphCut deprecated in CUDA 7.5 and removed in 8.0
64      Author: Vladislav Vinogradov <vlad.vinogradov@itseez.com>
65      1 file changed, 2 insertions(+), 1 deletion(-)
66
67 Secondly, there is a fix for a CMake macro call that is problematic on some systems:
68
69     $ git cherry pick cdb9c
70
71 You should see output similar to:
72
73     [v3.1.0-28613 e5ac2e4] gpu samples: fix REMOVE_ITEM error
74      Author: Alexander Alekhin <alexander.alekhin@itseez.com>
75      1 file changed, 1 insertion(+), 1 deletion(-)
76
77 The last upstream fix that is needed deals with the `pkg-config` configuration file that is bundled with the developer package (`libopencv-dev`):
78
79     $ git cherry-pick 24dbb
80
81 You should see output similar to:
82
83     [v3.1.0 3a6d7ab] pkg-config: modules list contains only OpenCV modules (fixes #5852)
84      Author: Alexander Alekhin <alexander.alekhin@itseez.com>
85      1 file changed, 7 insertions(+), 4 deletions(-)
86
87 At this point, the `opencv` repository is ready for building.
88
89 OpenCV Extra
90 ------------
91
92 The `opencv_extra` repository contains extra data for the OpenCV library, including the data files used by the tests and demos. It must be cloned separately:
93
94     # In the same base directory from which you cloned OpenCV:
95     $ git clone https://github.com/opencv/opencv_extra.git
96
97 As with the OpenCV source, you must use the same method as above to set the source tree to the 3.1.0 version. When you are building from a specific tag, both repositories must be checked out at that tag.
98
99     $ cd opencv_extra
100     $ git checkout -b v3.1.0 3.1.0
101
102 You may opt to not fetch this repository if you do not plan on running the tests or installing the test-data along with the samples and example programs. If it is not referenced in the invocation of CMake, it will not be used.
103
104 __Note:__ If you plan to run the tests, some tests expect the data to be present and will fail without it.
105
106 Preparation and Prerequisites {#tutorial_building_tegra_cuda_preparation}
107 =============================
108
109 To build OpenCV, you need a directory to create the configuration and build the libraries. You also need a number of 3rd-party libraries upon which OpenCV depends.
110
111 Prerequisites for Ubuntu Linux
112 ------------------------------
113
114 These are the basic requirements for building OpenCV for Tegra on Linux:
115
116 * CMake 2.8.10 or newer
117 * CUDA toolkit 8.0 (7.0 or 7.5 may also be used)
118 * Build tools (make, gcc, g++)
119 * Python 2.6 or greater
120
121 These are the same regardless of the platform (DRIVE PX 2, Desktop, etc.).
122
123 A number of development packages are required for building on Linux:
124
125 * libglew-dev
126 * libtiff5-dev
127 * zlib1g-dev
128 * libjpeg-dev
129 * libpng12-dev
130 * libjasper-dev
131 * libavcodec-dev
132 * libavformat-dev
133 * libavutil-dev
134 * libpostproc-dev
135 * libswscale-dev
136 * libeigen3-dev
137 * libtbb-dev
138 * libgtk2.0-dev
139 * pkg-config
140
141 Some of the packages above are in the `universe` repository for Ubuntu Linux systems. If you have not already enabled that repository, you need to do the following before trying to install all of the packages listed above:
142
143     $ sudo apt-add-repository universe
144     $ sudo apt-get update
145
146 The following command can be pasted into a shell in order to install the required packages:
147
148     $ sudo apt-get install \
149         libglew-dev \
150         libtiff5-dev \
151         zlib1g-dev \
152         libjpeg-dev \
153         libpng12-dev \
154         libjasper-dev \
155         libavcodec-dev \
156         libavformat-dev \
157         libavutil-dev \
158         libpostproc-dev \
159         libswscale-dev \
160         libeigen3-dev \
161         libtbb-dev \
162         libgtk2.0-dev \
163         pkg-config
164
165 (Line-breaks and continuation characters are added for readability.)
166
167 If you want the Python bindings to be built, you will also need the appropriate packages for either or both of Python 2 and Python 3:
168
169 * python-dev / python3-dev
170 * python-numpy / python3-numpy
171 * python-py / python3-py
172 * python-pytest / python3-pytest
173
174 The commands that will do this:
175
176     $ sudo apt-get install python-dev python-numpy python-py python-pytest
177     # And, optionally:
178     $ sudo apt-get install python3-dev python3-numpy python3-py python3-pytest
179
180 Once all the necessary packages are installed, you can configure the build.
181
182 Preparing the Build Area
183 ------------------------
184
185 Software projects that use the CMake system for configuring their builds expect the actual builds to be done outside of the source tree itself. For configuring and building OpenCV, create a directory called "build" in the same base directory into which you cloned the git repositories:
186
187     $ mkdir build
188     $ cd build
189
190 You are now ready to configure and build OpenCV.
191
192 Configuring OpenCV for Building {#tutorial_building_tegra_cuda_configuring}
193 ===============================
194
195 The CMake configuration options given below for the different platforms are targeted towards the functionality needed for Tegra. They are based on the original configuration options used for building OpenCV 2.4.13.
196
197 The build of OpenCV is configured with CMake. If run with no parameters, it detects what it needs to know about your system. However, it may have difficulty finding the CUDA files if they are not in a standard location, and it may try to build some options that you might otherwise not want included, so the following invocations of CMake are recommended.
198
199 In each `cmake` command listed in the following sub-sections, line-breaks and indentation are added for readability. Continuation characters are also added in examples for Linux-based platforms, allowing you to copy and paste the examples directly into a shell. When entering these commands by hand, enter the command and options as a single line. For a detailed explanation of the parameters passed to `cmake`, see the "CMake Parameter Reference" section.
200
201 For the Linux-based platforms, the shown value for the `CMAKE_INSTALL_PREFIX` parameter is `/usr`. You can set this to whatever you want, based on the layout of your system.
202
203 In each of the `cmake` invocations below, the last parameter, `OPENCV_TEST_DATA_PATH`, tells the build system where to find the test-data that is provided by the `opencv_extra` repository. When this is included, a `make install` installs this test-data alongside the libraries and example code, and a `make test` automatically provides this path to the tests that have to load data from it. If you did not clone the `opencv_extra` repository, do not include this parameter.
204
205 Vibrante V4L Configuration
206 --------------------------
207
208 Supported platform: Drive PX 2
209
210     $ cmake \
211         -DCMAKE_BUILD_TYPE=Release \
212         -DCMAKE_INSTALL_PREFIX=/usr \
213         -DBUILD_PNG=OFF \
214         -DBUILD_TIFF=OFF \
215         -DBUILD_TBB=OFF \
216         -DBUILD_JPEG=OFF \
217         -DBUILD_JASPER=OFF \
218         -DBUILD_ZLIB=OFF \
219         -DBUILD_EXAMPLES=ON \
220         -DBUILD_JAVA=OFF \
221         -DBUILD_opencv_python2=ON \
222         -DBUILD_opencv_python3=OFF \
223         -DENABLE_NEON=ON \
224         -DWITH_OPENCL=OFF \
225         -DWITH_OPENMP=OFF \
226         -DWITH_FFMPEG=ON \
227         -DWITH_GSTREAMER=OFF \
228         -DWITH_GSTREAMER_0_10=OFF \
229         -DWITH_CUDA=ON \
230         -DWITH_GTK=ON \
231         -DWITH_VTK=OFF \
232         -DWITH_TBB=ON \
233         -DWITH_1394=OFF \
234         -DWITH_OPENEXR=OFF \
235         -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-8.0 \
236         -DCUDA_ARCH_BIN=6.2 \
237         -DCUDA_ARCH_PTX="" \
238         -DINSTALL_C_EXAMPLES=ON \
239         -DINSTALL_TESTS=OFF \
240         -DOPENCV_TEST_DATA_PATH=../opencv_extra/testdata \
241         ../opencv
242
243 The configuration provided above builds the Python bindings for Python 2 (but not Python 3) as part of the build process. If you want the Python 3 bindings (or do not want the Python 2 bindings), change the values of `BUILD_opencv_python2` and/or `BUILD_opencv_python3` as needed. To enable bindings, set the value to `ON`, to disable them set it to `OFF`:
244
245     -DBUILD_opencv_python2=OFF
246
247 Jetson L4T Configuration
248 ------------------------
249
250 Supported platforms:
251
252 * Jetson TK1
253 * Jetson TX1
254
255 Configuration is slightly different for the Jetson TK1 and the Jetson TX1 systems.
256
257 ### Jetson TK1
258
259     $ cmake \
260         -DCMAKE_BUILD_TYPE=Release \
261         -DCMAKE_INSTALL_PREFIX=/usr \
262         -DCMAKE_CXX_FLAGS=-Wa,-mimplicit-it=thumb \
263         -DBUILD_PNG=OFF \
264         -DBUILD_TIFF=OFF \
265         -DBUILD_TBB=OFF \
266         -DBUILD_JPEG=OFF \
267         -DBUILD_JASPER=OFF \
268         -DBUILD_ZLIB=OFF \
269         -DBUILD_EXAMPLES=ON \
270         -DBUILD_JAVA=OFF \
271         -DBUILD_opencv_python2=ON \
272         -DBUILD_opencv_python3=OFF \
273         -DENABLE_NEON=ON \
274         -DWITH_OPENCL=OFF \
275         -DWITH_OPENMP=OFF \
276         -DWITH_FFMPEG=ON \
277         -DWITH_GSTREAMER=OFF \
278         -DWITH_GSTREAMER_0_10=OFF \
279         -DWITH_CUDA=ON \
280         -DWITH_GTK=ON \
281         -DWITH_VTK=OFF \
282         -DWITH_TBB=ON \
283         -DWITH_1394=OFF \
284         -DWITH_OPENEXR=OFF \
285         -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-6.5 \
286         -DCUDA_ARCH_BIN=3.2 \
287         -DCUDA_ARCH_PTX="" \
288         -DINSTALL_C_EXAMPLES=ON \
289         -DINSTALL_TESTS=OFF \
290         -DOPENCV_TEST_DATA_PATH=../opencv_extra/testdata \
291         ../opencv
292
293 __Note:__ This uses CUDA 6.5, not 8.0.
294
295 ### Jetson TX1
296
297     $ cmake \
298         -DCMAKE_BUILD_TYPE=Release \
299         -DCMAKE_INSTALL_PREFIX=/usr \
300         -DBUILD_PNG=OFF \
301         -DBUILD_TIFF=OFF \
302         -DBUILD_TBB=OFF \
303         -DBUILD_JPEG=OFF \
304         -DBUILD_JASPER=OFF \
305         -DBUILD_ZLIB=OFF \
306         -DBUILD_EXAMPLES=ON \
307         -DBUILD_JAVA=OFF \
308         -DBUILD_opencv_python2=ON \
309         -DBUILD_opencv_python3=OFF \
310         -DENABLE_PRECOMPILED_HEADERS=OFF \
311         -DWITH_OPENCL=OFF \
312         -DWITH_OPENMP=OFF \
313         -DWITH_FFMPEG=ON \
314         -DWITH_GSTREAMER=OFF \
315         -DWITH_GSTREAMER_0_10=OFF \
316         -DWITH_CUDA=ON \
317         -DWITH_GTK=ON \
318         -DWITH_VTK=OFF \
319         -DWITH_TBB=ON \
320         -DWITH_1394=OFF \
321         -DWITH_OPENEXR=OFF \
322         -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-8.0 \
323         -DCUDA_ARCH_BIN=5.3 \
324         -DCUDA_ARCH_PTX="" \
325         -DINSTALL_C_EXAMPLES=ON \
326         -DINSTALL_TESTS=OFF \
327         -DOPENCV_TEST_DATA_PATH=../opencv_extra/testdata \
328         ../opencv
329
330 __Note:__ This configuration does not set the `ENABLE_NEON` parameter.
331
332 Ubuntu Desktop Linux Configuration
333 ----------------------------------
334
335 Supported platforms:
336
337 * Ubuntu Desktop Linux 14.04 LTS
338 * Ubuntu Desktop Linux 16.04 LTS
339
340 The configuration options given to `cmake` below are targeted towards the functionality needed for Tegra. For a desktop system, you may wish to adjust some options to enable (or disable) certain features. The features enabled below are based on the building of OpenCV 2.4.13.
341
342     $ cmake \
343         -DCMAKE_BUILD_TYPE=Release \
344         -DCMAKE_INSTALL_PREFIX=/usr \
345         -DBUILD_PNG=OFF \
346         -DBUILD_TIFF=OFF \
347         -DBUILD_TBB=OFF \
348         -DBUILD_JPEG=OFF \
349         -DBUILD_JASPER=OFF \
350         -DBUILD_ZLIB=OFF \
351         -DBUILD_EXAMPLES=ON \
352         -DBUILD_JAVA=OFF \
353         -DBUILD_opencv_python2=ON \
354         -DBUILD_opencv_python3=OFF \
355         -DWITH_OPENCL=OFF \
356         -DWITH_OPENMP=OFF \
357         -DWITH_FFMPEG=ON \
358         -DWITH_GSTREAMER=OFF \
359         -DWITH_GSTREAMER_0_10=OFF \
360         -DWITH_CUDA=ON \
361         -DWITH_GTK=ON \
362         -DWITH_VTK=OFF \
363         -DWITH_TBB=ON \
364         -DWITH_1394=OFF \
365         -DWITH_OPENEXR=OFF \
366         -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-8.0 \
367         -DCUDA_ARCH_BIN='3.0 3.5 5.0 6.0 6.2' \
368         -DCUDA_ARCH_PTX="" \
369         -DINSTALL_C_EXAMPLES=ON \
370         -DINSTALL_TESTS=OFF \
371         -DOPENCV_TEST_DATA_PATH=../opencv_extra/testdata \
372         ../opencv
373
374 This configuration is nearly identical to that for V4L and L4T, except that the `CUDA_ARCH_BIN` parameter specifies multiple architectures so as to support a variety of GPU boards. For a desktop, you have the option of omitting this parameter, and CMake will instead run a small test program that probes for the supported architectures. However, the libraries produced might not work on Ubuntu systems with different cards.
375
376 As with previous examples, the configuration given above builds the Python bindings for Python 2 (but not Python 3) as part of the build process.
377
378 Building OpenCV {#tutorial_building_tegra_cuda_building}
379 ===============
380
381 Once `cmake` finishes configuring OpenCV, building is done using the standard `make` utility.
382
383 Building with `make`
384 --------------------
385
386 The only parameter that is needed for the invocation of `make` is the `-j` parameter for specifying how many parallel threads to use. This varies depending on the system and how much memory is available, other running processes, etc. The following table offers suggested values for this parameter:
387
388 |Platform|Suggested value|Notes|
389 |--------|---------------|-----|
390 |DRIVE PX 2|6| |
391 |Jetson TK1|3|If the build fails due to a compiler-related error, try again with a smaller number of threads. Also consider rebooting the system if it has been running for a long time since the last reboot.|
392 |Jetson TX1|4| |
393 |Ubuntu Desktop|7|The actual value will vary with the number of cores you have and the amount of physical memory. Because of the resource requirements of compiling the CUDA code, it is not recommended to go above 7.|
394
395 Based on the value you select, build (assuming you selected 6):
396
397     $ make -j6
398
399 By default, CMake hides the details of the build steps. If you need to see more detail about each compilation unit, etc., you can enable verbose output:
400
401     $ make -j6 VERBOSE=1
402
403 Testing OpenCV {#tutorial_building_tegra_cuda_testing}
404 ==============
405
406 Once the build completes successfully, you have the option of running the extensive set of tests that OpenCV provides. If you did not clone the `opencv_extra` repository and specify the path to `testdata` in the `cmake` invocation, then testing is not recommended.
407
408 Testing under Linux
409 -------------------
410
411 To run the basic tests under Linux, execute:
412
413     $ make test
414
415 This executes `ctest` to carry out the tests, as specified in CTest syntax within the OpenCV repository. The `ctest` harness takes many different parameters (too many to list here, see the manual page for CTest to see the full set), and if you wish to pass any of them, you can do so by specifying them in a `make` command-line parameter called `ARGS`:
416
417     $ make test ARGS="--verbose --parallel 3"
418
419 In this example, there are two (2) arguments passed to `ctest`: `--verbose` and `--parallel 3`. The first argument causes the output from `ctest` to be more detailed, and the second causes `ctest` to run as many as three (3) tests in parallel. As with choosing a thread count for building, base any choice for testing on the available number of processor cores, physical memory, etc. Some of the tests do attempt to allocate significant amounts of memory.
420
421 ### Known Issues with Tests
422
423 At present, not all of the tests in the OpenCV test suite pass. There are tests that fail whether or not CUDA is compiled, and there are tests that are only specific to CUDA that also do not currently pass.
424
425 __Note:__ There are no tests that pass without CUDA but fail only when CUDA is included.
426
427 As the full lists of failing tests vary based on platform, it is impractical to list them here.
428
429 Installing OpenCV {#tutorial_building_tegra_cuda_installing}
430 =================
431
432 Installing OpenCV is very straightforward. For the Linux-based platforms, the command is:
433
434     $ make install
435
436 Depending on the chosen installation location, you may need root privilege to install.
437
438 Building OpenCV 2.4.X {#tutorial_building_tegra_cuda_opencv_24X}
439 =====================
440
441 If you wish to build your own version of the 2.4 version of OpenCV, there are only a few adjustments that must be made. At the time of this writing, the latest version on the 2.4 tree is 2.4.13. These instructions may work for later versions of 2.4, though they have not been tested for any earlier versions.
442
443 __Note:__ The 2.4.X OpenCV source does not have the extra modules and code for Tegra that was upstreamed into the 3.X versions of OpenCV. This part of the guide is only for cases where you want to build a vanilla version of OpenCV 2.4.
444
445 Selecting the 2.4 Source
446 ------------------------
447
448 First you must select the correct source branch or tag. If you want a specific version such as 2.4.13, you want to make a local branch based on the tag, as was done with the 3.1.0 tag above:
449
450     # Within the opencv directory:
451     $ git checkout -b v2.4.13 2.4.13
452
453     # Within the opencv_extra directory:
454     $ git checkout -b v2.4.13 2.4.13
455
456 If you simply want the newest code from the 2.4 line of OpenCV, there is a `2.4` branch already in the repository. You can check that out instead of a specific tag:
457
458     $ git checkout 2.4
459
460 There is no need for the `git cherry-pick` commands used with 3.1.0 when building the 2.4.13 source.
461
462 Configuring
463 -----------
464
465 Configuring is done with CMake as before. The primary difference is that OpenCV 2.4 only provides Python bindings for Python 2, and thus does not distinguish between Python 2 and Python 3 in the CMake parameters. There is only one parameter, `BUILD_opencv_python`. In addition, there is a build-related parameter that controls features in 2.4 that are not in 3.1.0. This parameter is `BUILD_opencv_nonfree`.
466
467 Configuration still takes place in a separate directory that must be a sibling to the `opencv` and `opencv_extra` directories.
468
469 ### Configuring Vibrante V4L
470
471 For DRIVE PX 2:
472
473     $ cmake \
474         -DCMAKE_BUILD_TYPE=Release \
475         -DCMAKE_INSTALL_PREFIX=/usr \
476         -DBUILD_PNG=OFF \
477         -DBUILD_TIFF=OFF \
478         -DBUILD_TBB=OFF \
479         -DBUILD_JPEG=OFF \
480         -DBUILD_JASPER=OFF \
481         -DBUILD_ZLIB=OFF \
482         -DBUILD_EXAMPLES=ON \
483         -DBUILD_JAVA=OFF \
484         -DBUILD_opencv_nonfree=OFF \
485         -DBUILD_opencv_python=ON \
486         -DENABLE_NEON=ON \
487         -DWITH_OPENCL=OFF \
488         -DWITH_OPENMP=OFF \
489         -DWITH_FFMPEG=ON \
490         -DWITH_GSTREAMER=OFF \
491         -DWITH_GSTREAMER_0_10=OFF \
492         -DWITH_CUDA=ON \
493         -DWITH_GTK=ON \
494         -DWITH_VTK=OFF \
495         -DWITH_TBB=ON \
496         -DWITH_1394=OFF \
497         -DWITH_OPENEXR=OFF \
498         -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-8.0 \
499         -DCUDA_ARCH_BIN=6.2 \
500         -DCUDA_ARCH_PTX="" \
501         -DINSTALL_C_EXAMPLES=ON \
502         -DINSTALL_TESTS=ON \
503         -DOPENCV_TEST_DATA_PATH=../opencv_extra/testdata \
504         ../opencv
505
506 ### Configuring Jetson L4T
507
508 For Jetson TK1:
509
510     $ cmake \
511         -DCMAKE_BUILD_TYPE=Release \
512         -DCMAKE_INSTALL_PREFIX=/usr \
513         -DBUILD_PNG=OFF \
514         -DBUILD_TIFF=OFF \
515         -DBUILD_TBB=OFF \
516         -DBUILD_JPEG=OFF \
517         -DBUILD_JASPER=OFF \
518         -DBUILD_ZLIB=OFF \
519         -DBUILD_EXAMPLES=ON \
520         -DBUILD_JAVA=OFF \
521         -DBUILD_opencv_nonfree=OFF \
522         -DBUILD_opencv_python=ON \
523         -DENABLE_NEON=ON \
524         -DWITH_OPENCL=OFF \
525         -DWITH_OPENMP=OFF \
526         -DWITH_FFMPEG=ON \
527         -DWITH_GSTREAMER=OFF \
528         -DWITH_GSTREAMER_0_10=OFF \
529         -DWITH_CUDA=ON \
530         -DWITH_GTK=ON \
531         -DWITH_VTK=OFF \
532         -DWITH_TBB=ON \
533         -DWITH_1394=OFF \
534         -DWITH_OPENEXR=OFF \
535         -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-6.5 \
536         -DCUDA_ARCH_BIN=3.2 \
537         -DCUDA_ARCH_PTX="" \
538         -DINSTALL_C_EXAMPLES=ON \
539         -DINSTALL_TESTS=ON \
540         -DOPENCV_TEST_DATA_PATH=../opencv_extra/testdata \
541         ../opencv
542
543 For Jetson TX1:
544
545     $ cmake \
546         -DCMAKE_BUILD_TYPE=Release \
547         -DCMAKE_INSTALL_PREFIX=/usr \
548         -DBUILD_PNG=OFF \
549         -DBUILD_TIFF=OFF \
550         -DBUILD_TBB=OFF \
551         -DBUILD_JPEG=OFF \
552         -DBUILD_JASPER=OFF \
553         -DBUILD_ZLIB=OFF \
554         -DBUILD_EXAMPLES=ON \
555         -DBUILD_JAVA=OFF \
556         -DBUILD_opencv_nonfree=OFF \
557         -DBUILD_opencv_python=ON \
558         -DENABLE_PRECOMPILED_HEADERS=OFF \
559         -DWITH_OPENCL=OFF \
560         -DWITH_OPENMP=OFF \
561         -DWITH_FFMPEG=ON \
562         -DWITH_GSTREAMER=OFF \
563         -DWITH_GSTREAMER_0_10=OFF \
564         -DWITH_CUDA=ON \
565         -DWITH_GTK=ON \
566         -DWITH_VTK=OFF \
567         -DWITH_TBB=ON \
568         -DWITH_1394=OFF \
569         -DWITH_OPENEXR=OFF \
570         -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-8.0 \
571         -DCUDA_ARCH_BIN=5.3 \
572         -DCUDA_ARCH_PTX="" \
573         -DINSTALL_C_EXAMPLES=ON \
574         -DINSTALL_TESTS=ON \
575         -DOPENCV_TEST_DATA_PATH=../opencv_extra/testdata \
576         ../opencv
577
578 ### Configuring Desktop Ubuntu Linux
579
580 For both 14.04 LTS and 16.04 LTS:
581
582     $ cmake \
583         -DCMAKE_BUILD_TYPE=Release \
584         -DCMAKE_INSTALL_PREFIX=/usr \
585         -DBUILD_PNG=OFF \
586         -DBUILD_TIFF=OFF \
587         -DBUILD_TBB=OFF \
588         -DBUILD_JPEG=OFF \
589         -DBUILD_JASPER=OFF \
590         -DBUILD_ZLIB=OFF \
591         -DBUILD_EXAMPLES=ON \
592         -DBUILD_JAVA=OFF \
593         -DBUILD_opencv_nonfree=OFF \
594         -DBUILD_opencv_python=ON \
595         -DWITH_OPENCL=OFF \
596         -DWITH_OPENMP=OFF \
597         -DWITH_FFMPEG=ON \
598         -DWITH_GSTREAMER=OFF \
599         -DWITH_GSTREAMER_0_10=OFF \
600         -DWITH_CUDA=ON \
601         -DWITH_GTK=ON \
602         -DWITH_VTK=OFF \
603         -DWITH_TBB=ON \
604         -DWITH_1394=OFF \
605         -DWITH_OPENEXR=OFF \
606         -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-8.0 \
607         -DCUDA_ARCH_BIN='3.0 3.5 5.0 6.0 6.2' \
608         -DCUDA_ARCH_PTX="" \
609         -DINSTALL_C_EXAMPLES=ON \
610         -DINSTALL_TESTS=ON \
611         -DOPENCV_TEST_DATA_PATH=../opencv_extra/testdata \
612         ../opencv
613
614 Building, Testing and Installing
615 --------------------------------
616
617 Once configured, the steps of building, testing, and installing are the same as above for the 3.1.0 source.
618
619 CMake Parameter Reference {#tutorial_building_tegra_cuda_parameter_reference}
620 =========================
621
622 The following is a table of all the parameters passed to CMake in the recommended invocations above. Some of these are parameters from CMake itself, while most are specific to OpenCV.
623
624 |Parameter|Our Default Value|What It Does|Notes|
625 |---------|-----------------|------------|-----|
626 |BUILD_EXAMPLES|ON|Governs whether the C/C++ examples are built| |
627 |BUILD_JASPER|OFF|Governs whether the Jasper library (`libjasper`) is built from source in the `3rdparty` directory| |
628 |BUILD_JPEG|OFF|As above, for `libjpeg`| |
629 |BUILD_PNG|OFF|As above, for `libpng`| |
630 |BUILD_TBB|OFF|As above, for `tbb`| |
631 |BUILD_TIFF|OFF|As above, for `libtiff`| |
632 |BUILD_ZLIB|OFF|As above, for `zlib`| |
633 |BUILD_JAVA|OFF|Controls the building of the Java bindings for OpenCV|Building the Java bindings requires OpenCV libraries be built for static linking only|
634 |BUILD_opencv_nonfree|OFF|Controls the building of non-free (non-open-source) elements|Used only for building 2.4.X|
635 |BUILD_opencv_python|ON|Controls the building of the Python 2 bindings in OpenCV 2.4.X|Used only for building 2.4.X|
636 |BUILD_opencv_python2|ON|Controls the building of the Python 2 bindings in OpenCV 3.1.0|Not used in 2.4.X|
637 |BUILD_opencv_python3|OFF|Controls the building of the Python 3 bindings in OpenCV 3.1.0|Not used in 2.4.X|
638 |CMAKE_BUILD_TYPE|Release|Selects the type of build (release vs. development)|Is generally either `Release` or `Debug`|
639 |CMAKE_INSTALL_PREFIX|/usr|Sets the root for installation of the libraries and header files| |
640 |CUDA_ARCH_BIN|varies|Sets the CUDA architecture(s) for which code is compiled|Usually only passed for platforms with known specific cards. OpenCV includes a small program that determines the architectures of the system's installed card if you do not pass this parameter. Here, for Ubuntu desktop, the value is a list to maximize card support.|
641 |CUDA_ARCH_PTX|""|Builds PTX intermediate code for the specified virtual PTX architectures| |
642 |CUDA_TOOLKIT_ROOT_DIR|/usr/local/cuda-8.0 (for Linux)|Specifies the location of the CUDA include files and libraries| |
643 |ENABLE_NEON|ON|Enables the use of NEON SIMD extensions for ARM chips|Only passed for builds on ARM platforms|
644 |ENABLE_PRECOMPILED_HEADERS|OFF|Enables/disables support for pre-compiled headers|Only specified on some of the ARM platforms|
645 |INSTALL_C_EXAMPLES|ON|Enables the installation of the C example files as part of `make install`| |
646 |INSTALL_TESTS|ON|Enables the installation of the tests as part of `make install`| |
647 |OPENCV_TEST_DATA_PATH|../opencv_extra/testdata|Path to the `testdata` directory in the `opencv_extra` repository| |
648 |WITH_1394|OFF|Specifies whether to include IEEE-1394 support| |
649 |WITH_CUDA|ON|Specifies whether to include CUDA support| |
650 |WITH_FFMPEG|ON|Specifies whether to include FFMPEG support| |
651 |WITH_GSTREAMER|OFF|Specifies whether to include GStreamer 1.0 support| |
652 |WITH_GSTREAMER_0_10|OFF|Specifies whether to include GStreamer 0.10 support| |
653 |WITH_GTK|ON|Specifies whether to include GTK 2.0 support|Only given on Linux platforms, not Microsoft Windows|
654 |WITH_OPENCL|OFF|Specifies whether to include OpenCL runtime support| |
655 |WITH_OPENEXR|OFF|Specifies whether to include ILM support via OpenEXR| |
656 |WITH_OPENMP|OFF|Specifies whether to include OpenMP runtime support| |
657 |WITH_TBB|ON|Specifies whether to include Intel TBB support| |
658 |WITH_VTK|OFF|Specifies whether to include VTK support| |
659
660 Copyright &copy; 2016, NVIDIA CORPORATION. All rights reserved.