#Parameters FRAMES_INTEGRATION = 3 MINIMUM_CONFIDENCE = 10 DEBUG = cover_detection_debug REFERENCE_IMG = "ref1" ERODE_ITERATIONS = 2 #Load reference image SIZE = [128,128] BORDER = 7 hexiposi.move("A") #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") #binary_dilate(ip, True, 2) for i in range(ERODE_ITERATIONS): ip.getProcessor().erode(1, 255) cx,cy = int(ip.width/2), int(ip.height/2) ip = sub_image(ip, cx-SIZE[0]/2, cy-SIZE[1]/2, SIZE[0], SIZE[1]) invert(ip) ip = grayscale(ip, True) #smooth(ip) if BORDER > 0: sip = sub_image(ip, BORDER,BORDER, SIZE[0]-2*BORDER, SIZE[1]-2*BORDER) ip = pad_image(sip, BORDER, BORDER, BORDER, BORDER) if DEBUG: image_panel = show_panel(ip.bufferedImage) save_image(ip, str("{images}/cover/" + REFERENCE_IMG + ".png") ,"png")