Script execution
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user