ubuntu16.04安装opencv(anaconda)
-
安装opencv所需的依赖
sudo apt-get update sudo apt-get upgrade sudo apt-get install build-essential cmake pkg-config libatlas-base-dev gfortran unzip sudo apt-get install python2.7-dev sudo apt install python-pip pip install numpy
-
编译安装opencv
wget https://github.com/opencv/opencv/archive/3.3.0.zip -O opencv-3.3.0.zip unzip opencv-3.3.0.zip cd opencv-3.3.0 mkdir build && cd build
#这步中的CMAKE_INSTALL_PREFIX是安装路径,默认的可以是/usr/local,也可以像我一样装在个人目录下,PYTHON_EXECUTABLE是用到的python,可以在命令行中输入which python查看用到的是哪个python
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/home/xiongcx/anaconda2/envs/r21d -D PYTHON_EXECUTABLE=/home/xiongcx/anaconda2/envs/r21d/bin/python -D BUILD_EXAMPLES=ON -D BUILD_SHARED_LIBS=ON ..
make -j20
#如果前面CMAKE_INSTALL_PREFIX选择的是/usr/local,这里需改为sudo make install
make install
4、验证安装是否成功
python
>>> import cv2
>>> cv2.__version__
'3.4.0'