Python Gstreamer, Webcam, and Pil
David Röthlisberger
david at rothlis.net
Sat Aug 24 02:08:40 PDT 2013
On 24 Aug 2013, at 09:14, Jason (spot) Brower wrote:
> I can take the picture and save the image to a file using just Gstreamer.
> But I need to work with the image before I save it anyway, so how can I convert it to PIL after I take the picture.
> A code example would be handy. I have googled and no found it as far as I have searched.
stb-tester[1] does something similar but converts the GStreamer buffer
to the OpenCV format (i.e. a numpy matrix)[2]. We use appsink[3], and we
register a handler for appsink's "new-buffer" signal[4] that calls
"pull-buffer"[5]. Note that the signal handler is called from the
GStreamer element's streaming thread, so you shouldn't do blocking work
there; instead we push the buffer onto a synchronised Queue[6] that our
main application thread reads from[7].
[1] http://stb-tester.com
[2] https://github.com/drothlis/stb-tester/blob/0.15/stbt.py#L947
[3] https://github.com/drothlis/stb-tester/blob/0.15/stbt.py#L704
[4] https://github.com/drothlis/stb-tester/blob/0.15/stbt.py#L760
[5] https://github.com/drothlis/stb-tester/blob/0.15/stbt.py#L812
[6] http://docs.python.org/2/library/queue.html
[7] https://github.com/drothlis/stb-tester/blob/0.15/stbt.py#L772
More information about the gstreamer-devel
mailing list