This commit is contained in:
@@ -11,10 +11,11 @@ class CoverDetectionConfig(RegisterConfig):
|
||||
self.center_y = 570.0
|
||||
self.scale_x = 1.0
|
||||
self.scale_y = 1.0
|
||||
self.rotation_degrees = 0.0
|
||||
self.correlation_threshold = 0.60
|
||||
self.diameter_target=95
|
||||
self.diamter_disk=670
|
||||
self.diamter_dewar=1800
|
||||
self.diameter_disk=670
|
||||
self.diameter_dewar=1800
|
||||
self.size_mask_disk=0.8
|
||||
self.size_mask_dewar=0.98
|
||||
self.max_detect_offset=10
|
||||
@@ -106,7 +107,7 @@ class CoverDetection(ReadonlyAsyncRegisterBase, ReadonlyRegisterArray):
|
||||
self.error = None
|
||||
center = (self.config.center_x, self.config.center_y)
|
||||
x,y = detect(ip, center, \
|
||||
diam_target=self.config.diameter_target, diam_disk= self.config.diamter_disk, diam_dewar=self.config.diamter_dewar, \
|
||||
diam_target=self.config.diameter_target, diam_disk= self.config.diameter_disk, diam_dewar=self.config.diameter_dewar, \
|
||||
mask_disk=self.config.size_mask_disk, mask_dewar=self.config.size_mask_dewar, \
|
||||
offset_threshold=self.config.max_detect_offset ,open_strategy= self.config.open_strategy)
|
||||
|
||||
@@ -131,6 +132,28 @@ class CoverDetection(ReadonlyAsyncRegisterBase, ReadonlyRegisterArray):
|
||||
|
||||
if not self.config.continuous:
|
||||
self.images=[]
|
||||
|
||||
def calculate_factors(self, x1, y1, x2, y2, mx1, my1, mx2, my2):
|
||||
dx = x2-x1
|
||||
dy = y2-y1
|
||||
dmx = mx2-mx1
|
||||
dmy = my2-my1
|
||||
sx = dmx/dx
|
||||
sy = dmy / dy
|
||||
tp=math.atan(dy/dx)
|
||||
tm=math.atan(dmy/dmx)
|
||||
t = tm - tp
|
||||
return sx, sy, math.degrees(t)
|
||||
|
||||
def pixel_to_millis(self, x, y):
|
||||
try:
|
||||
t = math.radians(self.config.rotation_degrees)
|
||||
offx, offy = x-self.config.center_x, y-self.config.center_y
|
||||
rx, ry = (offx * math.cos(t) + offy * math.sin(t)), (-offx * math.sin(t) + offy * math.cos(t))
|
||||
mx, my = self.config.scale_x*rx, self.config.scale_y*ry
|
||||
return round(mx,3), round(my,3)
|
||||
except:
|
||||
return float('nan'), float('nan')
|
||||
|
||||
def set(self, x, y, tm, error):
|
||||
if self.enabled:
|
||||
@@ -138,9 +161,9 @@ class CoverDetection(ReadonlyAsyncRegisterBase, ReadonlyRegisterArray):
|
||||
self.offset_px = self.offset_um = None
|
||||
value = None
|
||||
else:
|
||||
offx, offy = x-cover_detection.config.center_x, -(y-cover_detection.config.center_y)
|
||||
offx, offy = x-self.config.center_x, y-self.config.center_y
|
||||
self.offset_px = opx, opy = round(offx), round(offy)
|
||||
self.offset_um = omx, omy = self.config.scale_x * offx * 1000.0, self.config.scale_y * offy *1000.0
|
||||
self.offset_um = omx, omy = self.pixel_to_millis(x,y)
|
||||
value = to_array([x, y, opx, opy, omx, omy, tm], 'i')
|
||||
self.onReadout(value)
|
||||
if self.renderer is not None:
|
||||
|
||||
Reference in New Issue
Block a user