How To Compile Opencv With Gstreamer (Ubuntu&Windows) : Galaktyk 01
How To Compile Opencv With Gstreamer (Ubuntu&Windows) : Galaktyk 01
Galaktyk 01 Follow
Save
## Ubuntu
Ubuntu 16.04
Python 3.7
OpenCV 4.1.0
Open in app Sign up Sign In
https://galaktyk.medium.com/how-to-build-opencv-with-gstreamer-b11668fa09c 1/14
3/9/23, 8:43 AM How to compile OpenCV with Gstreamer [Ubuntu&Windows] | by Galaktyk 01 | Medium
Gstreamer 1.8.3
Cmake 3.5.1
Search Medium
1. install gstreamer1.0
3. install numpy
I recommend to use conda or virtualenv over the native one, in case we mess things up.
5. Building
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D INSTALL_C_EXAMPLES=OFF \
-D PYTHON_EXECUTABLE=$(which python3) \
-D BUILD_opencv_python2=OFF \ 86 9
https://galaktyk.medium.com/how-to-build-opencv-with-gstreamer-b11668fa09c 2/14
3/9/23, 8:43 AM How to compile OpenCV with Gstreamer [Ubuntu&Windows] | by Galaktyk 01 | Medium
if something went wrong just remove build folder and try again.
7. Building
◾ Install package
https://galaktyk.medium.com/how-to-build-opencv-with-gstreamer-b11668fa09c 4/14
3/9/23, 8:43 AM How to compile OpenCV with Gstreamer [Ubuntu&Windows] | by Galaktyk 01 | Medium
## WINDOWS
Windows 10 1903
python 3.7.0
OpenCV 4.1.0
https://galaktyk.medium.com/how-to-build-opencv-with-gstreamer-b11668fa09c 5/14
3/9/23, 8:43 AM How to compile OpenCV with Gstreamer [Ubuntu&Windows] | by Galaktyk 01 | Medium
Gstreamer 1.16.4
Cmake 3.14.5
Visual Studio 2019
2. Install numpy
https://galaktyk.medium.com/how-to-build-opencv-with-gstreamer-b11668fa09c 6/14
3/9/23, 8:43 AM How to compile OpenCV with Gstreamer [Ubuntu&Windows] | by Galaktyk 01 | Medium
◾ Open CmakeGUI.
◾ Select opencv source and build folder.
https://galaktyk.medium.com/how-to-build-opencv-with-gstreamer-b11668fa09c 7/14
3/9/23, 8:43 AM How to compile OpenCV with Gstreamer [Ubuntu&Windows] | by Galaktyk 01 | Medium
◾ Hit Configure, select your Visual Studio version then click Finish
https://galaktyk.medium.com/how-to-build-opencv-with-gstreamer-b11668fa09c 8/14
3/9/23, 8:43 AM How to compile OpenCV with Gstreamer [Ubuntu&Windows] | by Galaktyk 01 | Medium
◾ Click Generate
◾ in Visual Studio:
switch from DEBUG to RELEASE and x64
https://galaktyk.medium.com/how-to-build-opencv-with-gstreamer-b11668fa09c 9/14
3/9/23, 8:43 AM How to compile OpenCV with Gstreamer [Ubuntu&Windows] | by Galaktyk 01 | Medium
😉👌
◾ Finally, add bin & lib folder to your env PATH , (from C:\opencv-
4.1.0\build\install\x64\vc16)
https://galaktyk.medium.com/how-to-build-opencv-with-gstreamer-b11668fa09c 10/14
3/9/23, 8:43 AM How to compile OpenCV with Gstreamer [Ubuntu&Windows] | by Galaktyk 01 | Medium
Test
◾ Identify the location of a cv2 module
import cv2
print(cv2.__file__)"
https://galaktyk.medium.com/how-to-build-opencv-with-gstreamer-b11668fa09c 11/14
3/9/23, 8:43 AM How to compile OpenCV with Gstreamer [Ubuntu&Windows] | by Galaktyk 01 | Medium
print(cv2.getBuildInformation())
https://galaktyk.medium.com/how-to-build-opencv-with-gstreamer-b11668fa09c 12/14
3/9/23, 8:43 AM How to compile OpenCV with Gstreamer [Ubuntu&Windows] | by Galaktyk 01 | Medium
import cv2
cap = cv2.VideoCapture('autovideosrc ! videoconvert ! appsink')
while True:
ret,frame = cap.read()
cv2.imshow('',frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cv2.destroyAllWindows()
cap.release()
https://galaktyk.medium.com/how-to-build-opencv-with-gstreamer-b11668fa09c 13/14
3/9/23, 8:43 AM How to compile OpenCV with Gstreamer [Ubuntu&Windows] | by Galaktyk 01 | Medium
Enjoy 🐔
https://galaktyk.medium.com/how-to-build-opencv-with-gstreamer-b11668fa09c 14/14