else:
return ransac.least_squares(sample)
+ def score(self, est, dist):
+ cons = []
+ score = 0
+ a, b, c = est
+ dst = lambda (x, y): abs(a * x + b * y + c) / sqrt(a*a+b*b)
+ for p in self.data:
+ d = dst(p)
+ if d <= dist:
+ cons.append(p)
+ score += min(d, dist)
+ return score, cons
+
def intersection((a1, b1, c1), (a2, b2, c2)):
delim = float(a1 * b2 - b1 * a2)
x = (b1 * c2 - c1 * b2) / delim
c3 = [p for p in d1.points if p in c2.l2.points][0]
c4 = [p for p in d2.points if p in c3.l1.points][0]
except IndexError:
- pass
+ continue
# there is not a corresponding intersection
# TODO create an intersection?
try:
pyplot.scatter([center[0]], [center[1]], color='r')
pyplot.xlim(0, size[0])
pyplot.ylim(0, size[1])
+ pyplot.gca().invert_yaxis()
fig.canvas.draw()
size_f = fig.canvas.get_width_height()
buff = fig.canvas.tostring_rgb()