I want to compile opencv WITH gstreamer for an application to run on my Raspberry pi 3b+. I am unsure what to do as many tutorials are outdated or complicated and there is no build with gstreamer enabled. I have tried following this: https://solarianprogrammer.com/2018/12/18/cross-compile-opencv-raspberry-pi-raspbian/

and it seems to be my best option, I was able to get opencv with gstreamer enabled to compile, but I had to do a lot of weird (and unreproducable) stuff to get it to compile.

Is there a easyish way for me to compile opencv with gstreamer support on my desktop for the Pi?

1 Answer 1


Okay, I was able to compile it using this script, its essentially the same as the post, but with the addition of the gstreamer

apt upgrade && sudo apt upgrade
sudo dpkg --add-architecture armhf
sudo apt update
sudo apt install qemu-user-static
apt-get install python3-dev
apt-get install python3-numpy
apt-get install python-dev
apt-get install python-numpy
apt-get install libpython2-dev:armhf
apt-get install libpython3-dev:armhf

apt install libtiff-dev:armhf zlib1g-dev:armhf
apt install libjpeg-dev:armhf libpng-dev:armhf
apt install libavcodec-dev:armhf libavformat-dev:armhf libswscale-dev:armhf libv4l-dev:armhf
apt install libxvidcore-dev:armhf libx264-dev:armhf
apt install crossbuild-essential-armhf
apt install gfortran-arm-linux-gnueabihf
sudo apt install cmake git pkg-config wget

cd ~
mkdir opencv_all && cd opencv_all
wget -O opencv.tar.gz https://github.com/opencv/opencv/archive/4.1.0.tar.gz
tar xf opencv.tar.gz
wget -O opencv_contrib.tar.gz https://github.com/opencv/opencv_contrib/archive/4.1.0.tar.gz
tar xf opencv_contrib.tar.gz
rm *.tar.gz

export PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabihf/pkgconfig:/usr/share/pkgconfig
export PKG_CONFIG_LIBDIR=/usr/lib/arm-linux-gnueabihf/pkgconfig:/usr/share/pkgconfig

apt install gstreamer1.0-tools:armhf libgstreamer1.0-dev:armhf libgstreamer-plugins-base1.0-dev:armhf

cd opencv-4.1.0
mkdir build && cd build
     -D CMAKE_INSTALL_PREFIX=/opt/opencv-4.1.0 \
     -D CMAKE_TOOLCHAIN_FILE=../platforms/linux/arm-gnueabi.toolchain.cmake \
     -D OPENCV_EXTRA_MODULES_PATH=~/opencv_all/opencv_contrib-4.1.0/modules \
     -D PYTHON2_INCLUDE_PATH=/usr/include/python2.7 \
     -D PYTHON2_LIBRARIES=/usr/lib/arm-linux-gnueabihf/libpython2.7.so \
     -D PYTHON2_NUMPY_INCLUDE_DIRS=/usr/lib/python2/dist-packages/numpy/core/include \
     -D PYTHON3_INCLUDE_PATH=/usr/include/python3.7m \
     -D PYTHON3_LIBRARIES=/usr/lib/arm-linux-gnueabihf/libpython3.7m.so \
     -D PYTHON3_NUMPY_INCLUDE_DIRS=/usr/lib/python3/dist-packages/numpy/core/include \
  • Please mark the answer as the accepted one with a click on the tick on its left side. That prevents your Question from being shown as a unsolved Post to the community and saves them/us a lot of work.
    – Ingo
    Commented Sep 21, 2020 at 19:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.