Skip to content

Instantly share code, notes, and snippets.

@aslafy-z
Last active January 29, 2025 10:01
Show Gist options
  • Save aslafy-z/95957a12b60fed5643f95d49d8823669 to your computer and use it in GitHub Desktop.
Save aslafy-z/95957a12b60fed5643f95d49d8823669 to your computer and use it in GitHub Desktop.
Build opencv-python with Gstreamer support on Windows

Build opencv-python with Gstreamer support on Windows

Requirements

Create python environment

$ conda create -n opencv-build-py312 python=3.12
$ conda activate opencv-build-py312

Build the package

OPENCV_VER="4.x"
export ENABLE_CONTRIB=1
export ENABLE_HEADLESS=0
export CMAKE_ARGS="-DWITH_GSTREAMER=ON" # We want GStreamer support enabled.

BUILDDIR=$(mktemp -d)
CLONEDIR="$BUILDDIR/opencv-python"

git clone --branch "${OPENCV_VER}" --depth 1 --recurse-submodules --shallow-submodules https://github.com/opencv/opencv-python.git "$CLONEDIR"
TMPDIR="$BUILDDIR" python -m pip wheel "$CLONEDIR" --verbose

mv "$CLONEDIR"/opencv_*.whl "$BUILDDIR"

Source: opencv/opencv-python#530 (comment)

Cleanup

rm -rf $BUILDDIR
conda remove -n opencv-build-py312 --all

Install package

python -m pip install $BUILDDIR/opencv_*.whl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment