[Sugar-devel] getting image from gStreamer

Puneet Kaur puneet.gkaur at gmail.com
Mon Jul 21 09:48:27 EDT 2014


yes, I guess you are right Gonzalo.I too was thinking that there would be
some pipeline issue because of which I am not able to get the image.Thanks
for the help :-)


On Mon, Jul 21, 2014 at 5:43 PM, Gonzalo Odiard <godiard at sugarlabs.org>
wrote:

> I think yoou should get the photo data from the gstreamer side,
> not from the widget where you are displaying it.
> If you look at the Record activity code,
> the logic used to take the photo is in glive.py take_photo method,
> and adding a sink to a tee in the gstreamer pipeline,
> and getting the data from there (_photo_handoff method)
>
> Gonzalo
>
>
> On Mon, Jul 21, 2014 at 2:50 AM, James Cameron <quozl at laptop.org> wrote:
>
>> 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/
>> _______________________________________________
>> Sugar-devel mailing list
>> Sugar-devel at lists.sugarlabs.org
>> http://lists.sugarlabs.org/listinfo/sugar-devel
>>
>
>
>
> --
> Gonzalo Odiard
>
> SugarLabs - Software for children learning
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20140721/d6b5c943/attachment.html>


More information about the Sugar-devel mailing list