[gst-embedded] I can't draw on RGB space a frame from webcam

Tim-Philipp Müller t.i.m at zen.co.uk
Mon May 11 07:12:11 PDT 2009


On Sat, 2009-05-09 at 11:34 -0300, Juan Pablo Hernández Vogt wrote:

> I'd like to draw lines in a RGB space before show it. I let you a
> simple c++ program that shows a webcam. I've add a callback to get the
> buffer after convert it, but it's in YUY2 and not in RGB. What am I
> doing wrong?
>  ...
>   // setup capsfilter
>   g_object_set (G_OBJECT (flt), "caps",
>     gst_caps_new_simple ("video/x-raw-yuv",
>       "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'),
>  ...

Ok, so you've put a capsfilter right after the camera source, and set
filtercaps requesting YUY2 format on it, which means that the pipeline
will either fail (if the cam doesn't support YUY2 or the
framerate/resolution you've chosen), or capsfilter will output buffers
in YUY2 format.

Next you have ffmpegcolorspace ! xvimagesink. This makes sure that the
YUY2 buffer gets converted into a format xvimagesink can handle in case
xvimagesink does't support YUY2 in your setup.

This means in practice that you can't really make any assumptions about
what format the video data pushed to xvimagesink will be.

You have set up a pad probe on xvimagesink's sink pad, so the buffer you
receive in the callback could be any format. You can check the format
with something like:

if (GST_BUFFER_CAPS (buffer)) {
  gchar *str = gst_caps_to_string (GST_BUFFER_CAPS (caps));
  g_print ("buffer caps: %s\n", str);
  g_free (str);
}

If you absolutely need to manipulate RGB data, you could write an
element that does that and which exposes RGB caps on its pad templates,
and then have a pipeline like: v4l2src ! ffmpegcolorspace ! capsfilter !
yourelement ! ffmpegcolorsapce ! xvimagesink
 
Cheers
 -Tim





More information about the Gstreamer-embedded mailing list