Skip to content Skip to sidebar Skip to footer

How To Get Gstreamer Live Stream Using Opencv And Python?

I am streaming a live usb camera feed from raspberry pi zero by using below code in terminal: gst-launch-1.0 -v v4l2src device=/dev/video0 ! 'image/jpeg,width=640, height=480, fram

Solution 1:

I just went through a similar issue myself and had a 'good' time debugging it. Here is my related post.

Your question gives no discrete insight, as to how you installed your cv2 python module. In case you used pip to get the package, you can't enable gstreamer for the package. That is because pip only deploys pre-built binaries of the cv2 package and none of them support gstreamer.

What you would need to do (it is indeed fairly easy) is, follow these instructions to build OpenCV from the source distribution.

Beware not to make the same mistake I did. When configuring the build using cmake or ccmake, make sure to only set WITH_GSTREAMER to ON. Make sure WITH_GSTREAMER_0_10 is set OFF.

Also, before you do the installation from source, make sure to whipe all existing binaries.

For pip installations of cv2 that is going to mean something like:

pip unistall opencv-python

In case you already built binaries from the opencv source, you'll have to:

sudo make uninstall

from the <opencv-src>/build folder. Then go ahead and give it another go.

Solution 2:

I can answer the question on how to find out, if you have opencv installed with gstreamer support.

Paste this in your Python script:

print(cv2.getBuildInformation())

You should find something like that:

Video I/O:...GStreamer:base:YES(ver1.8.3)video:YES(ver1.8.3)app:YES(ver1.8.3)...

If it is not YES, you must reinstall opencv with gstreamer support.

Post a Comment for "How To Get Gstreamer Live Stream Using Opencv And Python?"