From 8c5ef4cfe1becc30f5aebada2ce69f4bd2392c30 Mon Sep 17 00:00:00 2001 From: gac-S_Changer Date: Tue, 27 Jun 2017 14:42:03 +0200 Subject: [PATCH] Script execution --- script/CoverDetection.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/script/CoverDetection.py b/script/CoverDetection.py index 3d13451..bb5b58a 100644 --- a/script/CoverDetection.py +++ b/script/CoverDetection.py @@ -69,10 +69,20 @@ for i in xdata: #renderer = show_panel(op.bufferedImage) #time.sleep(0.001) -p = plot(ydata,xdata=xdata)[0] +def moving_average(arr, n) : + ret = [] + for i in range(len(arr)): + ret.append(sum(arr[i-n:i+n])) + return ret +av = moving_average(ydata, 3) + +p = plot(ydata, xdata=xdata)[0] -peaks = estimate_peak_indexes(ydata, xdata, (min(ydata) + max(ydata))/2, 25.0) +s = p.addSeries("Moving Average") +s.setData(av, xdata) + +peaks = estimate_peak_indexes(ydata, xdata, (min(ydata) + max(ydata))/2, 35.0) print "Peak indexes: " + str(map(lambda x:xdata[x], peaks)) print "Peak values: " + str(map(lambda x:ydata[x], peaks))