From b085789df2b0aadbc66228ae7dadedb246784c7e Mon Sep 17 00:00:00 2001 From: gac-S_Changer Date: Fri, 23 Jun 2017 14:54:45 +0200 Subject: [PATCH] Closedown --- script/CoverDetection.py | 20 ++++++++++++-------- script/LedDetectionProc.py | 18 ++++++++++++++---- script/local.py | 7 ++++--- 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/script/CoverDetection.py b/script/CoverDetection.py index e047c3e..0e6f4b2 100644 --- a/script/CoverDetection.py +++ b/script/CoverDetection.py @@ -9,8 +9,9 @@ line = load_image("{images}/line.png", title="Line") line.getProcessor().setBackgroundValue(0.0) #renderer = show_panel(line.bufferedImage) -ip = get_image() - +#ip = get_image() +ip = average_frames(5) +ip =grayscale(ip) smooth(ip) #bandpass_filter(ip, 30, 1000) @@ -32,7 +33,7 @@ for m in AutoThresholder.getMethods(): renderer = show_panel(aux.bufferedImage) time.sleep(1.0) """ -#binary_fill_holes(ip, dark_background=True) +binary_dilate(ip, dark_background=False) #binary_fill_holes(ip, dark_background=False) #binary_open(ip, dark_background=Tr) @@ -45,13 +46,16 @@ renderer = show_panel(ip.bufferedImage) -line = sub_image(line, 89, 89, 1024, 1024) -ip = sub_image(ip, 89, 89, 1024, 1024) +line = sub_image(line, 325, 325, 512, 512) +ip = sub_image(ip, 325, 325, 512, 512) #op = op_fft(ip, line, "correlate") + +renderer = show_panel(ip.bufferedImage) + #renderer = show_panel(op.bufferedImage) #line.show() - +""" vals = [] for i in range (180): l = line.duplicate() @@ -64,8 +68,8 @@ for i in range (180): #renderer = show_panel(op.bufferedImage) #time.sleep(0.001) - - +plot(vals) +""" #image_fft(ip) diff --git a/script/LedDetectionProc.py b/script/LedDetectionProc.py index eca9e3f..8df5782 100644 --- a/script/LedDetectionProc.py +++ b/script/LedDetectionProc.py @@ -34,23 +34,33 @@ renderer.clearOverlays() invert(image) auto_threshold(image, method = "MaxEntropy") #Tested ok: MaxEntropy, Triangle, Yen #binary_open(aux) -(r,output) = analyse_particles(image, 250,1000, +(r,output) = analyse_particles(image, 150,1000, fill_holes = True, exclude_edges = False, print_table=False, output_image = "outlines", minCirc = 0.3 , maxCirc = 1.0) points = "" npoints = 0 +x=[] +y=[] for row in range (r.counter): if in_roi(r.getValue("XM",row), r.getValue("YM",row)): #x, y = int(r.getValue("XM", row))+roi[0], int(r.getValue("YM", row))+roi[1] - x, y = int(r.getValue("XM", row)), int(r.getValue("YM", row)) - points = points + " (" + str(x) + ", " + str(y) + ")" + x.append(int(r.getValue("XM", row))) + y.append(int(r.getValue("YM", row))) + points = points + " (" + str(x[-1]) + ", " + str(y[-1]) + ")" npoints = npoints + 1 - renderer.addOverlay(Crosshairs(Pen(java.awt.Color.MAGENTA), java.awt.Point(x,y), java.awt.Dimension(15,15))) + renderer.addOverlay(Crosshairs(Pen(java.awt.Color.MAGENTA), java.awt.Point(x[-1],y[-1]), java.awt.Dimension(15,15))) print str(npoints) + " - " + points print r + +print x +print y + +offset = int(math.sqrt(1000)/2) +cv = (min(x)-offset, min(y)-offset, max(x)+offset, max(y)+offset) +renderer.addOverlay(Rect(Pen(java.awt.Color.MAGENTA), java.awt.Point(cv[0], cv[1]), java.awt.Dimension(cv[2]-cv[0],cv[3]-cv[1]))) #show_panel(output.getBufferedImage()) #img.backgroundEnabled=False diff --git a/script/local.py b/script/local.py index d16b6a3..2fa1660 100644 --- a/script/local.py +++ b/script/local.py @@ -58,8 +58,7 @@ def average (ips): def grab_frames(samples): frames = [] for i in range(samples): - aux = get_image() - grayscale(aux) + aux = get_image() frames.append(aux) return frames @@ -80,7 +79,9 @@ def get_roi(): def get_image(): roi = get_roi() ip = load_image(img.image) - return sub_image(ip, roi[0], roi[1], roi[2], roi[3]) + ret = sub_image(ip, roi[0], roi[1], roi[2], roi[3]) + grayscale(ret) + return ret def detect_pucks(ip):