linux: ubuntu16.04-64bit
python: 3.5.2
opencv: 3.0.0
系統(tǒng)更新:
sudo apt-get update安裝Python3的必要插件:
sudo apt-get install python3-setuptools python3-dev -y
(-y指的是安裝默認(rèn)選擇yes)安裝pip3(系統(tǒng)同時(shí)存在Python2和Python3且只想在Python3下安裝pip):
sudo apt-get install python3-pip安裝Python科學(xué)計(jì)算庫numpy(Opencv依賴庫)
pip3 install numpy安裝提供編譯程序必須軟件包的列表信息的庫build-essential:
sudo apt-get install build-essential -y安裝必要的開發(fā)插件:
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev -y下載OpenCV 3.0.0壓縮包:
wget https://github.com/Itseez/opencv/archive/3.0.0.zip解壓OpenCV 3.0.0壓縮包并進(jìn)入到解壓后文件:
unzip opencv-3.0.0.zip && cd opencv-3.0.0cmake編譯:
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DPYTHON3_EXECUTABLE=/usr/bin/python3 -DPYTHON_INCLUDE_DIR=/usr/include/python3.5 -DPYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.5m.so -DPYTHON3_NUMPY_INCLUDE_DIRS=/usr/local/lib/python3.5/dist-packages/numpy/core/include
make編譯:
make -j && sudo make install測試
python3
import cv2
exit()