当前位置: > CentOS > CentOS教程 >

CentOS 安装OpenCV

时间:2016-05-22 22:03来源:linux.it.net.cn 作者:IT
yum install cmake python-devel numpy gcc gcc-c++

yum install gtk2-devel libdc1394-devel libv4l-devel ffmpeg-devel gstreamer-plugins-base-devel

#可选
yum install libpng-devel libjpeg-turbo-devel jasper-devel openexr-devel libtiff-devel libwebp-devel


wget github.com/Itseez/opencv/archive/2.4.12.zip

unzip 2.4.12.zip
cd opencv-2.4.12
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
make
make install

#在make 时出现如下错误:
#collect2: ld returned 1 exit status
#make[2]: *** [lib/cv2.so] Error 1
#make[1]: *** [modules/python/CMakeFiles/opencv_python.dir/all] Error 2
#make: *** [all] Error 2

#解决办法,重装编译python
./configure --enable-shared

#安装python完成后,启动提示错误:
#error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory
http://linux.it.net.cn


#解决办法
echo "/usr/local/lib">>/etc/ld.so.conf && ldconfig

#再编译完成后测试:
pthon
>>> import cv2
>>> cv2.__version__
'2.4.12'

#如果在 import cv2 时提示错误:
#>>> import cv2
#libdc1394 error: Failed to initialize libdc1394

#解决办法:
ln /dev/null /dev/raw1394


(责任编辑:IT)
------分隔线----------------------------
栏目列表
推荐内容