[Sugar-devel] Sugar-devel Digest, Vol 38, Issue 17
James Cameron
quozl at laptop.org
Tue Dec 6 19:32:12 EST 2011
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/
More information about the Sugar-devel
mailing list