美文网首页
OpenCV2.4.13+Ubuntu18.04 配置

OpenCV2.4.13+Ubuntu18.04 配置

作者: calm_furious | 来源:发表于2019-05-14 11:01 被阅读0次

    每次配环境都是一种折磨,记录以下这次的过程。
    (如果用linux的免驱camera千万不要再尝试用windows配置OPENCV)

    装依赖包

    参考
    https://gist.github.com/sedovolosiy/6711123a9e5a73a6ce519e80338d0067

    # install dependencies
    sudo apt-get update
    sudo apt-get install -y build-essential
    sudo apt-get install -y cmake
    sudo apt-get install -y libgtk2.0-dev
    sudo apt-get install -y pkg-config
    sudo apt-get install -y python-numpy python-dev
    sudo apt-get install -y libavcodec-dev libavformat-dev libswscale-dev
    sudo apt-get install -y libjpeg-dev libpng12-dev libtiff5-dev libjasper-dev
     
    sudo apt-get -qq install libopencv-dev build-essential checkinstall cmake pkg-config yasm libjpeg-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine2 libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev python-dev python-numpy libtbb-dev libqt4-dev libgtk2.0-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils
    

    最后一行中那几个包你不需要的话,找不到也不要紧。

    其中,libjasper-dev安装不成功解决办法:
    via https://blog.csdn.net/weixin_41053564/article/details/81254410

    sudo add-apt-repository "deb [http://security.ubuntu.com/ubuntu](http://security.ubuntu.com/ubuntu) xenial-security main"
    sudo apt update
    sudo apt install libjasper1 libjasper-dev
    

    下载解压opencv

    请各显神通
    我的方式还是参考上面的github,在Download文件夹下:

    # download opencv-2.4.13
    wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.13/opencv-2.4.13.zip
    unzip opencv-2.4.13.zip
    cd opencv-2.4.13
    mkdir release
    cd release
    

    编译安装

    只参考github会报很多错,解决办法都在这里:

    1. OpenCV CMake package version error 版本号没有定义
      https://codeyarns.com/2017/12/24/opencv-cmake-package-version-error/
    2. CMake Error at cmake/OpenCVDetectCXXCompiler.cmake :
      https://answers.opencv.org/question/65548/cmake-error-at-cmakeopencvdetectcxxcompilercmake/
      解决方法是改opencv-2.4.13/cmake文件夹里的两个文件。

    然后参考https://blog.csdn.net/zbzb1000/article/details/81431685https://blog.csdn.net/u012116133/article/details/78559859
    (会报fatal error: stdlib.h: No such file or directory这个错):

    # compile and install
    cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D ENABLE_PRECOMPILED_HEADERS=OFF ..
    make -j6 #根据自己的情况改数字,报错的话要么看log,要么单线程跑。
    sudo make install
    

    相关文章

      网友评论

          本文标题:OpenCV2.4.13+Ubuntu18.04 配置

          本文链接:https://www.haomeiwen.com/subject/argjaqtx.html