X-Git-Url: http://git.tomasm.cz/imago.git/blobdiff_plain/a0ffea12425b22e87010c097a393e9b627eb0a29..9cacba9db688f4c2164a0ae5f388a9f5a68175ad:/imago.py diff --git a/imago.py b/imago.py index 810aa53..81aa1ac 100755 --- a/imago.py +++ b/imago.py @@ -16,6 +16,7 @@ except ImportError, msg: import im_debug import linef +import manual def main(): """Main function of the program.""" @@ -25,6 +26,8 @@ def main(): help="image to analyse") parser.add_argument('-w', type=int, default=640, help="scale image to the specified width before analysis") + parser.add_argument('-m', '--manual', dest='manual_mode', action='store_true', + help="manual grid selection") parser.add_argument('-d', '--debug', dest='show_all', action='store_true', help="show every step of the computation") parser.add_argument('-s', '--save', dest='saving', action='store_true', @@ -51,9 +54,23 @@ def main(): if args.saving: do_something = imsave("saved/" + args.file[0][:-4] + "_" + str(image.size[0]) + "/").save - - lines = linef.find_lines(image, show_all, do_something, verbose) + 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) + + image_g = image.copy() + draw = ImageDraw.Draw(image_g) + for line in [l for s in lines for l in s]: + draw.line(linef.line_from_angl_dist(line, image.size), fill=(120, 255, 120)) + if show_all: + do_something(image_g, "the grid") + intersections = intersections_from_angl_dist(lines, image.size) image_g = image.copy() draw = ImageDraw.Draw(image_g)