编译参考
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())