X-Git-Url: http://git.tomasm.cz/imago.git/blobdiff_plain/5b14e50cf12ff0b275a291da0dc6f7534779ae10..f1094e68978c348e13ddc4f1da0af6d481ec7cf0:/src/intrsc.py?ds=sidebyside diff --git a/src/intrsc.py b/src/intrsc.py index cbf922a..977ad84 100644 --- a/src/intrsc.py +++ b/src/intrsc.py @@ -30,6 +30,11 @@ def board(image, lines, show_all, do_something): # TODO refactor show_all, do_something # TODO refactor this into smaller functions lines = [dst_sort(l) for l in lines] + an0 = (sum([l[0] for l in lines[0]]) / len(lines[0]) - pi / 2) + an1 = (sum([l[0] for l in lines[1]]) / len(lines[1]) - pi / 2) + if an0 > an1: + lines = [lines[1], lines[0]] + intersections = intersections_from_angl_dist(lines, image.size) if show_all: @@ -129,10 +134,11 @@ def intersection(l1, l2): y = (c1 * a2 - a1 * c2) / delim return x, y +# TODO remove the parameter get_all def intersections_from_angl_dist(lines, size, get_all=True): """Take grid-lines and size of the image. Return intersections.""" - lines1 = map(lambda l: to_general(l, size), lines[1]) lines0 = map(lambda l: to_general(l, size), lines[0]) + lines1 = map(lambda l: to_general(l, size), lines[1]) intersections = [] for l1 in lines1: line = []