CentOS 6 安装 OpenCV2(python支持)



安装以下包:

# yum install gcc cmake git python-devel gtk2-devel numpy tbb-devel libjpeg-turbo-devel libtiff-devel libpng-devel libjasper-devel cmake-gui


下载opencv源码包,解压到主目录,将自动创建子目录opencv-2.4.11。

进入该目录中,编译OpenCV:

$ cd ~/opencv-2.4.11

cmake CMakeLists.txt

$ make -j7        # 同时运行7个任务


在进行到快30%的时候,出现以下错误:

In file included from /home/xxf/opencv-2.4.11/modules/highgui/src/cap_ffmpeg.cpp:45:
/home/xxf/opencv-2.4.11/modules/highgui/src/cap_ffmpeg_impl.hpp: In member function ‘void CvVideoWriter_FFMPEG::close()’:
/home/xxf/opencv-2.4.11/modules/highgui/src/cap_ffmpeg_impl.hpp:1468: error: ‘avformat_free_context’ was not declared in this scope
make[2]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_ffmpeg.cpp.o] Error 1


解决办法:使用yum 卸载 ffmpeg、ffmpeg-devel,然后下载ffmpeg源码,编译安装:

$ cd ffmpeg

$ ./configure --enable-shared

此时可能提示yasm/nasm太旧,安装之:

$ sudo yum install nasm yasm 

再继续:

$ make

$ sudo make install


进入opencv目录

cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_EXAMPLES=ON -DBUILD_NEW_PYTHON_SUPPORT=ON -DINSTALL_PYTHON_EXAMPLES=ON -DPYTHON_EXECUTABLE=/usr/local/python-2.7/bin/python -DPYTHON_INCLUDE_DIR=/usr/local/python-2.7/include -DPYTHON_LIBRARY=/usr/local/python-2.7/lib/libpython2.7.so -DPYTHON_NUMPY_INCLUDE_DIR=/usr/local/python-2.7/lib/python2.7/site-packages/numpy/core/include/ -DPYTHON_PACKAGES_PATH=/usr/local/python-2.7/lib/python2.7/site-packages/ -DCUDA_GENERATION=Auto ..


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值