From aef6daae43a6a5c0b6fa2300e15d8558f5e29aa1 Mon Sep 17 00:00:00 2001 From: sfop Date: Thu, 18 Aug 2016 16:38:39 +0200 Subject: [PATCH] Script execution --- script/ImageStats.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/script/ImageStats.py b/script/ImageStats.py index e8529b8..195924c 100644 --- a/script/ImageStats.py +++ b/script/ImageStats.py @@ -33,6 +33,7 @@ def get_centroid(source): class ImageStats(DeviceBase): def __init__(self, name, source): DeviceBase.__init__(self, name) + self.source = source self.com_x_samples, self.com_y_samples = [], [] class ComX(Readable): def read(self): @@ -62,9 +63,11 @@ class ImageStats(DeviceBase): def doUpdate(self): self.com_x_samples, self.com_y_samples = [], [] for i in range(self.num_images): - self.waitNext(2000) - self.com_x_samples.append(self.com_x.read()) - self.com_y_samples.append(self.com_y.read()) + self.source.waitNext(2000) + centroid = get_centroid(self.source) + if centroid is not None: + self.com_x_samples.append(centroid[0]) + self.com_y_samples.append(centroid[1]) def setNumberOfImages(self, value): self.num_images = value @@ -84,7 +87,7 @@ if __name__ == "__builtin__": add_device(ImageStats("image_stats", image), True) image_stats.enableBackground(False) for i in range (100): - imagestats.update() - print camera_tool.take(), camera_tool.com_x.read(), camera_tool.com_y.read() + image_stats.update() + print camera_tool.take(), camera_tool.com_x_mean.read(), camera_tool.com_y_mean.read()