1. 系统: CentOS 6.7 ,64位
2. GCC: gcc version 4.8.5 (GCC) 及以上均可
3. cmake: cmake version 2.8.12.2 及以上均可
4. Python: Python 2.6.6 及以上均可
请继续进行以下安装:
# yum install python-devel
# yum install libjpeg libjpeg-devel zlib zlib-devel freetype freetype-devel lcms lcms-devel
# yum install python-imaging
5. Numpy :numpy-1.9.0 ,参考文献[1]
# wget http://jaist.dl.sourceforge.net/project/numpy/NumPy/1.9.0/numpy-1.9.0.zip
# unzip numpy-1.9.0.zip
# cd numpy-1.9.0
# python setup.py install
# reboot
6. 安装依赖库:
# yum install gtk+-devel gimp-devel gimp-devel-tools gimp-help-browser zlib-devel libtiff-devel libjpeg-devel libpng-devel gstreamer-devel libavc1394-devel libraw1394-devel libdc1394-devel jasper-devel jasper-utils swig python libtool nasm
# yum install gtk*
7. 安装yasm
# wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
# tar zxvf yasm-1.3.0.tar.gz
# cd yasm-1.3.0
# ./configure
# make && make install
8. 安装ffmpeg,参考文献[3],建议不要指定--prefix,采用默认安装路径即可
# 从ffmpeg官网:https://www.ffmpeg.org/download.html下载源代码
# tar -jxvf ffmpeg-3.2.4.tar.bz2
# ./configure --enable-shared --enable-gpl --enable-swscale
其中--enable-shared表示生成动态链接库,可以供以后编程使用,同时生成的可执行程序也依赖这些动态库。如果不加上--enable-shared选项则使用静态链接的方式编译,此时不会生成动态库,同时生成的ffmpeg等的可执行文件体积也比较大,但他们不需要动态库就可以直接运行.
# make (大约15分钟)
# make install
1. 从官网下载 opencv-2.4.13.zip
2. 执行安装
# unzip opencv-2.4.13.zip
# cd opencv-2.4.13
# cmake CMakeLists.txt
(此处大约1分钟,会看到很多打印信息,包括ffmepg的配置信息,如果是YES,则一切OK,如下图所示)
# make && make install
(此处大约30分钟)
1. # vim /etc/ld.so.conf.d/opencv.conf 创建并编辑该文件。填入:/usr/local/lib
2. # ldconfig
3. # vim /etc/bashrc 在文件末尾,填写以下2行:
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH
4. # source /etc/bashrc 使文件生效
5. 进入opencv-2.4.13下的 samples / c 目录
运行脚本$./build_all.sh
等待其编译完后,执行目录下的其中一个程序 $./find_obj 。可以看到结果
报错信息:
OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvNamedWindow,...................
解决方案:
(1)彻底删除已安装的opencv
# 删除解压后的安装包,重新解压一次 opencv-2.4.13.zip
# rm -rf /usr/local/lib/libopencv*
# rm -rf /usr/local/include/opencv
# rm -rf /usr/local/include/opencv2
(2)重复第三、四步,执行安装
-----------------------------------------------------------------------------------------------------------------------------------
[1] http://blog.csdn.net/genghaihua/article/details/44305949
[2] http://blog.csdn.net/luotuo44/article/details/8909258
[3] http://noalgo.info/874.html
------