[Sugar-devel] getting image from gStreamer

James Cameron quozl at laptop.org
Mon Jul 21 01:50:40 EDT 2014


On Mon, Jul 21, 2014 at 11:14:16AM +0530, Puneet Kaur wrote:
> 
> 
> 
> 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.
> 
> 
> 
> ^

Sorry, I don't understand.  Yes, I agree with the comments you added
to the code, but I don't see how you are copying the camera image to
the surface.  As far as I can tell, you _must_ end up with a blank
surface if you don't put anything on it.

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


More information about the Sugar-devel mailing list