apt install git build-essential cmake python3-numpy [python-numpy]
apt-get install libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libavresample-dev
apt-get install --no-install-recommends libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-bad1.0-dev gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-doc gstreamer1.0-tools gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-qt5 gstreamer1.0-pulseaudio
apt install libgtk-3-dev
pip install --upgrade pip
git clone https://github.com/opencv/opencv-python
cd opencv-python
MAKEFLAGS='-j10' pip wheel . --verbose
pip install {BUILT WHEEL}
Manual compilation
https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu
python -m pip install --upgrade pip
pip -V
pip install scikit-build
apt install git cmake
# chown -R root:root if using docker
python setup.py clean --all
cd /workspace
git clone https://github.com/opencv/opencv-python
PKG_CONFIG_PATH=/root/ffmpeg_build/lib/pkgconfig/ \
ENABLE_CONTRIB=1 \
python setup.py bdist_wheel -- -DOPENCV_EXTRA_MODULES_PATH=/workspace/opencv-python/opencv_contrib/modules \
-DWITH_CUDA=ON -DENABLE_FAST_MATH=1 -DCUDA_FAST_MATH=1 -DWITH_CUBLAS=1 -DCUDA_ARCH_BIN='6.1 7.5 8.0 8.6'
- Install a newer version of NASM with source
- Git clone released tag (e.g.
v3.3.0
) of libaom - Git clone released tag (e.g.
n5.0.1
) of ffmpeg - Compile libaom with
-DBUILD_SHARED_LIBS=1
to avoid opencv linking problem. - Install a newer version of meson with
pip
(may have to removeapt
'smeson
) - To compile with ffmpeg, run opencv-python's build with pkg-config dir: setting environmental variable
PKG_CONFIG_PATH
- Run
pip install scikit-build
before building - Run
sudo apt-get install libunistring-dev
to avoidERROR: gnutls not found using pkg-config
in ffmpeg build (https://askubuntu.com/a/1253020/958072)