From 869e6a297931ffa2c791e10a532220eb2291706d Mon Sep 17 00:00:00 2001 From: gac-S_Changer Date: Wed, 21 Jun 2017 17:00:25 +0200 Subject: [PATCH] Closedown --- script/LedDetection.py | 72 +------------------------------------- script/LedDetectionProc.py | 2 ++ 2 files changed, 3 insertions(+), 71 deletions(-) diff --git a/script/LedDetection.py b/script/LedDetection.py index 7cc957d..e609d62 100644 --- a/script/LedDetection.py +++ b/script/LedDetection.py @@ -11,16 +11,6 @@ from ch.psi.pshell.imaging.Overlays import * import ch.psi.pshell.imaging.Pen as Pen -""" -def detect_led(ip): - aux = grayscale(ip, in_place=False) - threshold(aux,0,50) - binary_fill_holes(aux) - return analyse_particles(aux, 10000,50000, - fill_holes = False, exclude_edges = True,print_table=True, - output_image = "outlines", minCirc = 0.4, maxCirc = 1.0) -""" - roi_center = (800, 600) roi_radius = 600 integration_count = 10 @@ -41,42 +31,6 @@ ov_roi_center = Crosshairs(Pen(color_roi, 0), java.awt.Point(roi_center[0],roi_ renderer.addOverlays([ov_roi_shape, ov_roi_bound,ov_roi_center]) - -""" -def in_roi(x,y): - global roi_center, roi_radius - return math.hypot(x-roi_center[0], y-roi_center[1]) < roi_radius - -def detect_led(ip): - aux = grayscale(ip, in_place=False) - invert(aux) - #subtract_background(aux) - auto_threshold(aux) - binary_open(aux) - (results,output) = analyse_particles(aux, 800,4000, - fill_holes = True, exclude_edges = True,print_table=False, - output_image = "outlines", minCirc = 0.4 - , maxCirc = 1.0) - r=results - print "\n" - print r.getColumnHeadings() - for row in range (r.counter): - if in_roi(r.getValue("XM",row), r.getValue("YM",row)): - print r.getRowAsString(row) - else: - #print >> sys.stderr, 'Invalid location:' + str(r.getValue("XM", row)) + ", " + str( r.getValue("YM", row)) - print >> sys.stderr, r.getRowAsString(row) - return (results,output) - -class MyFilter(Filter): - def process(self, image, data): - ip = load_image(image) - (results,output) = detect_led(ip) - invert(output) - op_image(ip, output, "xor") - return ip.getBufferedImage() - -""" def in_roi(x,y): return math.hypot(x-roi_radius, y-roi_radius) < roi_radius @@ -125,16 +79,7 @@ def detect_led(ip): , maxCirc = 1.0) r=results - """ - print "\n" - print r.getColumnHeadings() - for row in range (r.counter): - if in_roi(r.getValue("XM",row), r.getValue("YM",row)): - print r.getRowAsString(row) - else: - #print >> sys.stderr, 'Invalid location:' + str(r.getValue("XM", row)) + ", " + str( r.getValue("YM", row)) - print >> sys.stderr, r.getRowAsString(row) - """ + points = "" npoints = 0 for row in range (r.counter): @@ -156,19 +101,4 @@ def detect_led(ip): -ip = None - -class MyFilter(Filter): - def process(self, image, data): - global roi_center, roi_radius, ip - ip = load_image(image) - (results,output) = detect_led(ip) - if output is not None: - invert(output) - output = pad_image(output, roi[0], 0,roi[1], 0) - op_image(ip, output, "xor") - return ip.getBufferedImage() - -#Setting the filter to a source -img.setFilter(MyFilter()) diff --git a/script/LedDetectionProc.py b/script/LedDetectionProc.py index 992c6e7..2e896cc 100644 --- a/script/LedDetectionProc.py +++ b/script/LedDetectionProc.py @@ -1,3 +1,5 @@ run ("LedDetection") +ip = load_image(img.getImage()) +(results,output) = detect_led(ip) \ No newline at end of file