Ubuntu14.04+anaconda2下配置opencv3
1.opencv编译安装
# Get all the up-to-date tools you'll need
sudo apt-get update
sudo apt-get install git cmake build-essential
# Get latest greatest OpenCV from GitHub
git clone https://github.com/opencv/opencv.git
# Go build and install that puppy
cd opencv
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..(后面是一个空格加上两个点)
注:此时可能会提示cmake版本太低,则需要升级
make -j 8
sudo make install
2.在python中导入(没做这一步)
cp /usr/local/lib/python2.7/site-packages/cv2.so ~/anaconda2/lib/python2.7/site-packages
3. 最后,测试是否安装成功
root@VB:# python
>>>import cv2
>>>cv2.__version__
'3.4.0'
显示出版本号,则表示opencv安装成功。
在导入的时候可能会出现not found的错误,安装opencv-python即可解决:
pip install opencv-python
Ubuntu14.04 默认CMake版本是2.8.X 当我们需要更高级版本的时候就需要升级CMake。具体步骤如下:
sudo apt-get install build-essential //如果系统已安装build-essential则不需要执行此步骤
wget http://www.cmake.org/files/v3.5/cmake-3.5.1.tar.gz
tar xf cmake-3.5.1.tar.gz
cd cmake-3.5.1
./configure
make
sudo apt-get install checkinstall
sudo checkinstall
网友评论