From: Tomas Musil Date: Tue, 9 Oct 2012 20:16:46 +0000 (+0200) Subject: bugs in manual mode fixed X-Git-Url: http://git.tomasm.cz/imago.git/commitdiff_plain/9cacba9db688f4c2164a0ae5f388a9f5a68175ad?ds=inline;hp=e3b0b7b8f5accc4f6af935923e6db9b34a40b362 bugs in manual mode fixed --- diff --git a/manual.py b/manual.py index f774c7b..c7f8e2b 100644 --- a/manual.py +++ b/manual.py @@ -32,7 +32,7 @@ def find_lines(im_orig): fill=(255, 64, 64)) corners = [] color=(64, 64, 255) - line_width = 2 + line_width = 1 lines_r = [] while not done: @@ -71,10 +71,10 @@ def find_lines(im_orig): (corners[1], corners[2])] l_hor += [(corners[0], corners[1]), (corners[2], corners[3])] - l_vert = sorted(l_vert) - l_hor = sorted(l_hor) - for i in [3, 8, 14]: - for j in [3, 8, 14]: + l_vert.sort() + l_hor.sort() + for i in [3, 9, 15]: + for j in [3, 9, 15]: hoshi(intersection(line(l_vert[i][0], l_vert[i][1]), line(l_hor[j][0], l_hor[j][1]))) lines_r = [[l2ad(l[0], l[1], im.size) for l in l_vert], @@ -139,6 +139,11 @@ def l2ad(a, b, size): q = float(a[1] - b[1]) / (a[0] - b[0]) angle = atan(q) + if angle < 0: + angle += pi + if angle > pi: + angle -= pi + distance = (((a[0] - (size[0] / 2)) * sin(angle)) + ((a[1] - (size[1] / 2)) * - cos(angle))) return (angle, distance)