centos下安装OpenCV及python依赖


1.安装依赖

yum install gcc(建议gcc版本>=4.8.0)

yun install cmake(建议cmake版本>=3.0.0)

yum install gtk*

yum install pkgconfig

yum install python-dev*

yum install numpy

pip install numpy

2.下载opencv

git clone https://github.com/Itseez/opencv.git

git checkout 2.4

cd opencv

3.编译安装

mkdir build

cd build

cmake D CMAKE_BUILD_TYPE=RELEASE D CMAKE_INSTALL_PREFIX=/usr/local D BUILD_EXAMPLES=ON D BUILD_NEW_PYTHON_SUPPORT=ON D INSTALL_PYTHON_EXAMPLES=ON D PYTHON_EXECUTABLE=/usr/local/bin/python2.7 D PYTHON_INCLUDE_DIR=/usr/local/python-2.7.9/include/python2.7 D PYTHON_LIBRARY=/usr/local/python-2.7.9/lib/libpython2.7.so.1.0 D PYTHON_NUMPY_INCLUDE_DIR=/usr/local/python-2.7.9/lib/python2.7/site-packages/numpy/core/include D PYTHON_PACKAGES_PATH=/usr/local/python-2.7.9/lib/python2.7/site-packages ..

make

make install

说明:cmake中PYTHON_EXECUTABLE为python所在文件路径,PYTHON_NUMPY_INCLUDE_DIR为python拓展包numpy的所在路径,PYTHON_PACKAGES_PATH为python包路径,编译输出需确保python的Interpreter和Libraries版本一致,若不一致参照文档http://stackoverflow.com/questions/26597527/how-to-install-libpython2-7-so安装。若make失败参考《CentOS6.5上配置Python2.7+OpenCV2.4.7》。

4.python调用测试

python

import cv2

print cv2.version

输出:2.4.13

参考文档:

官方文档:http://docs.opencv.org/2.4/doc/tutorials/introduction/linux_install/linux_install.html#linux-installation

CentOS6.5上配置Python2.7+OpenCV2.4.7http://blog.csdn.net/u011056389/article/details/37816067

python调用测试时报错“ImportError: /usr/lib64/libstdc++.so.6”:https://github.com/qiwsir/ITArticles/blob/master/Linux/How_to_solve_GLIBCXX_3.4.19.md

python调用测试时报错“libdc1394 error: Failed to initialize libdc1394”:http://stackoverflow.com/questions/12689304/ctypes-error-libdc1394-error-failed-to-initialize-libdc1394


发表评论