diff --git a/script/camtool.py b/script/camtool.py new file mode 100644 index 0000000..a48af38 --- /dev/null +++ b/script/camtool.py @@ -0,0 +1,45 @@ +class CamTool: + def __init__(self, prefix = "cam:", latch = False) + self.prefix = prefix + self.latch = latch + self.mode = "latch" if latch else "pipeline" + self.data_prefix = prefix + mode + "." + self.cam_run = Channel(prefix + "camera.run", alias = "cam_run") + self.cam_latch = Channel(prefix + "latch.capture", alias = "cam_latch") + self.timestamp = Channel(data_prefix + "timestamp", alias = "timestamp") #[D1, D2, ...] + + self.cam_x = Channel(data_prefix + "x_stats.com", alias = "cam_x") + self.cam_y = Channel(data_prefix + "y_stats.com", alias = "cam_y") + self.profile_x = Channel(data_prefix + "profile.x", alias = "profile_x") + self.profile_y = Channel(data_prefix + "profile.y", alias = "profile_y") + self.cam_image = Channel(data_prefix + "image", alias = "cam_image") + self.cam_image_shape = Channel(data_prefix + "image.shape", alias = "cam_image_shape") #[D1, D2, ...] + self.cam_bg_image = Channel(data_prefix + "bg_image", alias = "cam_bg_image") #[D1, D2, ...] + + self.cam_bg_en = Channel(prefix + "bg.enable", alias = "cam_bg_en") + self.cam_bg_capture = Channel(prefix + "bg.capture", alias = "cam_bg_capture") + self.cam_bg_capture_remain = Channel(prefix + "bg.capture", alias = "cam_bg_capture_remain") + if latch: + start_cam() + else + stop_cam() + + def start_cam(self) + self.cam_run.write(-1) + + def stop_cam(self) + self.cam_run.write(0) + + def capture(self) + timestamp = self.timestamp.read() + if mode == "latch": + self.cam_latch.write(1) + else: + self.cam_run.write(1) + while(timestamp == self.timestamp.read()): + time.sleep(1) + + +camera_tool = CamTool() +camera_tool.capture() +print camera_tool.cam_x, camera_tool.cam_x,