Script execution
This commit is contained in:
@@ -1,25 +1,86 @@
|
||||
###################################################################################################
|
||||
# Deployment specific global definitions - executed after startup.py
|
||||
###################################################################################################
|
||||
|
||||
|
||||
from ch.psi.pshell.serial import TcpDevice
|
||||
from ch.psi.pshell.modbus import ModbusTCP
|
||||
|
||||
|
||||
###################################################################################################
|
||||
# Scripted devices
|
||||
###################################################################################################
|
||||
|
||||
|
||||
run("RobotSC")
|
||||
#run("RobotModbus")
|
||||
|
||||
#run("OneWire")
|
||||
|
||||
|
||||
#Raspberry login: usr=pi pwd=Buntschu
|
||||
|
||||
|
||||
add_device(img.getContrast(), force = True)
|
||||
add_device(img.getCamera(), force = True)
|
||||
|
||||
|
||||
#TODO: The range should be set automatically reading LN2 sensor.
|
||||
def set_led_range(room_temp = True):
|
||||
led_ctrl.config.maxValue = 0.40 if room_temp else 1.20
|
||||
led_ctrl.config.save()
|
||||
|
||||
|
||||
|
||||
###################################################################################################
|
||||
# Image processing utilities
|
||||
###################################################################################################
|
||||
|
||||
|
||||
from ijutils import *
|
||||
from ch.psi.pshell.imaging.Overlays import *
|
||||
import ch.psi.pshell.imaging.Pen as Pen
|
||||
|
||||
def in_roi(x,y):
|
||||
return math.hypot(x-roi_radius, y-roi_radius) < roi_radius
|
||||
|
||||
|
||||
def integrate(ips):
|
||||
aux = None
|
||||
for i in range(len(ips)):
|
||||
if i==0:
|
||||
aux = new_image(roi[2], roi[3], image_type="float", title = "sum", fill_color = None)
|
||||
op_image(aux, ips[i], "add", float_result=True, in_place=True)
|
||||
return aux
|
||||
|
||||
def average (ips):
|
||||
aux = integrate(ips)
|
||||
op_const(aux, "divide", len(ips), in_place=True)
|
||||
return aux
|
||||
|
||||
def grab_frames(samples):
|
||||
frames = []
|
||||
for i in range(samples):
|
||||
aux = get_image()
|
||||
grayscale(aux)
|
||||
frames.append(aux)
|
||||
return frames
|
||||
|
||||
def average_frames(samples = 1):
|
||||
return average(grab_frames(samples))
|
||||
|
||||
def integrate_frames(samples = 1):
|
||||
return integrate(grab_frames(samples))
|
||||
|
||||
|
||||
roi_center = (800, 600)
|
||||
roi_radius = 600
|
||||
|
||||
def get_roi():
|
||||
return (roi_center[0] - roi_radius, roi_center[1] - roi_radius, 2* roi_radius, 2*roi_radius)
|
||||
|
||||
|
||||
def get_image():
|
||||
ip = load_image(img.image)
|
||||
return sub_image(ip, roi[0], roi[1], roi[2], roi[3])
|
||||
|
||||
|
||||
|
||||
def detect_pucks(ip):
|
||||
"""
|
||||
@@ -54,6 +115,9 @@ g[0]=0x80;r[0]=0x80;
|
||||
g[1]=0xFF ; r[1] = 0x80; b[1] = 0x80
|
||||
outline_lut2 = (r,g,b)
|
||||
|
||||
###################################################################################################
|
||||
# Math utilities
|
||||
###################################################################################################
|
||||
|
||||
|
||||
from mathutils import estimate_peak_indexes, fit_gaussians, create_fit_point_list, Gaussian
|
||||
@@ -115,10 +179,6 @@ def fit(ydata, xdata = None, draw_plot = True):
|
||||
context = get_context()
|
||||
|
||||
|
||||
#TODO: The range should be set automatically reading LN2 sensor.
|
||||
def set_led_range(room_temp = True):
|
||||
led_ctrl.config.maxValue = 0.40 if room_temp else 1.20
|
||||
led_ctrl.config.save()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user