Files
sf-op/script/camtool.py
2016-07-05 15:59:57 +02:00

46 lines
2.0 KiB
Python

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 + self.mode + "."
self.cam_run = Channel(prefix + "camera.run", alias = "cam_run")
self.cam_latch = Channel(prefix + "latch.capture", alias = "cam_latch")
self.timestamp = Channel(self.data_prefix + "timestamp", alias = "timestamp") #[D1, D2, ...]
self.cam_x = Channel(self.data_prefix + "x_stats.com", alias = "cam_x")
self.cam_y = Channel(self.data_prefix + "y_stats.com", alias = "cam_y")
self.profile_x = Channel(self.data_prefix + "profile.x", alias = "profile_x")
self.profile_y = Channel(self.data_prefix + "profile.y", alias = "profile_y")
self.cam_image = Channel(self.data_prefix + "image", alias = "cam_image")
self.cam_image_shape = Channel(self.data_prefix + "image.shape", alias = "cam_image_shape") #[D1, D2, ...]
self.cam_bg_image = Channel(self.data_prefix + "bg_image", alias = "cam_bg_image") #[D1, D2, ...]
self.cam_bg_en = Channel(self.prefix + "bg.enabled", alias = "cam_bg_en")
self.cam_bg_capture = Channel(self.prefix + "bg.capture", alias = "cam_bg_capture")
self.cam_bg_capture_remain = Channel(self.prefix + "bg.capture", alias = "cam_bg_capture_remain")
if latch:
self.start_cam()
else:
self.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 self.latch:
self.cam_latch.write(1)
else:
self.cam_run.write(1)
while(timestamp == self.timestamp.read()):
time.sleep(0.001)
camera_tool = CamTool()
camera_tool.capture()
print camera_tool.cam_x.read(), camera_tool.cam_y.read()