linux: ubuntu16.04-64bit
python: 3.5.2
opencv: 3.0.0
系统更新:
sudo apt-get update
安装Python3的必要插件:
sudo apt-get install python3-setuptools python3-dev -y
(-y指的是安装默认选择yes)安装pip3(系统同时存在Python2和Python3且只想在Python3下安装pip):
sudo apt-get install python3-pip
安装Python科学计算库numpy(Opencv依赖库)
pip3 install numpy
安装提供编译程序必须软件包的列表信息的库build-essential:
sudo apt-get install build-essential -y
安装必要的开发插件:
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压缩包并进入到解压后文件:
unzip opencv-3.0.0.zip && cd opencv-3.0.0
cmake编译:
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()