This commit is contained in:
@@ -7,13 +7,12 @@ FRAMES_INTEGRATION = 3
|
||||
STEP_SIZE = 2
|
||||
POSITION_NAMES = [ 'A','B','C','D', 'E', 'F']
|
||||
POSITION_ANGLES = [330, 30, 90, 150, 210, 270]
|
||||
POSITION_TOLERANCE = 10
|
||||
POSITION_TOLERANCE = 3
|
||||
MINIMUM_CONFIDENCE = 10
|
||||
DEBUG = True
|
||||
PLOT = True
|
||||
REFERENCE_IMG = "ref2"
|
||||
|
||||
|
||||
#Load reference image
|
||||
ref = load_image(str("{images}/cover/" + REFERENCE_IMG + ".png") , title="Line")
|
||||
|
||||
@@ -31,6 +30,7 @@ ip = sub_image(ip, cx-ref.width/2, cy-ref.height/2, ref.width, ref.height)
|
||||
#Show ROI of pre-processed image
|
||||
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 = []
|
||||
@@ -39,12 +39,12 @@ for i in xdata:
|
||||
r = ref.duplicate()
|
||||
r.getProcessor().setBackgroundValue(0.0)
|
||||
r.getProcessor().rotate(float(i))
|
||||
op = op_fft(ip, r, "correlate")
|
||||
op = op_fft(r, ip, "correlate")
|
||||
bi = op.getBufferedImage()
|
||||
p = integrateVertically(bi)
|
||||
ydata.append(sum(p))
|
||||
#image_panel = show_panel(op.bufferedImage)
|
||||
#time.sleep(0.001)
|
||||
#time.sleep(1.0)
|
||||
|
||||
|
||||
#Calculate angle of the highest correlation, and confidence level
|
||||
@@ -72,7 +72,7 @@ if DEBUG:
|
||||
print "Peak values: " + str(peaks_y)
|
||||
print "Angle: " , angle
|
||||
print "Position: " , position
|
||||
print "Confifdence: " , confidence
|
||||
print "Confidence: " , confidence
|
||||
|
||||
#Set return value
|
||||
set_return ([position, angle, confidence])
|
||||
|
||||
@@ -51,10 +51,10 @@ set_led_state(False)
|
||||
|
||||
op_image(image, background, "subtract", float_result=True, in_place=True)
|
||||
|
||||
if RENDERER is None:
|
||||
if RENDERER is not None:
|
||||
RENDERER.setImage(None, image.getBufferedImage(), None)
|
||||
else:
|
||||
RENDERER = show_panel(image.getBufferedImage())
|
||||
else:
|
||||
RENDERER.setImage(None, image.getBufferedImage(), None)
|
||||
RENDERER.clearOverlays()
|
||||
|
||||
invert(image)
|
||||
@@ -73,15 +73,14 @@ for row in range (r.counter):
|
||||
x, y = int(r.getValue("XM", row)), int(r.getValue("YM", row))
|
||||
cx, cy = img.getCalibration().convertToAbsoluteX(x), img.getCalibration().convertToAbsoluteY(y)
|
||||
points.append([cx,cy])
|
||||
RENDERER.addOverlay(Crosshairs(Pen(java.awt.Color.MAGENTA), java.awt.Point(x,y), java.awt.Dimension(15,15)))
|
||||
if RENDERER is not None:
|
||||
RENDERER.addOverlay(Crosshairs(Pen(java.awt.Color.MAGENTA), java.awt.Point(x,y), java.awt.Dimension(15,15)))
|
||||
|
||||
|
||||
|
||||
#RENDERER.addOverlays(ovs)
|
||||
|
||||
clear_detection(block_id)
|
||||
detect_pucks(points, block_id)
|
||||
plot_base_plate(points, p=PLOT)
|
||||
if PLOT is not None:
|
||||
plot_base_plate(points, p=PLOT)
|
||||
|
||||
ret = get_puck_detection_dict(block_id)
|
||||
|
||||
|
||||
@@ -15,6 +15,14 @@ def get_img_cover_pos():
|
||||
[position, angle, confidence] = run("imgproc/CoverDetection2")
|
||||
return position
|
||||
|
||||
def assert_img_in_cover_pos(pos = None):
|
||||
if pos==None:
|
||||
pos = hexiposi.take()
|
||||
img_segment = get_img_cover_pos()
|
||||
if img_segment != segment:
|
||||
raise Excepton ("Image detection of cover does not match hexiposi: " + str(img_segment))
|
||||
|
||||
|
||||
def in_roi(x,y):
|
||||
global roi_center, roi_radius, roi_border
|
||||
return math.hypot(x-roi_center[0], y-roi_center[1]) < (roi_radius-roi_border)
|
||||
|
||||
Reference in New Issue
Block a user