[Sugar-devel] getting image from gStreamer

Puneet Kaur puneet.gkaur at gmail.com
Mon Jul 21 01:44:16 EDT 2014


On Mon, Jul 21, 2014 at 10:56 AM, James Cameron <quozl at laptop.org> wrote:

> On Mon, Jul 21, 2014 at 02:07:15AM +0530, Puneet Kaur wrote:
> > Hey all,
> >
> > I was able to get the webcam stream using gStreamer through this :
> >
> >         self.src = Gst.ElementFactory.make('autovideosrc', None)
> >         self.sink = Gst.ElementFactory.make('autovideosink', None)
> >
> >         (and more related corde...)
>
> Good.
>
> > but how to modify in order to store the image (on click) to a file /
> buffer ?
> >
> > I tried :
> >
> > 1)     gdk_display = GdkX11.X11Display.get_default()
> >         gdk_window =
> GdkX11.X11Window.foreign_new_for_display(gdk_display,self.xid)
>

the above two lines for fetching gdk window from a given xid


> >         width = gdk_window.get_width()
> >         height = gdk_window.get_height()
>

width and height of the gdk window


> >         ims = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
>

make a cairo surface

>
> >         pb = Gdk.pixbuf_get_from_window(gdk_window, 0, 0, width, height)
>

get the pixbuf from the gdk window


> >         cr = cairo.Context(ims)
>

set the cairo context


> >         Gdk.cairo_set_source_pixbuf(cr, pb, 0, 0)
>

set cairo source


> >         cr.paint()
>


paint on the cairo context and then save the surface by :
ims.write_to_png('testimage'+self.snapshot_name()+'.png')



> How are you copying the camera image to the surface?  I can't see how
> you do that in the above example.
>
>
^


> tacamera.py in plugins/camera_sensor/ in turtleart git was very
> interesting; it showed a method _on_message to ensure the pixbuf is
> available before proceeding with saving.
>
>
Thanks, would look into it.


> --
> James Cameron
> http://quozl.linux.org.au/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20140721/8fc978aa/attachment-0001.html>


More information about the Sugar-devel mailing list