From f1094e68978c348e13ddc4f1da0af6d481ec7cf0 Mon Sep 17 00:00:00 2001 From: Tomas Musil Date: Mon, 14 Jul 2014 14:56:00 +0200 Subject: [PATCH] fix transposition bug --- src/intrsc.py | 8 +++++++- src/manual.py | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) 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 = [] diff --git a/src/manual.py b/src/manual.py index 8e246d4..4030104 100644 --- a/src/manual.py +++ b/src/manual.py @@ -76,6 +76,8 @@ def find_lines(im_orig): def lines(corners): # TODO Error on triangle + corners.sort() # TODO does this help? + # TODO refactor this vvv cor_d = [(corners[0], (c[0] - corners[0][0], c[1] - corners[0][1]), c) for c in corners[1:]] cor_d = [(float(a[0] * b[0] + a[1] * b[1]) / (sqrt(a[0] ** 2 + a[1] ** 2) * -- 2.4.2