def process_mazes(): while True: time.sleep(2) if len(queue) != 0: jid, handdrawn, scale, fname = queue.pop() print("Processing job {}".format(jid)) config.args = Args(handdrawn) orig_img = cv2.imread(fname) if orig_img is None: print("Unable to load image file {}".format(fname)) return img, scale = processimage.processimage(orig_img, scale, handdrawn) img2, graph = mazereader.read_maze(img) completed_jobs[jid] = (graph, scale)
action='store_true', help='Use tiled skeletonization\ (sometimes faster on images with lots of white space') args = parser.parse_args() config.args = args origImg = cv2.imread(config.args.image) if origImg is None: print("Unable to load image file") sys.exit(-1) start_time = time.time() img = origImg.copy() img, scale = processimage.processimage(origImg, config.args.scale, config.args.handdrawn) cv2.imwrite("preprocessed.png", img) ret = mazereader.read_maze(img) start = end = None num_clicks = 0 if ret is not None: img2, graph = ret if not config.args.nogui: cv2.imshow("image", img2) end_time = time.time() print("Time: {}".format(end_time - start_time)) w, r, h = img2.shape r = max(float(config.args.screenRows), r) w = max(float(config.args.screenCols), w)
dest='handdrawn', action='store_true', help='Preprocess the image for a messier maze') parser.add_argument('--scale', '-s', dest='scale', type=float, default=None, help='Scale factor to scale the image by before solving') parser.add_argument('--tiles', '-t', dest='tiles', action='store_true', help='Use tiled skeletonization') args = parser.parse_args() args.nogui = True args.pixellines = False config.args = args origImg = cv2.imread(config.args.image) if origImg is None: print("Unable to load image file") sys.exit(-1) img = origImg.copy() img, scale = processimage.processimage(origImg, config.args.scale, config.args.handdrawn) img2, graph = mazereader.read_maze(img) print('---GRAPH START---') for node in graph.nodes: print('---') print('{},{}'.format(node.pos[0] / scale, node.pos[1] / scale)) for con, dist in node.connections: print('{},{}'.format(con, dist))