From b7d54a5e995ac5f3e6e1949407e7e1b988287283 Mon Sep 17 00:00:00 2001 From: gac-S_Changer Date: Fri, 23 Jun 2017 15:35:03 +0200 Subject: [PATCH] Script execution --- script/CoverDetection.py | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/script/CoverDetection.py b/script/CoverDetection.py index 6717cb4..2ca860b 100644 --- a/script/CoverDetection.py +++ b/script/CoverDetection.py @@ -8,13 +8,11 @@ line = load_image("{images}/line.png", title="Line") line.getProcessor().setBackgroundValue(0.0) -#renderer = show_panel(line.bufferedImage) + #ip = get_image() - ip = integrate_frames(10) +ip = grayscale(ip, True) -#ip = grayscale(ip, True) -show_panel(ip.bufferedImage) smooth(ip) #bandpass_filter(ip, 30, 1000) @@ -58,7 +56,6 @@ renderer = show_panel(ip.bufferedImage) #renderer = show_panel(op.bufferedImage) #line.show() -""" vals = [] for i in range (180): l = line.duplicate() @@ -71,8 +68,31 @@ for i in range (180): #renderer = show_panel(op.bufferedImage) #time.sleep(0.001) -plot(vals) -""" +p = plot(vals)[0] + + + +threshold = (min(vals) + max(vals))/2 +min_peak_distance = 10.0 +xdata=Arr.indexesInt(len(vals)) + +peaks = estimate_peak_indexes(vals, xdata, threshold, min_peak_distance) +print "Peak indexes: " + str(peaks) +print "Peak x: " + str(map(lambda x:xdata[x], peaks)) +print "Peak y: " + str(map(lambda x:vals[x], peaks)) + +gaussians = fit_gaussians(vals, xdata, peaks) + +for i in range(len(peaks)): + peak = peaks[i] + (normalization, mean_val, sigma) = gaussians[i] + if abs(mean_val - xdata[peak]) < min_peak_distance: + print "Peak -> " + str(mean_val) + p.addMarker(mean_val, None, "N="+str(round(normalization,2)), Color(210,0,0)) + else: + print "Invalid gaussian fit: " + str(mean_val) + + #image_fft(ip)