Ask Your Question
0

How does the cv2.VideoCapture class work with gstreamer pipelines?

asked 2016-12-17 15:11:29 -0500

smokey gravatar image

updated 2016-12-17 15:26:30 -0500

Today I found out that you can use a gstreamer pipeline-string in the constructor of the VideoCapture class (see http://stackoverflow.com/a/23795492), like this:

cv2.VideoCapture("autovideosrc ! appsink")

(in python 2.7, OpenCV 3.1.0, Gstreamer 1.4.3)

And this works like a charm, apart from a few assertions failing for Gstreamer, with no apparent ramifications. Sadly, I did not find any documentation on this kind of usage. The (! appsink) is mandatory, I assume? Is data format which flows into 'appsink' arbitrary, i.e. as long as it is a valid pipeline, VideoCapture can work with it?

A Disclaimer: Im pretty new with cv2 - in fact today I used it the first time.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2016-12-20 11:25:15 -0500

smokey gravatar image

A direct excerpt from the comments in the source-code (3.1.0) resolves my question:

(https://github.com/opencv/opencv/blob...)

 * The 'filename' parameter is not limited to filesystem paths, and may be one of the following:
 *
 *  - a normal filesystem path:
 *        e.g. video.avi or /path/to/video.avi or C:\\video.avi
 *  - an uri:
 *        e.g. file:///path/to/video.avi or rtsp:///path/to/stream.asf
 *  - a gstreamer pipeline description:
 *        e.g. videotestsrc ! videoconvert ! appsink
 *        the appsink name should be either 'appsink0' (the default) or 'opencvsink'
 *
 *  When dealing with a file, CvCapture_GStreamer will not drop frames if the grabbing interval
 *  larger than the framerate period. (Unlike the uri or manual pipeline description, which assume
 *  a live source)
 *
 *  The pipeline will only be started whenever the first frame is grabbed. Setting pipeline properties
 *  is really slow if we need to restart the pipeline over and over again.

A little bit further down, the following capabilities are set (For GStreamer 1.x) :

caps = gst_caps_from_string("video/x-raw, format=(string){BGR, GRAY8}; video/x-bayer,format=(string){rggb,bggr,grbg,gbrg}");

Which is what the appsink/opencvsink is capable of.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2016-12-17 15:10:44 -0500

Seen: 9,429 times

Last updated: Dec 20 '16