45 lines
No EOL
1.5 KiB
Bash
45 lines
No EOL
1.5 KiB
Bash
#!/bin/bash
|
|
# When using RTSP gstreamer can provides a way lower latency then ffmpeg
|
|
# and exposes more options to tweak the connection. However, the pypi
|
|
# version of python-opencv is build without gstreamer. Thus, we need to
|
|
# build our own python wheel.
|
|
|
|
# adapted from https://github.com/opencv/opencv-python/issues/530#issuecomment-1006343643
|
|
|
|
# install gstreamer dependencies
|
|
sudo apt-get install --quiet -y --no-install-recommends \
|
|
gstreamer1.0-gl \
|
|
gstreamer1.0-opencv \
|
|
gstreamer1.0-plugins-bad \
|
|
gstreamer1.0-plugins-good \
|
|
gstreamer1.0-plugins-ugly \
|
|
gstreamer1.0-tools \
|
|
libgstreamer-plugins-base1.0-dev \
|
|
libgstreamer1.0-0 \
|
|
libgstreamer1.0-dev
|
|
|
|
# ffmpeg deps
|
|
sudo apt install ffmpeg libgtk2.0-dev libavformat-dev libavcodec-dev libavutil-dev libswscale-dev libtbb-dev libjpeg-dev libpng-dev libtiff-dev
|
|
|
|
OPENCV_VER="84" #fix at 4.10.0.84, or use rolling release: "4.x"
|
|
STARTDIR=$(pwd)
|
|
TMPDIR=$(mktemp -d)
|
|
|
|
# Build and install OpenCV from source.
|
|
echo $TMPDIR
|
|
|
|
# pyenv compatibility
|
|
cp .python-version $TMPDIR
|
|
|
|
cd "${TMPDIR}"
|
|
git clone --branch ${OPENCV_VER} --depth 1 --recurse-submodules --shallow-submodules https://github.com/opencv/opencv-python.git opencv-python-${OPENCV_VER}
|
|
cd opencv-python-${OPENCV_VER}
|
|
export ENABLE_CONTRIB=0
|
|
# export ENABLE_HEADLESS=1
|
|
# We want GStreamer support enabled.
|
|
export CMAKE_ARGS="-DWITH_GSTREAMER=ON -DWITH_FFMPEG=ON"
|
|
python -m pip wheel . --verbose -w $STARTDIR
|
|
|
|
# # Install OpenCV
|
|
# python3 -m pip install opencv_python*.whl
|
|
# cp opencv_python*.whl $STARTDIR |