def find(lines, size, l1, l2, bounds, hough, show_all, do_something, logger):
- logger("finding the grid")
new_lines1 = map(lambda l: Line.from_ad(l, size), lines[0])
new_lines2 = map(lambda l: Line.from_ad(l, size), lines[1])
for l1 in new_lines1:
return sqrt(x * x + y * y)
for n_tries in xrange(3):
+ logger("finding the diagonals")
model = Diagonal_model(points)
diag_lines = ransac.ransac_multi(6, points, 2, 800, model=model)
diag_lines = [l[0] for l in diag_lines]
image_p = Image.fromstring('RGB', size_f, buff, 'raw')
do_something(image_p, "finding diagonals")
+ logger("finding the grid")
data = sum(points, [])
# TODO what if lines are missing?
sc = float("inf")
do_something = im_debug.show
if verbose:
- def logger(m):
- print >> sys.stderr, m
+ import time
+ class Logger:
+ def __init__(self):
+ self.t = 0
+
+ def __call__(self, m):
+ t_n = time.time()
+ if self.t > 0:
+ print >> sys.stderr, "\t" + str(t_n - self.t)
+ print >> sys.stderr, m
+ self.t = t_n
+ logger = Logger()
+
else:
def logger(m):
pass
draw.line(l, fill=(64, 255, 64), width=1)
do_something(im_g, "grid", name="grid")
- board = intrsc.board(image, lines, show_all, do_something)
+ board = intrsc.board(image, lines, show_all, do_something, logger)
+
+ logger("finished")
if len(args.files) == 1:
print >> sys.stderr, "Opening", f
if image.mode == 'P':
image = image.convert('RGB')
- board = intrsc.board(image, lines, show_all, do_something)
+ board = intrsc.board(image, lines, show_all, do_something, logger)
if args.sgf_output:
game.addMove(board)
else:
lines.sort(key=itemgetter(1))
return lines
-def board(image, lines, show_all, do_something):
+def board(image, lines, show_all, do_something, logger):
"""Compute intersections, find stone colors and return board situation."""
# TODO refactor show_all, do_something
# TODO refactor this into smaller functions
+ logger("finding the stones")
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)