在 Ununtu 16.04 上安裝 Opencv3.2

Opencv3.2 在Ununtu 16.04 上的編譯安裝

參考自

安裝OpenCV依賴

1
2
3
4
5
6
7
8
9
 sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential cmake pkg-config
sudo apt-get install libjpeg8-dev libtiff5-dev libjasper-dev libpng12-dev
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
sudo apt-get install libxvidcore-dev libx264-dev
sudo apt-get install libgtk-3-dev
sudo apt-get install libatlas-base-dev gfortran
sudo apt-get install python2.7-dev python3.5-dev

下載OpenCV源碼

這裡下載3.2.0

 1
2
3
 $
$ wget -O opencv.zip https://github.com/Itseez/opencv/archive/3.2.0.zip
$ unzip opencv.zip

下載和OpenCV版本對應的opencv_contrib(一些擴展功能和non-free代碼):

 1
2
 $ wget -O opencv_contrib.zip https://github.com/Itseez/opencv_contrib/archive/3.2.0.zip
$ unzip opencv_contrib.zip

編譯安裝

1
2
3
 $
$ mkdir build
$
 1
2
3
4
5
 cmake -D CMAKE_BUILD_TYPE=RELEASE 
-D CMAKE_INSTALL_PREFIX=/usr/
-D INSTALL_PYTHON_EXAMPLES=ON
-D INSTALL_C_EXAMPLES=OFF
-D OPENCV_EXTRA_MODULES_PATH=/root/Downloads/opencv_contrib-3.2.0/modules -D PYTHON_EXECUTABLE=/root/miniconda3/bin/python ..

其中
若出現,需要下載
<…>/opencv-3.2.0/3rdparty/ippicv/downloads/linux-808b791a6eac9ed78d32a7666804320e/, 參考自

編譯:

$ make

安裝:

 1
2
 $ sudo make install
$ sudo ldconfig

Leave a Comment

Your email address will not be published.