1.yum命令安装以下依赖包:
yum install cmake gcc gcc-c++ 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
2. opencv解压后,进入目录,执行如下命令:
cmake -D CMAKE_BUILD_TYPE=Release -D OPENCV_EXTR_MODULES_PATH=/opt/soft/opencv/opencv_contrib/opencv_contrib/modules/ -D CMAKE_INSTALL_PREFIX=/usr/local .
3.
如果第2步不能成功下载 ippicv_linux_20151201.tgz ,把需要的文件从百度云盘的源码资料中替换到对应的目录(/3rdparty/ippicv/downloads/linux-808b791a6eac9ed78d32a7666804320e/ippicv_linux_20151201.tgz)
如果以上步骤成功,显示:
-- Configuring done
-- Generating done
-- Build files have been written to: /opt/opencv/opencv
4.
[root@BiuBiu opencv]# make -j8 && make install
5.
新建文件 /etc/ld.so.conf.d/opencv.conf
在文件中添加 /usr/local/lib
保存之后执行配置:
ldconfig-v
// 在ld.so.conf.d文件中将所有的/etc/ld.so.conf.d/*.conf文件都包含进来了
6.
为程序指定openvc的头文件位置, 使用pkg-config命令来完成。
首先在 /etc/profile 中添加:
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
立即生效:
source /etc/profile
7. 查看opencv配置信息:
[root@BiuBiu ld.so.conf.d]# pkg-config --libs opencv
显示如下信息:
-L/usr/local/lib -lopencv_shape -lopencv_stitching -lopencv_objdetect -lopencv_superres -lopencv_videostab -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_video -lopencv_photo -lopencv_ml -lopencv_imgproc -lopencv_flann -lopencv_core
参考:
http://www.yanjiankang.cn/linux-install-opencv-on-ubuntu-or-redhat/
http://www.cnblogs.com/fesh/p/4110535.html
http://www.jb51.net/os/RedHat/280309.html