8

I'm trying to have OpenCV process a frame in the middle of a gstreamer pipe.

I have one gstreamer pipe generating the stream, sending it to appsink for OpenCV code to receive:

v4l2src ! ffmpegcolorspace ! jpegenc ! appsink name=sink

And another pipe getting it from appsrc (to which OpenCV sends data) and outputting it on the screen:

appsrc name=src ! jpegdec ! xvimagesink

I open every frame with a pull-buffer request on sink and process it with OpenCV, then use push-buffer on src. I am doing all that in Python.

For some reason, that does not seem to work (segmentation fault).

But I'm not really trying to fix it; it's terribly inefficient anyway. I am just wondering whether there any better way to have OpenCV process the frame before it reaches an output sink?

3
  • 2
    Since you want more than what gst-opencv can offer, if you don't mind writing your logic in C (or C++), perhaps you should try writing it as a plugin to gst? You can take one of the gst-opencv plugins' source as a starting point Commented Jan 14, 2011 at 3:21
  • 1
    Another thing - your example seems to just grabbing from v4l2, and I think opencv's HighGui API supports that already (or at least v4l without the '2'). that would be the easiest solution if you don't really need gstreamer. Commented Jan 14, 2011 at 3:23
  • 1. Good suggestion, I might do that. 2. You're right, I could use HighGUI in this case, but v4l2src was used merely as an example. In the actual application I intend to get the video stream from a tcp source, so I can't really implement the whole thing in OpenCV. Commented Jan 14, 2011 at 3:40

2 Answers 2

3

Did you try gst-opencv? It supplies several opencv primitives as gstreamer plugins.

EDIT: Seems like it's merged into gst-plugins-bad, and the link above is outdated.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your answer. I considered gst-opencv but decided against it because I want the freedom to process the video frames in any way I want (for example, apply domain-specific machine learning algorithms), and the options offered by gst-opencv are very generic.
1

I know some years have passed since your original question, but just for the record, OpenCv can open Gstreamer pipelines directly. See the (self-)answer in Using custom camera in OpenCV (via GStreamer) for an example.

And, by the way, OpenCv 3.0 (master branch) actually integrates gstreamer 1.0 support.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.