This commit is contained in:
gac-S_Changer
2018-08-10 17:02:30 +02:00
parent 9ef973fa49
commit 1709e91d0d
23 changed files with 392 additions and 52 deletions

View File

@@ -6,11 +6,15 @@
FRAMES_INTEGRATION = 3
STEP_SIZE = 2
POSITION_NAMES = [ 'A','B','C','D', 'E', 'F']
POSITION_ANGLES = [330, 30, 90, 150, 210, 270]
#POSITION_ANGLES = [ 330, 30, 90, 150, 210, 270 ]
POSITION_ANGLES = [ 0, 60, 120, 180, 240, 300 ]
POSITION_TOLERANCE = 3
MINIMUM_CONFIDENCE = 10
MINIMUM_CONFIDENCE = 3
DEBUG = cover_detection_debug
REFERENCE_IMG = "ref2"
#REFERENCE_IMG = "ref2"
REFERENCE_IMG = "ref1"
BORDER = 7
#Load reference image
ref = load_image(str("{images}/cover/" + REFERENCE_IMG + ".png") , title="Line")
@@ -23,9 +27,16 @@ smooth(ip)
#bandpass_filter(ip, 30, 1000)
edges(ip)
auto_threshold(ip, method = "MaxEntropy")
#binary_erode(ip, False)
#binary_dilate(ip, True)
ip.getProcessor().erode(1, 255)
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)
if BORDER>0:
sip = sub_image(ip, BORDER,BORDER, ref.width-2*BORDER, ref.height-2*BORDER)
ip = pad_image(sip, BORDER, BORDER, BORDER, BORDER, fill_color=Color.WHITE)
#Show ROI of pre-processed image
if DEBUG:
image_panel = show_panel(ip.bufferedImage)
@@ -49,6 +60,14 @@ for i in xdata:
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)
if len(peaks_x) > 1:
#remoce close peaks between 350 deg and 10 deg
if ((peaks_x[0]<10) and (peaks_x[1]>350)) or ((peaks_x[1]<10) and (peaks_x[0]>350)):
peaks.pop(1)
peaks_x.pop(1)
peaks_y.pop(1)
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])