Example #1
0
def main(file_name):
    # 载入图像
    deci1, beishu1 = circle_position(file_name)
    frameProcessor = FrameProcessor(std_height, version, deci1, beishu1, debug)
    img_file = file_name
    if len(sys.argv) == 2:
        img_file = sys.argv[1]
    # 设置playground的UI
    if debug:
        setup_ui()
    # 设置图像参数
    frameProcessor.set_image(img_file)
    # result_str = ''
    # print(result_str)
    # 处理图像
    # process_image()
    reset_tiles()
    start_time = time.time()
    # 处理图像
    debug_images, output = frameProcessor.process_image(
        blur, threshold, adjustment, erode, iterations)
    result_str = output
    #result_str = process_image()
    # print(result_str)
    # 等待 这里应该在
    # CaptureVideo.cap_video()
    # cv2.waitKey()
    return result_str
Example #2
0
def process_image():
    reset_tiles()
    start_time = time.time()
    break_fully = False
    output = ''
    debug_images = []
    print "Blur:" + str(blur)
    print "Erode:" + str(erode)
    print "Iterations:" + str(iterations)
    try:
        debug_images, output = frameProcessor.process_image(
            blur, threshold, adjustment, erode, iterations)
        if '.' in output and len(output) == 4:
            output = remove_duplicate_chars(output)
        elif '.' not in output and len(output) == 3:
            output = remove_duplicate_chars(output)
        if output != '' and (
            (len(output) == 2 and '.' not in output) or
            (len(output) == 3 and '.' in output)) and (check_instance(
                output, float) or check_instance(output, int)):
            print("Output:" + output)
    except:
        output = output
    for image in debug_images:
        show_img(image[0], image[1])
    print(output)
    print("Processed image in %s seconds" % (time.time() - start_time))

    cv2.imshow(window_name, frameProcessor.img)
    cv2.moveWindow(window_name, 600, 600)
Example #3
0
def process_image():
    reset_tiles()
    start_time = time.time()
    break_fully = False
    output = ''
    debug_images = []
    for blur in [1,3,5,7,9]:
	print(break_fully)
	if break_fully:
		break
    	for erode in [1,2,3,4,5,6,7]:
		if break_fully:
			break
		for iterations in [1,2,3,4]:
			try:	
				debug_images, output = frameProcessor.process_image(blur, threshold, adjustment, erode, iterations)
				if '.' in output and len(output) == 4:
					output = remove_duplicate_chars(output)
				elif '.' not in output and len(output) == 3:
					output = remove_duplicate_chars(output)
				if output != '' and ((len(output) == 2 and '.' not in output) or (len(output) == 3 and '.' in output) ) and (check_instance(output, float) or check_instance(output, int)):
					print("Output:"+output)
					break_fully = True			
					break
			except:
				output = output
    for image in debug_images:
       show_img(image[0], image[1])
    print(output)
    print("Processed image in %s seconds" % (time.time() - start_time))

    cv2.imshow(window_name, frameProcessor.img)
    cv2.moveWindow(window_name, 600, 600)
Example #4
0
def process_image():
    reset_tiles()
    start_time = time.time()
    debug_images, output = frameProcessor.process_image(blur, threshold, adjustment, erode, iterations)

    for image in debug_images:
        show_img(image[0], image[1])

    print("Processed image in %s seconds" % (time.time() - start_time))

    cv2.imshow(window_name, frameProcessor.img)
    cv2.moveWindow(window_name, 600, 600)
Example #5
0
def process_image():
    # 重置栈
    reset_tiles()
    start_time = time.time()
    # 处理图像
    debug_images, output = frameProcessor.process_image(
        blur, threshold, adjustment, erode, iterations)

    # 显示处理过程
    # for image in debug_images:
    #     show_img(image[0], image[1])
    # if debug:
    #     print("Processed image in %s seconds" % (time.time() - start_time))
    #     cv2.imshow(window_name, frameProcessor.img)
    #     cv2.moveWindow(window_name, 600, 600)
    return output