編譯參考
Docker環境下編譯,內部整理的詳細的編譯選項和整個編譯的流程,能夠直接用,也能夠參考:python
- https://github.com/SkeLLLa/docker-ffmpeg-opencv
- https://github.com/SkeLLLa/docker-ffmpeg-opencv/blob/master/stretch/Dockerfile
ffmpeg編譯環境
ffmpeg 依賴庫安裝git
- apt-get install cmake g++ git tree vim
- apt-get install pkg-config libavutil-dev libavcodec-dev libavformat-dev libswscale-dev libavresample-dev
其中ffmpeg的工具,能夠經過系統進行安裝,也本身編譯ffmpeg把動態庫安裝到系統裏面
cmake的時候回看到下面的信息:
github
FFMPEG: YES avcodec: YES (ver 57.64.101) avformat: YES (ver 57.56.101) avutil: YES (ver 55.34.101) swscale: YES (ver 4.2.100) avresample: YES (ver 3.1.0)
OpenCV下載
咱們這裏用 3.4.3的版本docker
- git clone https://github.com/opencv/opencv.git
- git checkout 3.4.3
編譯c庫:vim
# mkdir build # cmake -D WITH_FFMPEG=ON -D WITH_IPP=OFF -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/root/opencv_4.1.2 .. # make -j 8; make install
編譯Python庫:工具
# pip install numpy==1.16.5 # mkdir build # cmake -D WITH_FFMPEG=ON -D WITH_IPP=OFF -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/root/opencv -D PYTHON_DEFAULT_EXECUTABLE=$(python -c "import sys; print(sys.executable)") -D PYTHON_NUMPY_INCLUDE_DIRS=$(python -c "import numpy; print (numpy.get_include())") -D PYTHON3_PACKAGES_PATH=$(python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") .. # make -j 8; make install
編譯測試
查看編譯信息測試
>>> import cv2 >>> print(cv2.getBuildInformation())