From: Tomas Musil Date: Sat, 5 Jul 2014 03:38:56 +0000 (+0200) Subject: fix bug in ransac X-Git-Url: http://git.tomasm.cz/imago.git/commitdiff_plain/5818b61929dbef0d50482028e99b2c96e13b6bbd fix bug in ransac --- diff --git a/src/gridf3.py b/src/gridf3.py index ac7fa2a..f5e6edb 100644 --- a/src/gridf3.py +++ b/src/gridf3.py @@ -125,7 +125,7 @@ def gen_corners(d1, d2): # TODO create an intersection? try: yield manual.lines(map(lambda p: p.to_tuple(), [c2, c1, c3, c4])) - except TypeError: + except (TypeError, ZeroDivisionError): pass # the square was too small to fit 17 lines inside # TODO define SquareTooSmallError or something diff --git a/src/ransac.py b/src/ransac.py index 5d5d218..4908421 100644 --- a/src/ransac.py +++ b/src/ransac.py @@ -57,10 +57,9 @@ def iterate(model, distance): score = new_score try: estimate = model.get(consensual) + new_score, consensual = model.score(estimate, distance) except NP.linalg.LinAlgError: pass - estimate = model.get(consensual) - new_score, consensual = model.score(estimate, distance) return score, estimate, consensual def estimate(data, dist, k, modelClass=Linear_model):