opencv的安装和卸载

安装

测试环境为centos

安装依赖

         yum install cmake gcc gcc-c++ gtk2-devel gimp-develgimp-devel-tools gimp-help-browser zlib-devel libtiff-devel libjpeg-devellibpng-devel gstreamer-devel libavc1394-devel libraw1394-devel libdc1394-develjasper-devel jasper-utils swig python libtool nasm 

下载opencv

http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.9/opencv-2.4.9.zip/download,拷贝到/usr/local/路径之下 。

    命令:“unzip opencv-2.4.9.zip”解压出opencv的源码

    命令:“cd opencv-2.4.9”进入源码文件夹

    命令:“cmake CMakeLists.txt”,生成build文件

    命令:”make”,完成opencv的编译

    命令:“make install”,完成opencv的安装

安装完成后    Opencv的头文件在“/usr/local/include”目录下

                     Opencv的库文件在“/usr/local/lib”目录下

命令:“cd /etc/ld.so.conf.d/”,进入库文件环境变量配置文件夹,命令“ls”,可以查看当前文件夹下已有的库文件配置。
命令:“vim opencv.conf”,按下“i”,输入opencv的库文件目录“/usr/local/lib”,保存退出(:wq)
命令:"ldconfig" 加载库文件配置

环境变量配置

  vim /etc/bashrc

  添加:PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig

       export PKG_CONFIG_PATH

  保存之后执行

  source /etc/bashrc

测试安装是否成功

  cd /usr/local/opencv-2.4.9/samples/c

命令:./build_all.sh

编译结束之后执行:

  ./facedetect cascade=“/usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_alt.xml”--scale=1.5 lena.jpg

如果安装成功的话,lena脸上会有一个蓝色的圈:

 

卸载

sudo rm -r /usr/local/include/opencv2 /usr/local/include/opencv /usr/include/opencv  /usr/include/opencv2 /usr/local/share/opencv /usr/local/share/OpenCV /usr/share/opencv /usr/share/OpenCV /usr/local/bin/opencv* /usr/local/lib/libopencv*

posted @ 2017-12-26 10:35  且听风吟-wuchao  阅读(11142)  评论(0编辑  收藏  举报