Previous tutorial: Cross-compilation of ARM-based Linux system
Next tutorial: Getting started with images
Original author | Randy J. Ray |
---|---|
Compatibility | OpenCV >= 3.1.0 |
Warning
This tutorial is outdated.
OpenCV for Tegra using CUDA
This document is a basic guide to building a CUDA-enabled OpenCV library in a Tegra environment. It covers the basic elements of building a 3.1.0 repository from source code for three (3) different types of platforms:
- NVIDIA Drive? PX 2 (V4L)
- NVIDIA? Tegra? Linux Driver Package (L4T)
- Desktop Linux (Ubuntu 14.04 LTS and 16.04 LTS)
This document does not cover all options available when building OpenCV. Specifically, it covers the basic options used when building for each platform, but excludes any options that are not required (or are identical to the defaults). Additionally, installation of the CUDA toolkit is not included here.
This document focuses on building the 3.1.0 version of OpenCV, but the guidelines here also apply to building from the master branch of a git repository. Some options for CMake are different when building the OpenCV 2.4.13 version, which are summarized below in the Building OpenCV 2.4.X section.
Most configuration commands are based on a system with CUDA 8.0 installed. In the case of Jetson TK1, the older CUDA is used since the platform does not support 8.0. These instructions may also work with older versions of CUDA, but were only tested with 8.0.
Instructions on local compilation and cross-compilation
The OpenCV compilation system supports native compilation for all supported platforms, as well as cross-compilation for platforms such as ARM. The native compilation process is simpler, while cross-compiling is usually faster.
Currently, this document only focuses on local compilation.
Get source code
There are two ways to obtain the OpenCV source code:
- Download directly from the OpenCV download page
- Clone the git repository on GitHub
This guide focuses on using git repositories. This is because version 3.1.0 of OpenCV will not build with CUDA 8.0 without applying some small upstream changes in the git repository.
OpenCV
Starting from the opencv repository:
# Clone the opencv repository locally: $ git clone https://github.com/opencv/opencv.git
To build the 3.1.0 version (instead of building the latest source code), you must checkout the branch based on the 3.1.0 tag:
cd opencv $ git checkout -b v3.1.0 3.1.0
Note: This operation creates a new local branch in the cloned repository.
Some upstream changes must be applied via the git cherry-pick
command. The first of these changes is a fix specifically for building with the 8.0 version of CUDA, which is not part of the 3.1.0 version:
# While still in the opencv directory: $ git cherry-pick 10896
You will see the following command output:
[v3.1.0 d6d69a7] GraphCut is deprecated in CUDA 7.5 and removed in 8.0 Author: Vladislav Vinograd Vladislav Vinogradov <[email protected]> 1 file changed, 2 inserted (+), 1 deleted (-)
Secondly, a problematic CMake macro call on some systems has also been fixed:
$ git cherry pick cdb9c
You should see output similar to the following
[v3.1.0-28613 e5ac2e4] gpu samples: fix REMOVE_ITEM error Author: Alexander Alekhin Alexander Alekhin <[email protected]> 1 file changed, 1 inserted (+), 1 deleted (-)
The last upstream issue that needs to be fixed is the pkg-config configuration file bundled with the developer package (libopencv-dev):
$ git cherry-pick 24dbb
You should see output similar to the following
[v3.1.0 3a6d7ab] pkg-config: modules list contains only OpenCV modules (fixes #5852) Author: Alexander Alekhin Alexander Alekhin <[email protected]> 1 file changed, 7 inserted (+), 4 deleted (-)
At this point, the opencv
software source is available for building.
OpenCV Extra
The opencv_extra
repository contains extra data for the OpenCV library, including data files used for testing and demonstrations. It must be cloned separately:
# In the same base directory where OpenCV was cloned: $ git clone https://github.com/opencv/opencv_extra.git
As with the OpenCV source code, the source tree must be set to version 3.1.0 using the same method described above. When building from a specific tag, both software sources must be checked out under that tag.
$ cd opencv_extra $ git checkout -b v3.1.0 3.1.0
You can choose not to obtain this repository if you do not plan to run tests or install test data and examples and sample programs. If the repository is not referenced when calling CMake, it will not be used.
Note: If you plan to run tests, some tests expect the data to be present or will fail.
Preparation and Prerequisites
To build OpenCV, you need a directory to create configurations and build libraries. You will also need some third-party libraries that OpenCV depends on.
Ubuntu Linux Prerequisites
These are the basic requirements for building OpenCV for Tegra on Linux:
- CMake 2.8.10 or newer
- CUDA Toolkit 8.0 (7.0 or 7.5 also works)
- Build tools (make, gcc, g++)
- Python 2.6 or higher
The tools are the same regardless of the platform (DRIVE PX 2, desktop, etc.).
Compiling on Linux requires some development packages:
- libglew-dev
- libtiff5-dev
- zlib1g-dev
- libjpeg-dev
- libpng12-dev
- libjasper-dev
- libavcodec-dev
- libavformat-dev
- libavutil-dev
- libpostproc-dev
- libswscale-dev
- libeigen3-dev
- libtbb-dev
- libgtk2.0-dev
- pkg-config
Some of the above packages are located in the universe
software repositories of Ubuntu Linux systems. If the repository has not been enabled, you will need to do the following before attempting to install all of the above packages:
$ sudo apt-add-repository universe $ sudo apt-get update
Paste the following commands into your shell to install the required packages:
$ sudo apt-get install (install libglew-dev libtiff5-dev zlib1g-dev libjpeg-dev libpng12-dev libjasper-dev libavcodec-dev libavformat-dev libavutil-dev libpostproc-dev libswscale-dev libeigen3-dev libtbb-dev libgtk2.0-dev pkg-config
(Newlines and continuation characters added for readability).
If you wish to build Python bindings, you also need the corresponding packages for Python 2 and Python 3:
- python-dev/python3-dev
- python-numpy/python3-numpy
- python-py/python3-py
- python-pytest/python3-pytest
The command to do this
$ sudo apt-get install python-dev python-numpy python-py python-pytest # You can also choose $ sudo apt-get install python3-dev python3-numpy python3-py python3-pytest
Once all necessary packages are installed, it’s time to configure the build.
Preparing the build area
Software projects built using the CMake system configuration expect the actual build to occur outside of the source tree. In order to configure and build OpenCV, create a directory called “build” in the same base directory where you cloned the git repository:
$ mkdir build cd build
It is now time to configure and build OpenCV.
Configuring OpenCV for building
The CMake configuration options provided below for different platforms target the functionality required by Tegra. They are based on the original configuration options used when building OpenCV 2.4.13.
OpenCV builds are configured via CMake. If run without arguments, it detects the system information it needs to know. However, it may have difficulty finding the CUDA files if they are not in a standard location, and it may try to compile with some options that you may not want to include, so it is recommended to use the following CMake call.
In each of the cmake
commands listed in the following sections, newlines and indents have been added to improve readability. In the examples based on Linux platforms, continuation characters have also been added to allow copying and pasting the examples directly into the shell. When entering these commands manually, enter the command and options as one line. For a detailed explanation of the parameters passed to cmake
, see the “CMake Parameter Reference” section.
For Linux-based platforms, the displayed value of the CMAKE_INSTALL_PREFIX
parameter is /usr. You can set this to any value you want based on your system layout.
In each cmake call below, the last parameter OPENCV_TEST_DATA_PATH
tells the build system where to find the test data provided by the opencv_extra
repository. If you include this path, make install
will install the test data along with the libraries and sample code, and make test will automatically provide this path to tests that need to load data from it. If the opencv_extra
repository is not cloned, do not include this parameter.
Vibrante V4L Configuration
Supported platforms: Drive PX 2
$ cmake \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=/usr \ -DBUILD_PNG=OFF \ -DBUILD_TIFF=OFF \ -DBUILD_TBB=OFF \ -DBUILD_JPEG=OFF \ -DBUILD_JASPER=OFF \ -DBUILD_ZLIB=OFF \ -DBUILD_EXAMPLES=ON \ -DBUILD_JAVA=OFF \ -DBUILD_opencv_python2=ON \ -DBUILD_opencv_python3=OFF \ -DENABLE_NEON=ON \ -DWITH_OPENCL=OFF \ -DWITH_OPENMP=OFF \ -DWITH_FFMPEG=ON \ -DWITH_GSTREAMER=OFF \ -DWITH_GSTREAMER_0_10=OFF \ -DWITH_CUDA=ON \ -DWITH_GTK=ON \ -DWITH_VTK=OFF \ -DWITH_TBB=ON \ -DWITH_1394=OFF \ -DWITH_OPENEXR=OFF \ -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-8.0 \ -DCUDA_ARCH_BIN=6.2 \ -DCUDA_ARCH_PTX="" \ -DINSTALL_C_EXAMPLES=ON \ -DINSTALL_TESTS=OFF \ -DOPENCV_TEST_DATA_PATH=../opencv_extra/testdata \ ../opencv
The configuration provided above will build Python bindings for Python 2 (but not Python 3) during the build process. If you want bindings for Python 3 (or don’t want bindings for Python 2), change the values of BUILD_opencv_python2
and/or BUILD_opencv_python3
as appropriate. To enable binding, set its value to ON
; to disable binding, set its value to OFF
:
-DBUILD_opencv_python2=OFF
Jetson L4T Configuration
Supported platforms:
- Jetson TK1
- Jetson TX1
Jetson TK1 and Jetson TX1 systems have slightly different configurations.
Jetson TK1
$ cmake \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=/usr \ -DCMAKE_CXX_FLAGS=-Wa,-mimplicit-it=thumb \ -DBUILD_PNG=OFF \ -DBUILD_TIFF=OFF \ -DBUILD_TBB=OFF \ -DBUILD_JPEG=OFF \ -DBUILD_JASPER=OFF \ -DBUILD_ZLIB=OFF \ -DBUILD_EXAMPLES=ON \ -DBUILD_JAVA=OFF \ -DBUILD_opencv_python2=ON \ -DBUILD_opencv_python3=OFF \ -DENABLE_NEON=ON \ -DWITH_OPENCL=OFF \ -DWITH_OPENMP=OFF \ -DWITH_FFMPEG=ON \ -DWITH_GSTREAMER=OFF \ -DWITH_GSTREAMER_0_10=OFF \ -DWITH_CUDA=ON \ -DWITH_GTK=ON \ -DWITH_VTK=OFF \ -DWITH_TBB=ON \ -DWITH_1394=OFF \ -DWITH_OPENEXR=OFF \ -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-6.5 \ -DCUDA_ARCH_BIN=3.2 \ -DCUDA_ARCH_PTX="" \ -DINSTALL_C_EXAMPLES=ON \ -DINSTALL_TESTS=OFF \ -DOPENCV_TEST_DATA_PATH=../opencv_extra/testdata \ ../opencv
NOTE: This uses CUDA 6.5, not 8.0.
Jetson TX1
$ cmake \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=/usr \ -DBUILD_PNG=OFF \ -DBUILD_TIFF=OFF \ -DBUILD_TBB=OFF \ -DBUILD_JPEG=OFF \ -DBUILD_JASPER=OFF \ -DBUILD_ZLIB=OFF \ -DBUILD_EXAMPLES=ON \ -DBUILD_JAVA=OFF \ -DBUILD_opencv_python2=ON \ -DBUILD_opencv_python3=OFF \ -DENABLE_PRECOMPILED_HEADERS=OFF \ -DWITH_OPENCL=OFF \ -DWITH_OPENMP=OFF \ -DWITH_FFMPEG=ON \ -DWITH_GSTREAMER=OFF \ -DWITH_GSTREAMER_0_10=OFF \ -DWITH_CUDA=ON \ -DWITH_GTK=ON \ -DWITH_VTK=OFF \ -DWITH_TBB=ON \ -DWITH_1394=OFF \ -DWITH_OPENEXR=OFF \ -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-8.0 \ -DCUDA_ARCH_BIN=5.3 \ -DCUDA_ARCH_PTX="" \ -DINSTALL_C_EXAMPLES=ON \ -DINSTALL_TESTS=OFF \ -DOPENCV_TEST_DATA_PATH=../opencv_extra/testdata \ ../opencv
Note: This configuration does not set the ENABLE_NEON
parameter.
Ubuntu Desktop Linux Configuration
Supported platforms:
- Ubuntu Desktop Linux 14.04 LTS
- Ubuntu Desktop Linux 16.04 LTS
The configuration options provided below for cmake target the functionality required by Tegra. For desktop systems, you may want to adjust certain options to enable (or disable) certain features. The following enabled features are based on the OpenCV 2.4.13 build.
$ cmake \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=/usr \ -DBUILD_PNG=OFF \ -DBUILD_TIFF=OFF \ -DBUILD_TBB=OFF \ -DBUILD_JPEG=OFF \ -DBUILD_JASPER=OFF \ -DBUILD_ZLIB=OFF \ -DBUILD_EXAMPLES=ON \ -DBUILD_JAVA=OFF \ -DBUILD_opencv_python2=ON \ -DBUILD_opencv_python3=OFF \ -DWITH_OPENCL=OFF \ -DWITH_OPENMP=OFF \ -DWITH_FFMPEG=ON \ -DWITH_GSTREAMER=OFF \ -DWITH_GSTREAMER_0_10=OFF \ -DWITH_CUDA=ON \ -DWITH_GTK=ON \ -DWITH_VTK=OFF \ -DWITH_TBB=ON \ -DWITH_1394=OFF \ -DWITH_OPENEXR=OFF \ -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-8.0 \ -DCUDA_ARCH_BIN='3.0 3.5 5.0 6.0 6.2' \ -DCUDA_ARCH_PTX="" \ -DINSTALL_C_EXAMPLES=ON \ -DINSTALL_TESTS=OFF \ -DOPENCV_TEST_DATA_PATH=../opencv_extra/testdata \ ../opencv
This configuration is almost identical to that of V4L and L4T, except that the CUDA_ARCH_BIN parameter specifies multiple architectures to support various GPU boards. For desktops, you can choose to omit this parameter and CMake will run a small test program to detect supported architectures. However, the resulting library may not run on Ubuntu systems using different graphics cards.
As with the previous example, the configuration given above will build Python bindings for Python 2 (but not Python 3) during the build process.
Building OpenCV
cmake
After configuring OpenCV, you can use the standard make tool to build.
Build using make
The only argument required when calling make
is the -j
argument that specifies how many parallel threads to use. This depends on the system and how much memory is available, other running processes, etc. The following table provides recommended values for this parameter:
Platform | Recommended value | Remarks |
---|---|---|
DRIVE PX 2 | 6 | |
Jetson TK1 | 3 | If the build fails due to a compiler-related error, try again with a smaller number of threads. You may also consider restarting the system if it has been running for a long time since the last restart. |
Jetson TX1 | 4 | |
Ubuntu Desktop | 7 | Actual values will vary depending on the number of cores and the amount of physical memory. Due to the resource-intensive compilation of CUDA code, it is recommended not to exceed 7. |
Compile based on the value you choose (assuming you choose 6):
$ make -j6
By default, CMake hides the details of compilation steps. If you need to see more details about each compilation unit, etc., you can enable verbose output:
$ make -j6 VERBOSE=1
Testing OpenCV
After successful compilation, you can choose to run the extensive test set provided by OpenCV. Testing is not recommended if you have not cloned the opencv_extra repository and have not specified the path to testdata
in the cmake
call.
Testing under Linux
To run basic tests under Linux, execute
$ make test
This will execute ctest
to perform the test as specified by the CTest
syntax in the OpenCV software library. The ctest tool requires a number of different parameters (too many to list here, see the CTest man page to see them all), and if you wish to pass any of these parameters, you can do so in the make command line argument named ARGS Specify these parameters:
$ make test ARGS="--verbose --parallel 3"
In this example, there are two (2) arguments passed to ctest: –verbose and –parallel 3. The first parameter will cause ctest’s output to be more verbose, and the second parameter will cause ctest to run up to three (3) tests in parallel. As with choosing the number of build threads, any test selection should be based on the number of available processor cores, physical memory, etc. Some tests attempt to allocate large amounts of memory.
Known issues for testing
Currently, not all tests in the OpenCV test suite pass. Some tests will fail whether or not CUDA is compiled, and some CUDA-only tests will currently fail.
Note: No test passes without CUDA compiled, but only fails when CUDA is included.
Because the complete list of failing tests varies from platform to platform, it is impractical to list them here.
Install OpenCV
Installing OpenCV is very simple. For Linux based platforms, the command is as follows
$ make install
Depending on the installation location chosen, you may need root access to install.
Building OpenCV 2.4.X
If you want to build your own version of OpenCV 2.4, just make a few tweaks. At the time of writing, the latest version on the 2.4 tree is 2.4.13. These instructions may work for subsequent versions of 2.4, but have not been tested with any earlier versions.
NOTE: The 2.4.X OpenCV source does not contain Tegra’s additional modules and code that have been incorporated into the 3.X version of OpenCV upstream. This part of the guide only applies if you want to build a vanilla version of OpenCV 2.4.
Select 2.4 source code
First, you must select the correct source code branch or tag. If you want a specific version, say 2.4.13, you need to create a local branch based on the tag, like the 3.1.0 tag above:
# In the opencv directory: $ git checkout -b v2.4.13 2.4.13
# In the opencv_extra directory: $ git checkout -b v2.4.13 2.4.13
If you just want the latest code for the OpenCV 2.4 version, there is already a 2.4 branch in the repository. You can check that branch instead of a specific tag:
$ git checkout 2.4
When building 2.4.13 source code, there is no need to use the git cherry-pick
command from 3.1.0.
Configuration
As before, configuration is done via CMake. The main difference is that OpenCV 2.4 only provides Python bindings for Python 2, so there is no distinction between Python 2 and Python 3 in the CMake arguments. There is only one parameter, BUILD_opencv_python
. Additionally, there is a compile-related parameter that controls features in 2.4 that are not available in 3.1.0. This parameter is BUILD_opencv_nonfree
.
Configuration is still done in a separate directory, which must be a sibling of the opencv
and opencv_extra
directories.
Configuring Vibrante V4L
For DRIVE PX 2:
$ cmake \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=/usr \ -DBUILD_PNG=OFF \ -DBUILD_TIFF=OFF \ -DBUILD_TBB=OFF \ -DBUILD_JPEG=OFF \ -DBUILD_JASPER=OFF \ -DBUILD_ZLIB=OFF \ -DBUILD_EXAMPLES=ON \ -DBUILD_JAVA=OFF \ -DBUILD_opencv_nonfree=OFF \ -DBUILD_opencv_python=ON \ -DENABLE_NEON=ON \ -DWITH_OPENCL=OFF \ -DWITH_OPENMP=OFF \ -DWITH_FFMPEG=ON \ -DWITH_GSTREAMER=OFF \ -DWITH_GSTREAMER_0_10=OFF \ -DWITH_CUDA=ON \ -DWITH_GTK=ON \ -DWITH_VTK=OFF \ -DWITH_TBB=ON \ -DWITH_1394=OFF \ -DWITH_OPENEXR=OFF \ -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-8.0 \ -DCUDA_ARCH_BIN=6.2 \ -DCUDA_ARCH_PTX="" \ -DINSTALL_C_EXAMPLES=ON \ -DINSTALL_TESTS=ON \ -DOPENCV_TEST_DATA_PATH=../opencv_extra/testdata \ ../opencv
Configuring Jetson L4T
For Jetson TK1:
$ cmake \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=/usr \ -DBUILD_PNG=OFF \ -DBUILD_TIFF=OFF \ -DBUILD_TBB=OFF \ -DBUILD_JPEG=OFF \ -DBUILD_JASPER=OFF \ -DBUILD_ZLIB=OFF \ -DBUILD_EXAMPLES=ON \ -DBUILD_JAVA=OFF \ -DBUILD_opencv_nonfree=OFF \ -DBUILD_opencv_python=ON \ -DENABLE_NEON=ON \ -DWITH_OPENCL=OFF \ -DWITH_OPENMP=OFF \ -DWITH_FFMPEG=ON \ -DWITH_GSTREAMER=OFF \ -DWITH_GSTREAMER_0_10=OFF \ -DWITH_CUDA=ON \ -DWITH_GTK=ON \ -DWITH_VTK=OFF \ -DWITH_TBB=ON \ -DWITH_1394=OFF \ -DWITH_OPENEXR=OFF \ -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-6.5 \ -DCUDA_ARCH_BIN=3.2 \ -DCUDA_ARCH_PTX="" \ -DINSTALL_C_EXAMPLES=ON \ -DINSTALL_TESTS=ON \ -DOPENCV_TEST_DATA_PATH=../opencv_extra/testdata \ ../opencv
For Jetson TX1
$ cmake \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=/usr \ -DBUILD_PNG=OFF \ -DBUILD_TIFF=OFF \ -DBUILD_TBB=OFF \ -DBUILD_JPEG=OFF \ -DBUILD_JASPER=OFF \ -DBUILD_ZLIB=OFF \ -DBUILD_EXAMPLES=ON \ -DBUILD_JAVA=OFF \ -DBUILD_opencv_nonfree=OFF \ -DBUILD_opencv_python=ON \ -DENABLE_PRECOMPILED_HEADERS=OFF \ -DWITH_OPENCL=OFF \ -DWITH_OPENMP=OFF \ -DWITH_FFMPEG=ON \ -DWITH_GSTREAMER=OFF \ -DWITH_GSTREAMER_0_10=OFF \ -DWITH_CUDA=ON \ -DWITH_GTK=ON \ -DWITH_VTK=OFF \ -DWITH_TBB=ON \ -DWITH_1394=OFF \ -DWITH_OPENEXR=OFF \ -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-8.0 \ -DCUDA_ARCH_BIN=5.3 \ -DCUDA_ARCH_PTX="" \ -DINSTALL_C_EXAMPLES=ON \ -DINSTALL_TESTS=ON \ -DOPENCV_TEST_DATA_PATH=../opencv_extra/testdata \ ../opencv
Configuring Desktop Ubuntu Linux
Applies to 14.04 LTS and 16.04 LTS:
$ cmake \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=/usr \ -DBUILD_PNG=OFF \ -DBUILD_TIFF=OFF \ -DBUILD_TBB=OFF \ -DBUILD_JPEG=OFF \ -DBUILD_JASPER=OFF \ -DBUILD_ZLIB=OFF \ -DBUILD_EXAMPLES=ON \ -DBUILD_JAVA=OFF \ -DBUILD_opencv_nonfree=OFF \ -DBUILD_opencv_python=ON \ -DWITH_OPENCL=OFF \ -DWITH_OPENMP=OFF \ -DWITH_FFMPEG=ON \ -DWITH_GSTREAMER=OFF \ -DWITH_GSTREAMER_0_10=OFF \ -DWITH_CUDA=ON \ -DWITH_GTK=ON \ -DWITH_VTK=OFF \ -DWITH_TBB=ON \ -DWITH_1394=OFF \ -DWITH_OPENEXR=OFF \ -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-8.0 \ -DCUDA_ARCH_BIN='3.0 3.5 5.0 6.0 6.2' \ -DCUDA_ARCH_PTX="" \ -DINSTALL_C_EXAMPLES=ON \ -DINSTALL_TESTS=ON \ -DOPENCV_TEST_DATA_PATH=../opencv_extra/testdata \ ../opencv
Build, test and install
After the configuration is completed, the steps for building, testing and installation are the same as the 3.1.0 source code above.
CMake Parameter Reference
The following table lists all parameters passed to CMake in the recommended call above. Some of these are parameters of CMake itself, while most are OpenCV-specific parameters.
Parameters | Our default value | What it does | Remarks | ||
---|---|---|---|---|---|
BUILD_EXAMPLES | ON | Control whether to compile C/C++ examples | |||
BUILD_JASPER | OFF | Control whether the Jasper library (libjasper) is built from source code in a third-party directory | |||
BUILD_JPEG | OFF | As above, for libjpeg | |||
BUILD_PNG | OFF | As above, applicable to libpng | |||
BUILD_TBB | OFF | As above, applicable to tbb | |||
BUILD_TIFF | OFF | As above, applicable to libtiff | |||
BUILD_ZLIB | OFF | As above, applicable to zlib | |||
BUILD_JAVA | OFF | Control the construction of OpenCV Java bindings | Building Java bindings requires that only OpenCV libraries be built for static linking | ||
BUILD_opencv_nonfree | OFF | Control non-free (non-free) Open source) element building | Only used to build version 2.4.X | ||
BUILD_opencv_python | ON | Control the building of Python 2 bindings in OpenCV 2.4.X | Only used to build 2.4. /td> | Controls the construction of Python 2 bindings in OpenCV 3.1.0 | Not used in 2.4.X. |
BUILD_opencv_python3 | OFF | Control the building of Python 3 bindings in OpenCV 3.1.0 | Not used in 2.4. td> | Usually for release or debug versions | |
CMAKE_INSTALL_PREFIX | /usr | Set the installation library and header files Root directory | |||
CUDA_ARCH_BIN | varies | Set the CUDA architecture for compiled code | Usually only available on platforms where a specific graphics card is known. If this parameter is not passed, OpenCV includes a small program to determine the architecture of the board installed in the system. For Ubuntu desktop, the value here is a list to maximize support for the graphics card. | ||
CUDA_ARCH_PTX | “” | Build PTX intermediate code for the specified virtual PTX architecture | |||
CUDA_TOOLKIT_ROOT_DIR /usr/local/cuda-8.0 (for Linux) Specifies the location of CUDA include files and libraries | |||||
ENABLE_NEON | ON | Enable NEON SIMD extension for ARM chips | Enable/disable support for precompiled headers | ||
ENABLE_PRECOMPILED_HEADERS | OFF | only when building on ARM platforms td> | Only specified on some ARM platforms | ||
INSTALL_C_EXAMPLES | ON | Enabled as part of make install Install C sample files | |||
INSTALL_TESTS | ON | Enable test installation as part of make install | |||
OPENCV_TEST_DATA_PATH | …/opencv_extra/testdata | To the testdata directory in the opencv_extra resource library Path | |||
WITH_1394 | OFF | Specifies whether to include IEEE-1394 support | |||
WITH_CUDA | ON | Specifies whether to include CUDA support | |||
WITH_FFMPEG | ON | Specifies whether to include FFMPEG support | |||
WITH_GSTREAMER | OFF | Specify whether to include GStreamer 1.0 support | |||
WITH_GSTREAMER_0_10 | OFF | Specify whether to include GStreamer 0.10 support | |||
WITH_GTK | ON | Specify whether to include GTK 2.0 support | Applies to Linux platform only, not to Microsoft Windows. | ||
WITH_OPENCL | OFF | Specifies whether to include OpenCL runtime support | |||
WITH_OPENEXR | OFF | Specify whether to join ILM support through OpenEXR | |||
WITH_OPENMP | OFF | Specifies whether to include OpenMP runtime support | |||
WITH_TBB | ON | Specify whether to include Intel TBB support | |||
WITH_VTK | OFF | Specify whether to include VTK support |