From f69ce9912b08dbba82044b4337dec2ec498cc36f Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Sun, 26 Dec 2010 19:22:19 +0000 Subject: add variable pause for camera capture depending upon hardware --- (limited to 'TurtleArt') diff --git a/TurtleArt/tacamera.py b/TurtleArt/tacamera.py index f7e08ff..a4227ed 100644 --- a/TurtleArt/tacamera.py +++ b/TurtleArt/tacamera.py @@ -22,7 +22,7 @@ import gst, time -def save_camera_input_to_file(imagepath): +def save_camera_input_to_file(imagepath, pause=2.0): """ Grab a frame from the video camera and save to a temporary file """ pipeline = gst.parse_launch( @@ -30,6 +30,6 @@ def save_camera_input_to_file(imagepath): pipeline.set_state(gst.STATE_PLAYING) # Need to pause for pipeline to stablize - time.sleep(2) + time.sleep(pause) pipeline.set_state(gst.STATE_NULL) diff --git a/TurtleArt/talogo.py b/TurtleArt/talogo.py index 8cdd9b5..399b5b4 100755 --- a/TurtleArt/talogo.py +++ b/TurtleArt/talogo.py @@ -526,9 +526,13 @@ class LogoCode: if self.tw.hw == XO1: self.voltage_gain = 0.00002225 self.voltage_bias = 1.140 + self.camera_pause = 0.6 elif self.tw.hw == XO15: self.voltage_gain = -0.0001471 self.voltage_bias = 1.695 + self.camera_pause = 0.5 + else: + self.camera_pause = 2.0 if self.tw.running_sugar: self.imagepath = get_path(self.tw.activity, @@ -1324,7 +1328,8 @@ class LogoCode: dsobject = None if string[6:] == 'CAMERA': if self.tw.camera: - save_camera_input_to_file(self.imagepath) + save_camera_input_to_file(self.imagepath, + self.camera_pause) self.filepath = self.imagepath elif os.path.exists(string[6:]): # is it a path? self.filepath = string[6:] @@ -1472,7 +1477,7 @@ class LogoCode: w = self._w() h = self._h() if w > 0 and h > 0 and self.tw.camera: - save_camera_input_to_file(self.imagepath) + save_camera_input_to_file(self.imagepath, self.camera_pause) pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(self.imagepath, w, h) try: array = pixbuf.get_pixels() -- cgit v0.9.1