From 5818b61929dbef0d50482028e99b2c96e13b6bbd Mon Sep 17 00:00:00 2001 From: Tomas Musil Date: Sat, 5 Jul 2014 05:38:56 +0200 Subject: [PATCH 1/1] fix bug in ransac --- src/gridf3.py | 2 +- src/ransac.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) 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): -- 2.4.2