[Sugar-devel] getting image from gStreamer

James Cameron quozl at laptop.org
Mon Jul 21 01:26:22 EDT 2014


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)
>         width = gdk_window.get_width()
>         height = gdk_window.get_height()    
>         ims = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)          
>         pb = Gdk.pixbuf_get_from_window(gdk_window, 0, 0, width, height)
>         cr = cairo.Context(ims)    
>         Gdk.cairo_set_source_pixbuf(cr, pb, 0, 0)     
>         cr.paint()

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.

-- 
James Cameron
http://quozl.linux.org.au/


More information about the Sugar-devel mailing list