From c08dea4f6f72ae0bcccab7d2f2e4f6133d020d5c Mon Sep 17 00:00:00 2001 From: gac-S_Changer Date: Wed, 21 Jun 2017 17:18:10 +0200 Subject: [PATCH] Script execution --- script/LedDetectionProc.py | 62 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 2 deletions(-) diff --git a/script/LedDetectionProc.py b/script/LedDetectionProc.py index 5529a67..f89d7f2 100644 --- a/script/LedDetectionProc.py +++ b/script/LedDetectionProc.py @@ -1,5 +1,63 @@ run ("LedDetection") -ip = load_image(img.image) -(results,output) = detect_led(ip) \ No newline at end of file +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 + + + +