開啟Terminal後, 輸入如下:
wget https://github.com/opencv/opencv/archive/3.4.3.zip
便開始下載opencv3.4.3.套件,
接著解壓縮此套件, 輸入:
unzip 3.4.3.zip
安裝opencv前先安裝其他套件(共15個),
ubtuntu version: 16.04
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
ubtuntu version: 18.04
sudo apt-get install \
libglew-dev \
libtiff5-dev \
zlib1g-dev \
libjpeg-dev \
libpng-dev \
libjasper-dev \
libavcodec-dev \
libavformat-dev \
libavutil-dev \
libpostproc-dev \
libswscale-dev \
libeigen3-dev \
libtbb-dev \
libgtk2.0-dev \
pkg-config
補充: libjasper-dev在ubuntu 18.04找不到套件
然而TX2本身未安裝cmake套件,
因此需要在額外安裝cmake,
sudo apt-get update
sudo apt-get install cmake
如果先前已經安裝過舊版本的opencv,
先做刪除動作(如未安裝過可省略),
sudo apt-get purge libopencv*
指定到已解壓縮的opencv目錄:
cd opencv-3.4.3
新建build資料夾至opencv目錄內,
mkdir build
指定到build目錄
cd build
接著使用cmake建置opencv相關套件
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=OFF \
-DBUILD_opencv_python3=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=OFF \
-DWITH_1394=OFF \
-DWITH_OPENEXR=OFF \
-DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda \
-DCUDA_ARCH_BIN=6.2 \
-DCUDA_ARCH_PTX="" \
-DINSTALL_C_EXAMPLES=OFF \
-DINSTALL_TESTS=OFF \
..
接著設定TX2 CUP核心模式來建置opecv
利用4核模式輸入:
sudo make -j4
利用6核模式輸入:
sudo make -j6
開始安裝opencv
sudo make install
驗證安裝結果:
python3
import cv2
如果輸入完沒出現錯誤訊息表示成功
留言列表