1. 程式人生 > >Jetson-TX2安裝opencv教程

Jetson-TX2安裝opencv教程

有時候我們需要用到opencv3.0,通過下面apt-get安裝的opencv版本為opencv 2.4.9,命令為

sudo apt-get install python-opencv
如果要安裝oepncv3.3,這裡我提供編譯的思路,我這裡用了linux的sh指令碼檔案,檔名為buildOpenCV.sh,指令碼內容為:
#!/bin/bash
# License: MIT. See license file in root directory
# Copyright(c) JetsonHacks (2017)
cd $HOME
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

Python 2.7

sudo apt-get install -y python-dev python-numpy python-py python-pytest -y

GStreamer support

sudo apt-get install -y libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev

This is for the test data

cd $HOME/opencv mkdir build cd build

Jetson TX2

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=ON -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-8.0 -DCUDA_ARCH_BIN=6.2 -DCUDA_ARCH_PTX="" -DINSTALL_C_EXAMPLES=ON -DINSTALL_TESTS=ON -DOPENCV_TEST_DATA_PATH=…/opencv_extra/testdata …/

Consider using all 6 cores; $ sudo nvpmodel -m 2 or $ sudo nvpmodel -m 0

make -j4 這裡注意

  -DBUILD_opencv_python2=ON \
  -DBUILD_opencv_python3=ON \
我把opencv的python2,python3的介面都開了,然後賦予執行許可權,然後執行:
chmod 777 buildOpenCV.sh
./buildOpenCV.sh
然後就等著它執行完啦,我的平臺是tx2,期間沒有任何報錯,是不是很簡單。感謝幫助過我的人

參考文獻

[1].buildOpenCVTX2.https://github.com/jetsonhacks/buildOpenCVTX2