[Sugar-devel] Sugar-devel Digest, Vol 38, Issue 17

laurent bernabe laurent.bernabe at gmail.com
Tue Dec 6 19:43:20 EST 2011


Yes, your last modifications made it work after about 2 or 3 seconds.
(I moved the gst initialisation and implemented the try/catch loop)
Thanks

2011/12/7 James Cameron <quozl at laptop.org>

> On Wed, Dec 07, 2011 at 01:07:46AM +0100, laurent bernabe wrote:
> > 2011/12/7 James Cameron <quozl at laptop.org> wrote:
> > > You might also try moving the setup of the gst stream to after the
> > > initialisation of pygame.  Experiment, and let us know your results.
> >
> > Sorry but I did not understand this sentence
>
> Sorry.  Try moving the "setup of the gst stream" to after the
> "initialisation of pygame".
>
> The "setup of the gst stream" are the lines:
>
>        # grab a frame from camera to file
>        pipeline = gst.parse_launch('v4l2src ! ffmpegcolorspace ! jpegenc !
>  filesink location=/tmp/pippypic.jpg')
>        pipeline.set_state(gst.STATE_PLAYING)
>
> The "initialisation of pygame" is the line:
>
>        # start using pygame
>        pygame.init()
>
> Moving one beyond the other means to change the order in which these
> operations occur.  I expect the result will be certain failure, which is
> a useful result because it proves the timing is important.
>
> --
>
> Given your test results of success if more time is wasted, perhaps the
> program should retry the read of the file until it works, like this:
>
> # start using pygame
> pygame.init()
>
> # turn off cursor
> pygame.mouse.set_visible(False)
>
> # create the pygame window and return a Surface object for
> # drawing in that window.
> screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)
>
> # grab a frame from camera to file
> pipeline = gst.parse_launch('v4l2src ! ffmpegcolorspace ! jpegenc !
> filesink location=/tmp/pippypic.jpg')
> pipeline.set_state(gst.STATE_PLAYING)
>
> while True:
>    try:
>        # load in the grabbed camera frame
>         image = pygame.image.load('/tmp/pippypic.jpg')
>         break
>    except pygame.error:
>        # pause to allow more time for the camera frame to be grabbed
>        time.sleep(1)
>
> ...
>
> --
> James Cameron
> http://quozl.linux.org.au/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20111207/c73435a2/attachment.html>


More information about the Sugar-devel mailing list