This commit is contained in:
@@ -9,8 +9,7 @@ POSITION_NAMES = [ 'A','B','C','D', 'E', 'F']
|
||||
POSITION_ANGLES = [330, 30, 90, 150, 210, 270]
|
||||
POSITION_TOLERANCE = 3
|
||||
MINIMUM_CONFIDENCE = 10
|
||||
DEBUG = True
|
||||
PLOT = True
|
||||
DEBUG = cover_detection_debug
|
||||
REFERENCE_IMG = "ref2"
|
||||
|
||||
#Load reference image
|
||||
@@ -28,7 +27,8 @@ 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
|
||||
image_panel = show_panel(ip.bufferedImage)
|
||||
if DEBUG:
|
||||
image_panel = show_panel(ip.bufferedImage)
|
||||
|
||||
|
||||
#Calculate correlation between image and reference, rotating the reference from 0 to 360
|
||||
@@ -43,8 +43,6 @@ for i in xdata:
|
||||
bi = op.getBufferedImage()
|
||||
p = integrateVertically(bi)
|
||||
ydata.append(sum(p))
|
||||
#image_panel = show_panel(op.bufferedImage)
|
||||
#time.sleep(1.0)
|
||||
|
||||
|
||||
#Calculate angle of the highest correlation, and confidence level
|
||||
@@ -62,7 +60,7 @@ if angle is not None:
|
||||
position = POSITION_NAMES[i]
|
||||
|
||||
#Plot the correlations values agains angle
|
||||
if PLOT:
|
||||
if DEBUG:
|
||||
p = plot(ydata, xdata=xdata)[0]
|
||||
|
||||
#Output results
|
||||
|
||||
@@ -18,9 +18,13 @@ def get_img_cover_pos():
|
||||
def assert_img_in_cover_pos(pos = None):
|
||||
if pos==None:
|
||||
pos = hexiposi.take()
|
||||
elif type(pos) is int:
|
||||
pos = chr( ord('A') + (pos-1))
|
||||
elif type(pos) is str:
|
||||
pos = pos.upper()
|
||||
img_segment = get_img_cover_pos()
|
||||
if img_segment != segment:
|
||||
raise Excepton ("Image detection of cover does not match hexiposi: " + str(img_segment))
|
||||
if img_segment != pos:
|
||||
raise Exception ("Image detection of cover does not match position: " + str(img_segment))
|
||||
|
||||
|
||||
def in_roi(x,y):
|
||||
|
||||
Reference in New Issue
Block a user