Script execution
This commit is contained in:
@@ -6,7 +6,7 @@ import java.awt.Color as Color
|
||||
import random
|
||||
import ch.psi.pshell.imaging.ImageListener as ImageListener
|
||||
from operator import add, mul, sub, truediv
|
||||
from ch.psi.pshell.imaging.Utils import *
|
||||
from ch.psi.pshell.imaging.Utils import sub
|
||||
|
||||
def arrmul(a, b):
|
||||
"""Multiply 2 series of the same size.
|
||||
@@ -111,8 +111,6 @@ class ImageStats(DeviceBase):
|
||||
class ComXVar(Readable):
|
||||
def read(self):
|
||||
if len(self.image_stats.com_x_samples)==0: return None
|
||||
print self.image_stats.com_x_samples
|
||||
print (stdev(self.image_stats.com_x_samples))
|
||||
return stdev(self.image_stats.com_x_samples)
|
||||
self.com_x_stdev = ComXVar(); self.com_x_stdev.image_stats = self
|
||||
class ComYVar(Readable):
|
||||
@@ -156,8 +154,8 @@ class ImageStats(DeviceBase):
|
||||
# self.com_y_samples.append(centroid[1])
|
||||
x_profile = self.source.data.integrateVertically(True)
|
||||
y_profile = self.source.data.integrateHorizontally(True)
|
||||
com_x,rms_x = center_of_mass(x_profile)
|
||||
com_y,rms_y = center_of_mass(y_profile)
|
||||
com_x,rms_x = center_of_mass(x_profile, self.source.data.getRowSelectionX(True))
|
||||
com_y,rms_y = center_of_mass(y_profile, self.source.data.getColSelectionX(True))
|
||||
self.com_x_samples.append(com_x)
|
||||
self.com_y_samples.append(com_y)
|
||||
self.rms_x_samples.append(rms_x)
|
||||
@@ -169,10 +167,11 @@ class ImageStats(DeviceBase):
|
||||
def enableBackground(self, value):
|
||||
self.bg_en = value
|
||||
class BackgroundSubtractor(Filter):
|
||||
def __init__(self, obj):
|
||||
self.obj=obj
|
||||
def process(self, image, data):
|
||||
image = sobel(image)
|
||||
return image
|
||||
self.source.filter = BackgroundSubtractor()
|
||||
return sub(image, obj.background, True) if (obj.background is not None) else None
|
||||
self.source.filter = BackgroundSubtractor() if (value==True) else None
|
||||
|
||||
def captureBackground(self, images):
|
||||
self.doInitialize()
|
||||
@@ -217,4 +216,4 @@ if __name__ == "__builtin__":
|
||||
|
||||
def before_sample():
|
||||
image_stats.update()
|
||||
tscan(sensors, 10, 1.0, before_read = before_sample)
|
||||
tscan(sensors, 10, 0.1, before_read = before_sample)
|
||||
|
||||
Reference in New Issue
Block a user