Linux下安装OpenCV步骤

1. sudo apt-get install cmake

    sudo apt-get install cmake-qt-gui

    sudo apt-get install libgtk2.0-dev

    sudo apt-get install pkg-config

2.新建一个目录opencv_x86作为pc编译目录

   执行cmake-gui

    CMAKE_BUILD_TYPE值输入Release

    WITH_QT勾选 去掉WITH_TIFF

    在opencv_x86中执行make;make install

3.配置环境变量: sudo gedit /etc/ld.so.conf.d/opencv.conf

                         将/usr/local/lib写入最后

                         执行sudo ldconfig

4.更改环境变量 sudo gedit /etc/bash.bashrc

    在文件后添加:PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig

                         export PKG_CONFIG_PATH

5.将源代码中samples中C文件夹拷出来

    ./build_all.sh

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

你可能感兴趣的:(Linux下安装OpenCV步骤)