- global Saving_dir
- Saving_dir = "saved/" + args.file[0][:-4] + "_" + str(image.size[0]) + "/"
-
- if show_all:
- do_something(image, "original image")
-
- im_l = image.convert('L')
- if show_all:
- do_something(im_l, "ITU-R 601-2 luma transform")
-
- im_edges = filters.edge_detection(im_l)
- if show_all:
- do_something(im_edges, "edge detection")
-
- im_h = filters.high_pass(im_edges, 100)
- if show_all:
- do_something(im_h, "high pass filters")
-
- hough1 = Hough(im_h.size)
- im_hough = hough1.transform(im_h)
- if show_all:
- do_something(im_hough, "hough transform")
-
- im_hough = filters.peaks(im_hough)
- if show_all:
- do_something(im_hough, "peak extraction")
-
- im_h2 = filters.high_pass(im_hough, 120)
- if show_all:
- do_something(im_h2, "second high pass filters")
-
- im_h2 = filters.components(im_h2)
- if show_all:
- do_something(im_h2, "components centers")
-
- hough2 = Hough(im_h2.size)
- im_hough2 = hough2.transform(im_h2)
- if show_all:
- do_something(im_hough2, "second hough transform")
-
- im_h3 = filters.high_pass(im_hough2, 120)
- if show_all:
- do_something(im_h3, "third high pass filter")
-
- im_h3 = filters.components(im_h3)
- if show_all:
- do_something(im_h3, "components centers 2")
-
- lines = hough2.all_lines(im_h3)
-
- im_lines = Image.new('L', im_h2.size)
-
- draw = ImageDraw.Draw(im_lines)
-
- for line in lines:
- draw.line(line_from_angl_dist(line, im_h2.size), fill=255, width=5)
- if show_all:
- do_something(im_lines, "lines")
-
- im_c = combine(im_h2, im_lines)
- if show_all:
- do_something(im_c, "first hough x lines")
-
- lines = hough1.all_lines(im_c)
- intersections = intersections_from_angl_dist(lines)
- draw = ImageDraw.Draw(image)
- for (x, y) in intersections:
- draw.point((x + image.size[0] / 2, y + image.size[1] / 2), fill=(120, 255, 120))
-
- print(len(intersections))
-
- do_something(image, "the grid")
+ do_something = im_debug.show
+ if args.saving:
+ do_something = imsave("saved/" + args.file[0][:-4] + "_" +
+ str(image.size[0]) + "/").save
+
+ if args.manual_mode:
+ try:
+ lines = manual.find_lines(image)
+ except manual.UserQuitError:
+ #TODO ask user to try again
+ return 1
+ else:
+ lines = linef.find_lines(image, show_all, do_something, verbose)
+
+ board = intrsc.board(image, lines, show_all, do_something)
+
+ #simple ASCII output:
+ for line in board:
+ print ' '.join(line)