<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jul 21, 2014 at 10:56 AM, James Cameron <span dir="ltr"><<a href="mailto:quozl@laptop.org" target="_blank">quozl@laptop.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="">On Mon, Jul 21, 2014 at 02:07:15AM +0530, Puneet Kaur wrote:<br>
> Hey all,<br>
><br>
> I was able to get the webcam stream using gStreamer through this :<br>
><br>
> self.src = Gst.ElementFactory.make('autovideosrc', None)<br>
> self.sink = Gst.ElementFactory.make('autovideosink', None)<br>
><br>
> (and more related corde...)<br>
<br>
</div>Good.<br>
<div class=""><br>
> but how to modify in order to store the image (on click) to a file / buffer ?<br>
><br>
> I tried : <br>
><br>
> 1) gdk_display = GdkX11.X11Display.get_default()<br>
> gdk_window = GdkX11.X11Window.foreign_new_for_display(gdk_display,self.xid)<br>
</div></blockquote><div><br></div><div>the above two lines for fetching gdk window from a given xid</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class="">> width = gdk_window.get_width()<br>
> height = gdk_window.get_height() <br></div></blockquote><div><br></div><div>width and height of the gdk window</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class="">
> ims = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height) </div></blockquote><div><br></div><div>make a cairo surface </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class=""> <br>
> pb = Gdk.pixbuf_get_from_window(gdk_window, 0, 0, width, height)<br></div></blockquote><div><br></div><div>get the pixbuf from the gdk window</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class="">
> cr = cairo.Context(ims) </div></blockquote><div><br></div><div>set the cairo context </div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class=""> <br>
> Gdk.cairo_set_source_pixbuf(cr, pb, 0, 0) <br></div></blockquote><div><br></div><div>set cairo source</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class="">
> cr.paint()<br></div></blockquote><div><br></div><div><br></div><div>paint on the cairo context and then save the surface by : ims.write_to_png('testimage'+self.snapshot_name()+'.png') </div><div>
<br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="">
<br>
</div>How are you copying the camera image to the surface? I can't see how<br>
you do that in the above example.<br>
<br></blockquote><div><br></div><div>^</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
tacamera.py in plugins/camera_sensor/ in turtleart git was very<br>
interesting; it showed a method _on_message to ensure the pixbuf is<br>
available before proceeding with saving.<br>
<span class=""><font color="#888888"><br></font></span></blockquote><div><br></div><div>Thanks, would look into it.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<span class=""><font color="#888888">
--<br>
James Cameron<br>
<a href="http://quozl.linux.org.au/" target="_blank">http://quozl.linux.org.au/</a><br>
</font></span></blockquote></div><br></div></div>