源码安装支持ffmpeg的opencv2

1.首先安装ffmpeg

  apt-get install ffmpeg

2.安装opencv对ffmeg的依赖

 #  for Compiling OpenCV with ffmpeg support
      apt-get install build-essential
      apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
      apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
     From <https://docs.opencv.org/3.4.2/d7/d9f/tutorial_linux_install.html>

3.下载opencv源码并编译

 >> cd ~/<my_working_directory>
    >> git clone https://github.com/opencv/opencv.git
    >> cd opencv
    >> git checkout 3.1.0
    >> cd ..
    >> git clone https://github.com/opencv/opencv_contrib.git
    >> cd opencv_contrib
    >> git checkout 3.1.0
    
    >> cd ~/<my_working_directory>/opencv
    >> mkdir build
    >> cd build
    
    >> cmake -D WITH_CUDA=OFF \
            -D CMAKE_BUILD_TYPE=Release \
            -D CMAKE_INSTALL_PREFIX=/usr/local \
            -D WITH_IPP=OFF \
            -D WITH_FFMPEG=ON  \
            -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \
            -D BUILD_TESTS=OFF \
            -D BUILD_PERF_TESTS=OFF \
            -D INSTALL_PYTHON_EXAMPLES=OFF \
            -D INSTALL_C_EXAMPLES=OFF \
            -D PYTHON_EXECUTABLE=$(which python) \
            -D BUILD_EXAMPLES=OFF ..
    
    >> make -j$nproc
    >> make install

上一篇:c#自适应窗体的实现


下一篇:How to pass an Amazon account review