From 70a11a6e3966abe6bc936f86fcfdf12ef3b0a8c2 Mon Sep 17 00:00:00 2001 From: gac-S_Changer Date: Thu, 14 Jun 2018 17:33:20 +0200 Subject: [PATCH] --- config/plugins.properties | 2 + devices/img.properties | 20 +-- devices/led_ctrl_1.properties | 4 +- devices/led_ctrl_2.properties | 4 +- devices/led_ctrl_3.properties | 4 +- plugins/Hexiposi.form | 34 +++++ plugins/Hexiposi.java | 78 +++++++++++ plugins/LN2.form | 34 +++++ plugins/LN2.java | 78 +++++++++++ plugins/MXSC-1.10.0.jar | Bin 79211 -> 79151 bytes script/devices/RobotSC.py | 4 +- script/devices/Wago.py | 7 +- script/imgproc/CameraCalibration.py | 148 +++++++++++++++----- script/imgproc/CameraCalibration2.py | 136 ------------------ script/imgproc/CoverDetection.py | 137 +++++++----------- script/imgproc/CoverDetection2.py | 77 ---------- script/imgproc/LedDetectionProc.py | 4 +- script/imgproc/Utils.py | 2 +- script/local.py | 6 + script/motion/tools.py | 7 + script/test/CameraCalibration.py | 71 ++++++++++ script/test/CoverDetection.py | 116 +++++++++++++++ script/{imgproc => test}/PuckDetection.py | 0 script/{imgproc => test}/SampleDetection.py | 0 script/test/TestCoverDetection.py | 2 +- 25 files changed, 612 insertions(+), 363 deletions(-) create mode 100644 plugins/Hexiposi.form create mode 100644 plugins/Hexiposi.java create mode 100644 plugins/LN2.form create mode 100644 plugins/LN2.java delete mode 100644 script/imgproc/CameraCalibration2.py delete mode 100644 script/imgproc/CoverDetection2.py create mode 100644 script/test/CameraCalibration.py create mode 100644 script/test/CoverDetection.py rename script/{imgproc => test}/PuckDetection.py (100%) rename script/{imgproc => test}/SampleDetection.py (100%) diff --git a/config/plugins.properties b/config/plugins.properties index ef1ef6c..976e538 100644 --- a/config/plugins.properties +++ b/config/plugins.properties @@ -1,4 +1,6 @@ MXSC-1.10.0.jar=enabled +LN2.java=enabled +Hexiposi.java=enabled NewJPanel.java=disabled Expert.java=disabled RobotPanel.java=enabled diff --git a/devices/img.properties b/devices/img.properties index b95a012..cb23248 100644 --- a/devices/img.properties +++ b/devices/img.properties @@ -1,4 +1,4 @@ -#Mon May 07 14:51:31 CEST 2018 +#Thu Jun 14 10:54:07 CEST 2018 colormap=Grayscale colormapAutomatic=false colormapMax=18.133 @@ -9,16 +9,16 @@ grayscale=false invert=false rescaleFactor=1.0 rescaleOffset=0.0 -roiHeight=867 -roiWidth=875 -roiX=65 -roiY=55 -rotation=17.927919762007235 +roiHeight=872 +roiWidth=869 +roiX=74 +roiY=0 +rotation=17.93079800677477 rotationCrop=true scale=1.0 -spatialCalOffsetX=-438.0 -spatialCalOffsetY=-434.0 -spatialCalScaleX=0.5371114316839612 -spatialCalScaleY=0.5416192705243328 +spatialCalOffsetX=-435.0 +spatialCalOffsetY=-436.0 +spatialCalScaleX=0.540300793168967 +spatialCalScaleY=0.5385447475747382 spatialCalUnits=mm transpose=false diff --git a/devices/led_ctrl_1.properties b/devices/led_ctrl_1.properties index 8019e7b..c6fe6fa 100644 --- a/devices/led_ctrl_1.properties +++ b/devices/led_ctrl_1.properties @@ -1,5 +1,5 @@ -#Wed Jun 13 09:47:55 CEST 2018 -maxValue=1.2 +#Thu Jun 14 15:23:57 CEST 2018 +maxValue=1.0 minValue=0.0 offset=0.0 precision=2 diff --git a/devices/led_ctrl_2.properties b/devices/led_ctrl_2.properties index 8019e7b..c6fe6fa 100644 --- a/devices/led_ctrl_2.properties +++ b/devices/led_ctrl_2.properties @@ -1,5 +1,5 @@ -#Wed Jun 13 09:47:55 CEST 2018 -maxValue=1.2 +#Thu Jun 14 15:23:57 CEST 2018 +maxValue=1.0 minValue=0.0 offset=0.0 precision=2 diff --git a/devices/led_ctrl_3.properties b/devices/led_ctrl_3.properties index 8019e7b..c6fe6fa 100644 --- a/devices/led_ctrl_3.properties +++ b/devices/led_ctrl_3.properties @@ -1,5 +1,5 @@ -#Wed Jun 13 09:47:55 CEST 2018 -maxValue=1.2 +#Thu Jun 14 15:23:57 CEST 2018 +maxValue=1.0 minValue=0.0 offset=0.0 precision=2 diff --git a/plugins/Hexiposi.form b/plugins/Hexiposi.form new file mode 100644 index 0000000..4687d34 --- /dev/null +++ b/plugins/Hexiposi.form @@ -0,0 +1,34 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/plugins/Hexiposi.java b/plugins/Hexiposi.java new file mode 100644 index 0000000..f4f8a21 --- /dev/null +++ b/plugins/Hexiposi.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2014-2018 Paul Scherrer Institute. All rights reserved. + */ + +import ch.psi.pshell.core.Context; +import ch.psi.pshell.swing.StripChart; +import ch.psi.pshell.ui.App; +import ch.psi.pshell.ui.Panel; +import ch.psi.utils.State; +import java.io.File; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * + */ +public class Hexiposi extends Panel { + final StripChart stripChart; + public Hexiposi() { + initComponents(); + stripChart = new StripChart(this.getTopLevel(), false, App.getStripChartFolderArg()); + panel.add(stripChart.getPlotPanel()); + + try { + stripChart.open(new File(Context.getInstance().getSetup().expandPath("{home}/stripchart/hexiposi_positon.scd"))); + stripChart.start(); + } catch (Exception ex) { + showException(ex); + Logger.getLogger(Hexiposi.class.getName()).log(Level.WARNING, null, ex); + } + + } + + //Overridable callbacks + @Override + public void onInitialize(int runCount) { + + } + + @Override + public void onStateChange(State state, State former) { + + } + + @Override + public void onExecutedFile(String fileName, Object result) { + } + + + //Callback to perform update - in event thread + @Override + protected void doUpdate() { + } + + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + panel = new javax.swing.JPanel(); + + panel.setLayout(new java.awt.BorderLayout()); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(panel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(panel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + ); + }// //GEN-END:initComponents + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel panel; + // End of variables declaration//GEN-END:variables +} diff --git a/plugins/LN2.form b/plugins/LN2.form new file mode 100644 index 0000000..4687d34 --- /dev/null +++ b/plugins/LN2.form @@ -0,0 +1,34 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/plugins/LN2.java b/plugins/LN2.java new file mode 100644 index 0000000..20360f7 --- /dev/null +++ b/plugins/LN2.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2014-2018 Paul Scherrer Institute. All rights reserved. + */ + +import ch.psi.pshell.core.Context; +import ch.psi.pshell.swing.StripChart; +import ch.psi.pshell.ui.App; +import ch.psi.pshell.ui.Panel; +import ch.psi.utils.State; +import java.io.File; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * + */ +public class LN2 extends Panel { + final StripChart stripChart; + public LN2() { + initComponents(); + stripChart = new StripChart(this.getTopLevel(), false, App.getStripChartFolderArg()); + panel.add(stripChart.getPlotPanel()); + + try { + stripChart.open(new File(Context.getInstance().getSetup().expandPath("{home}/stripchart/LN2_Monitoring.scd"))); + stripChart.start(); + } catch (Exception ex) { + showException(ex); + Logger.getLogger(LN2.class.getName()).log(Level.WARNING, null, ex); + } + + } + + //Overridable callbacks + @Override + public void onInitialize(int runCount) { + + } + + @Override + public void onStateChange(State state, State former) { + + } + + @Override + public void onExecutedFile(String fileName, Object result) { + } + + + //Callback to perform update - in event thread + @Override + protected void doUpdate() { + } + + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + panel = new javax.swing.JPanel(); + + panel.setLayout(new java.awt.BorderLayout()); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(panel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(panel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + ); + }// //GEN-END:initComponents + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel panel; + // End of variables declaration//GEN-END:variables +} diff --git a/plugins/MXSC-1.10.0.jar b/plugins/MXSC-1.10.0.jar index 18676db44133dc77fce78d22215a7accdac0aec3..f4abe15f1f00f1e8b494f951e487cd44a2871021 100644 GIT binary patch delta 5451 zcmZWtWk8he(&kxWkp_`&7J-GOJ6}M$VL=)T>5@Sarq(Kdecjz?Lsee;I$x^%~~@_bDqMpxqk z25&Q3*GE1PNcL>x~|6u_VTWNM&EQy!)XUs?{fF>SSu8=yDmO(Z96fTO}eE6)z=A| z6}tIIoe>eYciMkU(rUsckZa%CPpp%YshT{=2eLsjDzO~f@dYa(fMe5~g-GYXckH#Z_dI;Sq3RGy(+ zM$d_WWN_pY^51dJ^Kc|eU+#)2=_uCp_3RSC*NbC>x7=1NIDnX|SV@&?o+N9ePg`lJ zCdxJIvpYeFVndW@vvWSF-Te~5F21sm7$0ux#$;6uXO>i`1HRP7(CEEgT`WVA&9JQ* z-*f_-_PKE1x-q2+6Uh)4b7-fk<|uo3^okBqQ^&2%7X*7x+Cf(I{*{t$hOe@hX1LO= z1()@}7co|ZC>Np=@5J2San|os>z*N6T=a-)v?K^rq-!zC+R$Fd7l3SlMV8gkQ$)f_ z45#n4`?uhk6ekA|2lwlREiR*J5#^$1a_oc=Dpa41hib|s>8)o!e#e(*{LJ1-OvqOw z8JIs!#zT^rsFl;f*4L4CA-S?hWe@givCqueb%xFCjXz*Cy(zal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zYY`F9~@Ny0+L$pn)b+Ahie1x11K$C`E|U5241S029#c2ogKOf>Mzt z92&z7q{IgA*+CHjk#7?871T#*!ofmq6Er(&SBkKXf(*b0?4rzN03Bcem4EhHM6JjG z79fU8C}jv>L=0vGG8q9@R0RZ}Iy>QlH2*n8v_z+;a$tZ6rfIG&u4||z33mu|@s>2! z2SAL(NIHOthUx!golvw;fd33a!~TB?sIvkqDg_LXq5PqM5HS27;{xi#ncEH}48g{W XqJsh~XSoX~N?CxD^dDZr?(xdata[-1]-5): - #del peaks[0 if ydata[right] > ydata[left] else -1] - peaks.remove(right if ydata[right] > ydata[left] else left) - -peaks = sorted(peaks[:3]) peaks_x = map(lambda x:xdata[x], peaks) peaks_y = map(lambda x:ydata[x], peaks) +confidence = None if len(peaks_x)<2 else int(((float(peaks_y[0])/peaks_y[1])-1) * 1000) +angle = (None if len(peaks_x)==0 else peaks_x[0]) + +#From angle and confidence level estimate hexiposi position +position = None +if angle is not None: + for i in range(len(POSITION_NAMES)): + if abs(POSITION_ANGLES[i] - angle) <= POSITION_TOLERANCE: + position = POSITION_NAMES[i] -print "Peaks", peaks -print "Peak indexes: " + str(peaks_x) -print "Peak values: " + str(peaks_y) +#Plot the correlations values agains angle +if DEBUG: + p = plot(ydata, xdata=xdata)[0] +#Output results +if DEBUG: + print "Peaks", peaks + print "Peak indexes: " + str(peaks_x) + print "Peak values: " + str(peaks_y) + print "Angle: " , angle + print "Position: " , position + print "Confidence: " , confidence -for i in range(len(peaks)): - peak = xdata[peaks[i]] - p.addMarker(peak, None, "N="+str(round(peak,2)), Color(80,0,80)) - if ((peaks[i]>160) and (REF[i]<20)): - peaks[i] = peaks[i] - 180.0 +#Set return value +set_return ([position, angle, confidence]) -print "Peaks x: " + str(peaks_x) - - -d = mean(arrabs(arrsub(REF, peaks_x))) - -print "Angle = ", d \ No newline at end of file diff --git a/script/imgproc/CoverDetection2.py b/script/imgproc/CoverDetection2.py deleted file mode 100644 index 315911e..0000000 --- a/script/imgproc/CoverDetection2.py +++ /dev/null @@ -1,77 +0,0 @@ -################################################################################################### -# Procedure to detect the cover orientation -################################################################################################### - -#Parameters -FRAMES_INTEGRATION = 3 -STEP_SIZE = 2 -POSITION_NAMES = [ 'A','B','C','D', 'E', 'F'] -POSITION_ANGLES = [330, 30, 90, 150, 210, 270] -POSITION_TOLERANCE = 3 -MINIMUM_CONFIDENCE = 10 -DEBUG = cover_detection_debug -REFERENCE_IMG = "ref2" - -#Load reference image -ref = load_image(str("{images}/cover/" + REFERENCE_IMG + ".png") , title="Line") - -#Pre-process camera image -#ip = load_image("{images}/cover/Cover_000" + str(index) + ".png", title="Img") -ip = integrate_frames(FRAMES_INTEGRATION) -ip = grayscale(ip, True) -smooth(ip) -#bandpass_filter(ip, 30, 1000) -edges(ip) -auto_threshold(ip, method = "MaxEntropy") -cx,cy = int(ip.width/2), int(ip.height/2) -ip = sub_image(ip, cx-ref.width/2, cy-ref.height/2, ref.width, ref.height) - -#Show ROI of pre-processed image -if DEBUG: - image_panel = show_panel(ip.bufferedImage) - - -#Calculate correlation between image and reference, rotating the reference from 0 to 360 -import ch.psi.pshell.imaging.Utils.integrateVertically as integrateVertically -ydata = [] -xdata = range (0,360,STEP_SIZE) -for i in xdata: - r = ref.duplicate() - r.getProcessor().setBackgroundValue(0.0) - r.getProcessor().rotate(float(i)) - op = op_fft(r, ip, "correlate") - bi = op.getBufferedImage() - p = integrateVertically(bi) - ydata.append(sum(p)) - - -#Calculate angle of the highest correlation, and confidence level -peaks = estimate_peak_indexes(ydata, xdata, (min(ydata) + max(ydata))/2, 25.0) -peaks_x = map(lambda x:xdata[x], peaks) -peaks_y = map(lambda x:ydata[x], peaks) -confidence = None if len(peaks_x)<2 else int(((float(peaks_y[0])/peaks_y[1])-1) * 1000) -angle = (None if len(peaks_x)==0 else peaks_x[0]) - -#From angle and confidence level estimate hexiposi position -position = None -if angle is not None: - for i in range(len(POSITION_NAMES)): - if abs(POSITION_ANGLES[i] - angle) <= POSITION_TOLERANCE: - position = POSITION_NAMES[i] - -#Plot the correlations values agains angle -if DEBUG: - p = plot(ydata, xdata=xdata)[0] - -#Output results -if DEBUG: - print "Peaks", peaks - print "Peak indexes: " + str(peaks_x) - print "Peak values: " + str(peaks_y) - print "Angle: " , angle - print "Position: " , position - print "Confidence: " , confidence - -#Set return value -set_return ([position, angle, confidence]) - diff --git a/script/imgproc/LedDetectionProc.py b/script/imgproc/LedDetectionProc.py index 3730c23..39c628c 100644 --- a/script/imgproc/LedDetectionProc.py +++ b/script/imgproc/LedDetectionProc.py @@ -3,7 +3,7 @@ ################################################################################################### COVER_PRESENT = True -ROOM_TEMP = False +ROOM_TEMP = is_room_temp() if get_exec_pars().source == CommandSource.ui: PLOT = None @@ -41,11 +41,13 @@ time.sleep(led_latency) img.waitNext(2000) background = average_frames(number_backgrounds) +#background = integrate_frames(number_backgrounds) set_led_state(True) time.sleep(led_latency) img.waitNext(2000) image = average_frames(number_frames) +#image = integrate_frames(number_frames) set_led_state(False) diff --git a/script/imgproc/Utils.py b/script/imgproc/Utils.py index cf7b7f5..c5ed223 100644 --- a/script/imgproc/Utils.py +++ b/script/imgproc/Utils.py @@ -12,7 +12,7 @@ import java.awt.Rectangle as Rectangle def get_img_cover_pos(): - [position, angle, confidence] = run("imgproc/CoverDetection2") + [position, angle, confidence] = run("imgproc/CoverDetection") return position def assert_img_in_cover_pos(pos = None): diff --git a/script/local.py b/script/local.py index 26fc1a7..8e7a0a0 100644 --- a/script/local.py +++ b/script/local.py @@ -69,6 +69,12 @@ def check_puck_detection(): def stop_puck_detection(): run("tools/StopPuckDetection") +DEWAR_LEVEL_RT = 5.0 + +def is_room_temp(): + return dewar_level.read() <= DEWAR_LEVEL_RT + + ################################################################################################### # Device initialization ################################################################################################### diff --git a/script/motion/tools.py b/script/motion/tools.py index bc2eac4..e2215c7 100644 --- a/script/motion/tools.py +++ b/script/motion/tools.py @@ -40,6 +40,13 @@ def set_hexiposi(pos, force = False): else: hexiposi.move(pos) +#Can be used if cover has following error (no checking readback) +def _set_hexiposi(pos): + hexiposi.moveAsync(pos) + time.sleep(1.0) + hexiposi.waitReady(-1) + + def visual_check_hexiposi(segment): #if robot.working_mode == "manual" ? if hexiposi.moved: diff --git a/script/test/CameraCalibration.py b/script/test/CameraCalibration.py new file mode 100644 index 0000000..02e7d9d --- /dev/null +++ b/script/test/CameraCalibration.py @@ -0,0 +1,71 @@ +import ch.psi.pshell.device.Camera as Camera +import ch.psi.pshell.imaging.RendererMode as RendererMode +from ch.psi.pshell.imaging.Overlays import * + +""" +img.camera.setColorMode(Camera.ColorMode.Mono) +img.camera.setDataType(Camera.DataType.UInt8) +img.camera.setGrabMode(Camera.GrabMode.Continuous) +img.camera.setTriggerMode(Camera.TriggerMode.Fixed_Rate) +img.camera.setExposure(50.00) +img.camera.setAcquirePeriod(200.00) +img.camera.setGain(0.0) +img.config.rotationCrop=True + + +""" +#img.camera.setROI(200, 0,1200,1200) + +img.camera.setROI(0, 0,1600,1200) +img.config.rotation=0 +img.config.roiX,img.config.roiY, img.config.roiWidth,img.config.roiHeight =0,0,-1,-1 +img.config.setCalibration(None) +img.camera.stop() +img.camera.start() + +#img.camera.setROI(300, 200,1000,1000) +#img.config.rotation=17 +#img.config.roiX,img.config.roiY, img.config.roiWidth,img.config.roiHeight = 50,50,900,900 + +p = show_panel(img) +p.setMode(RendererMode.Fit) +ov_text = Text(Pen(java.awt.Color.GREEN.darker()), "", java.awt.Font("Verdana", java.awt.Font.PLAIN, 24), java.awt.Point(20,20)) +ov_text.setFixed(True) + + + +p.addOverlay(ov_text) +try: + ov_text.update("Click on upper reference...") + p1 = p.waitClick(60000) + print p1 + ov_text.update("Click on left reference...") + p2 = p.waitClick(60000) + print p2 + ov_text.update("Click on right reference...") + p3 = p.waitClick(60000) + print p3 + + x, y, z = p1.x+p1.y*1j, p2.x+p2.y*1j, p3.x+p3.y*1j + w = z-x + w /= y-x + c = (x-y)*(w-abs(w)**2)/2j/w.imag-x + cx, cy, r = -c.real, -c.imag, abs(c+x) + a = math.degrees(math.atan((cx-p1.x)/(p1.y-cy))) + + print cx, cy, r, a + + #img.camera.setROI(int((1600-cx)/2),int((1200-cy)/2),1000,1000) + img.camera.setROI(int(cx-r),int(cy-r),int(2*r),int(2*r)) + img.config.rotation=-a + #remove rotation border + d=int(r/11) + img.config.roiX,img.config.roiY, img.config.roiWidth,img.config.roiHeight =d,d, int(2*r-2*d), int(2*r-2*d) + #img.config.setCalibration(None) + img.camera.stop() + img.camera.start() + +finally: + p.removeOverlay(ov_text) + + \ No newline at end of file diff --git a/script/test/CoverDetection.py b/script/test/CoverDetection.py new file mode 100644 index 0000000..24a228b --- /dev/null +++ b/script/test/CoverDetection.py @@ -0,0 +1,116 @@ +################################################################################################### +# Procedure to detect the cover orientation +################################################################################################### +import ch.psi.pshell.imaging.Utils.integrateVertically as integrateVertically +img.backgroundEnabled=False + +REF = (0,96,125) + +line = load_image("{images}/line.png", title="Line") +#line = load_image("{images}/line360.png", title="Line") + +line.getProcessor().setBackgroundValue(0.0) + + +#ip = get_image() +ip = integrate_frames(10) +ip = grayscale(ip, True) + + +smooth(ip) +#bandpass_filter(ip, 30, 1000) +edges(ip) + +#invert(ip) +#auto_threshold(ip, method = "Default") + + +#auto_threshold(ip, method = "Li") +auto_threshold(ip, method = "MaxEntropy") + +""" +for m in AutoThresholder.getMethods(): + print m + aux = ip.duplicate() + auto_threshold(aux, method = m) + binary_fill_holes(aux, dark_background=False) + renderer = show_panel(aux.bufferedImage) + time.sleep(1.0) +""" +#binary_dilate(ip, dark_background=False) +#binary_fill_holes(ip, dark_background=False) +#binary_open(ip, dark_background=Tr) + +renderer = show_panel(ip.bufferedImage) + + + + + + + + +#line = sub_image(line, 325, 325, 512, 512) +#ip = sub_image(ip, 325, 325, 512, 512) +line = sub_image(line, 453, 453, 256, 256) +ip = sub_image(ip, 453, 453, 256, 256) +#op = op_fft(ip, line, "correlate") + + +renderer = show_panel(ip.bufferedImage) + +#renderer = show_panel(op.bufferedImage) +#line.show() +ydata = [] +xdata = range (0,180,1) +for i in xdata: + l = line.duplicate() + l.getProcessor().setBackgroundValue(0.0) + l.getProcessor().rotate(float(i)) + op = op_fft(ip, l, "correlate") + bi = op.getBufferedImage() + p = integrateVertically(bi) + ydata.append(sum(p)) + + #renderer = show_panel(op.bufferedImage) + #time.sleep(0.001) + +def moving_average(arr, n) : + ret = [] + for i in range(len(arr)): + ret.append(mean(arr[max(i-n,0):min(i+n,len(arr)-1)])) + return ret +av = moving_average(ydata, 1) + +p = plot(ydata, xdata=xdata)[0] + +p.addSeries(LinePlotSeries("Moving Average")) +p.getSeries(1).setData(xdata, av) + +peaks = estimate_peak_indexes(ydata, xdata, (min(ydata) + max(ydata))/2, 25.0) +left, right = min(peaks), max(peaks) +if xdata[left]<5 and xdata[right]>(xdata[-1]-5): + #del peaks[0 if ydata[right] > ydata[left] else -1] + peaks.remove(right if ydata[right] > ydata[left] else left) + +peaks = sorted(peaks[:3]) +peaks_x = map(lambda x:xdata[x], peaks) +peaks_y = map(lambda x:ydata[x], peaks) + +print "Peaks", peaks +print "Peak indexes: " + str(peaks_x) +print "Peak values: " + str(peaks_y) + + +for i in range(len(peaks)): + peak = xdata[peaks[i]] + p.addMarker(peak, None, "N="+str(round(peak,2)), Color(80,0,80)) + if ((peaks[i]>160) and (REF[i]<20)): + peaks[i] = peaks[i] - 180.0 + +print "Peaks x: " + str(peaks_x) + + +d = mean(arrabs(arrsub(REF, peaks_x))) + +print "Angle = ", d \ No newline at end of file diff --git a/script/imgproc/PuckDetection.py b/script/test/PuckDetection.py similarity index 100% rename from script/imgproc/PuckDetection.py rename to script/test/PuckDetection.py diff --git a/script/imgproc/SampleDetection.py b/script/test/SampleDetection.py similarity index 100% rename from script/imgproc/SampleDetection.py rename to script/test/SampleDetection.py diff --git a/script/test/TestCoverDetection.py b/script/test/TestCoverDetection.py index d65da21..e21e2c0 100644 --- a/script/test/TestCoverDetection.py +++ b/script/test/TestCoverDetection.py @@ -7,7 +7,7 @@ pa = [] #index = i+1 for i in ['A', 'B', 'C', 'D', 'E', 'F']: hexiposi.move(i) - [position, angle, confidence] = run("imgproc/CoverDetection2") + [position, angle, confidence] = run("imgproc/CoverDetection") print [position, angle, confidence] pa.append(position) aa.append(angle)