Script execution
This commit is contained in:
@@ -1,5 +1,63 @@
|
||||
run ("LedDetection")
|
||||
|
||||
|
||||
ip = load_image(img.image)
|
||||
(results,output) = detect_led(ip)
|
||||
def integrate (ips):
|
||||
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)
|
||||
op_const(aux, "divide", len(ips), in_place=True)
|
||||
return aux
|
||||
|
||||
|
||||
|
||||
def get_image(samples = 1):
|
||||
frames = []
|
||||
for i in range(samples):
|
||||
ip = load_image(img.image)
|
||||
aux = sub_image(ip, roi[0], roi[1], roi[2], roi[3])
|
||||
grayscale(aux)
|
||||
frames.append(aux)
|
||||
return integrate(frames)
|
||||
|
||||
|
||||
img.backgroundEnabled=False
|
||||
led_ctrl1.write(0.0)
|
||||
led_ctrl2.write(0.0)
|
||||
time.sleep(0.5)
|
||||
|
||||
background = get_image(5)
|
||||
|
||||
show_panel(background)
|
||||
|
||||
|
||||
img.background = background
|
||||
img.backgroundEnabled = True
|
||||
time.sleep(0.5)
|
||||
|
||||
|
||||
image = get_image(5)
|
||||
|
||||
|
||||
invert(aux)
|
||||
auto_threshold(aux, method = "Percentile")
|
||||
#binary_open(aux)
|
||||
(results,output) = analyse_particles(aux, 250,1000,
|
||||
fill_holes = True, exclude_edges = False, print_table=False,
|
||||
output_image = "outlines", minCirc = 0.3
|
||||
, maxCirc = 1.0)
|
||||
|
||||
points = ""
|
||||
npoints = 0
|
||||
for row in range (r.counter):
|
||||
if in_roi(r.getValue("XM",row), r.getValue("YM",row)):
|
||||
points = points + " (" + str(int(r.getValue("XM", row))+roi[0]) + ", " + str(int(r.getValue("YM", row))+roi[1]) + ")"
|
||||
npoints = npoints + 1
|
||||
print str(npoints) + " - " + points
|
||||
|
||||
|
||||
print results
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user