TX2上配置opencv3.4.0步骤

TX2上配置opencv3.4.0步骤

环境说明:python3.5+cuda9.0+pytorch0.4.1
TX2默认安装的opencv只能python2.7调用。

sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 100
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 150

step1:从网上下载opencv3.4.0版本https://github.com/opencv/opencv/tree/3.4.0;注意要使用opencv_contrib-3.4.0的话还需下载对应版本。

step2:安装依赖包。

sudo apt-get install -y \
    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 \
    cmake \
    pkg-config

step3:cmake

sudo cmake     -DCMAKE_BUILD_TYPE=Release     -DCMAKE_INSTALL_PREFIX=/usr/local     -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=ON  -DBUILD_opencv_python3_Libraries=/usr/lib/aarch64-linux-gnu/libpython3.5m.so   -DENABLE_PRECOMPILED_HEADERS=OFF     -DWITH_OPENCL=OFF     -DWITH_OPENMP=OFF     -DWITH_FFMPEG=ON     -DWITH_GSTREAMER=ON     -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-9.0     -DCUDA_ARCH_BIN=6.2  -DWITH_OPENGL=OFF   ..

step4:编译make -j8

step5:安装 sudo make install

PS:如果需要g++ 编译,一般需要指定路径

g++ `pkg-config opencv --cflags` hsv.cpp  -o hsv `pkg-config opencv --libs` 

猜你喜欢

转载自blog.csdn.net/qq_33206394/article/details/87913510