Tegra环境下安装OpenCV

环境:

  • NVIDIA DRIVE™ PX 2 (V4L)
  • NVIDIA® Tegra® Linux Driver Package (L4T)
  • Desktop Linux (Ubuntu 14.04 LTS and 16.04 LTS)  

下载源码:

git clone https://github.com/opencv/opencv.git
git clone https://github.com/opencv/opencv_extra.git 

安装前提:
CMake 2.8.10 or newer
CUDA toolkit 8.0 (7.0 or 7.5 may also be used)
Build tools (make, gcc, g++)
Python 2.6 or greater

在linux上编译opencv所需要的软件包:

sudo apt-get 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
python-dev / python3-dev
python-numpy / python3-numpy
python-py / python3-py
python-pytest / python3-pytest

$ sudo apt-get install python-dev python-numpy python-py python-pytest
# And, optionally:
$ sudo apt-get install python3-dev python3-numpy python3-py python3-pytest

准备编译目录:

$ mkdir build
$ cd build

编译前的配置:

Drive PX2 平台的配置如下,注意此配置是针对python2的,如果你只想在python3下配置opencv,需要手动修改下面的BUILD_opencv_python2的值为OFF,BUILD_opencv_python3的值为ON。

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_opencv_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

针对Linux Desktop的配置:

  • Ubuntu Desktop Linux 14.04 LTS
  • Ubuntu Desktop Linux 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_opencv_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

使用make进行编译并安装:

make -j6
sudo make install

 

CMake 参数指南

ParameterOur Default ValueWhat It DoesNotes
BUILD_EXAMPLESONGoverns whether the C/C++ examples are built 
BUILD_JASPEROFFGoverns whether the Jasper library (libjasper) is built from source in the 3rdparty directory 
BUILD_JPEGOFFAs above, for libjpeg 
BUILD_PNGOFFAs above, for libpng 
BUILD_TBBOFFAs above, for tbb 
BUILD_TIFFOFFAs above, for libtiff 
BUILD_ZLIBOFFAs above, for zlib 
BUILD_opencv_javaOFFControls the building of the Java bindings for OpenCVBuilding the Java bindings requires OpenCV libraries be built for static linking only
BUILD_opencv_nonfreeOFFControls the building of non-free (non-open-source) elementsUsed only for building 2.4.X
BUILD_opencv_pythonONControls the building of the Python 2 bindings in OpenCV 2.4.XUsed only for building 2.4.X
BUILD_opencv_python2ONControls the building of the Python 2 bindings in OpenCV 3.1.0Not used in 2.4.X
BUILD_opencv_python3OFFControls the building of the Python 3 bindings in OpenCV 3.1.0Not used in 2.4.X
CMAKE_BUILD_TYPEReleaseSelects the type of build (release vs. development)Is generally either Release or Debug
CMAKE_INSTALL_PREFIX/usrSets the root for installation of the libraries and header files 
CUDA_ARCH_BINvariesSets the CUDA architecture(s) for which code is compiledUsually 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.
CUDA_ARCH_PTX""Builds PTX intermediate code for the specified virtual PTX architectures 
CUDA_TOOLKIT_ROOT_DIR/usr/local/cuda-8.0 (for Linux)Specifies the location of the CUDA include files and libraries 
ENABLE_NEONONEnables the use of NEON SIMD extensions for ARM chipsOnly passed for builds on ARM platforms
ENABLE_PRECOMPILED_HEADERSOFFEnables/disables support for pre-compiled headersOnly specified on some of the ARM platforms
INSTALL_C_EXAMPLESONEnables the installation of the C example files as part of make install 
INSTALL_TESTSONEnables the installation of the tests as part of make install 
OPENCV_TEST_DATA_PATH../opencv_extra/testdataPath to the testdatadirectory in the opencv_extrarepository 
WITH_1394OFFSpecifies whether to include IEEE-1394 support 
WITH_CUDAONSpecifies whether to include CUDA support 
WITH_FFMPEGONSpecifies whether to include FFMPEG support 
WITH_GSTREAMEROFFSpecifies whether to include GStreamer 1.0 support 
WITH_GSTREAMER_0_10OFFSpecifies whether to include GStreamer 0.10 support 
WITH_GTKONSpecifies whether to include GTK 2.0 supportOnly given on Linux platforms, not Microsoft Windows
WITH_OPENCLOFFSpecifies whether to include OpenCL runtime support 
WITH_OPENEXROFFSpecifies whether to include ILM support via OpenEXR 
WITH_OPENMPOFFSpecifies whether to include OpenMP runtime support 
WITH_TBBONSpecifies whether to include Intel TBB support

https://docs.opencv.org/3.2.0/d6/d15/tutorial_building_tegra_cuda.html#tutorial_building_tegra_cuda_testing

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值