python - Least squares for circle detection -


i'm trying perform circle detection laser scan using least squares optimization on subset of data points. since measurements obtained part of circle, least squares method returns faulty result, reporting circle closer laser is.

the outcome of algorithm shown in picture. scatter points indicate laser measurements, circles centered on points returned algorithm. gray semi-transparent shape indicates robot taking scan (lasers on left , on right of shape).

i'm interested in local coordinates of circle, has known radius rr.

ps. assume scan separated clusters (self.clusters[i] 1 cluster), lists of [x,y] laser points

def circle(x, scan):     xc, yc = x     f = sqrt((scan[:,0] - xc)**2 + (scan[:,1] - yc)**2) - rr     return f   def optimize_detect_circles(self):      centre = [1,1]      in range(0, self.number_of_clusters):         range_points = np.array(self.clusters[i])          sol = optimize.root(circle, centre, args=(range_points), method='lm')         self.circle_candidates.append(sol.x)         print sol.x 

here’s picture:

enter image description here

1,1 far correct value; fall local optimum.

try starting point closer real center. find first fitting straight line cluster; separate points 2 halves, according half of line project onto; fit two lines next, each 1 of new 2 subclusters; , find intersection point 2 perpendiculars @ middle points.

this predicated on clusters being arcs not bigger 180 degrees in span, seem are. if not, repeat subdivision, 4 chords instead of two.


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

utf 8 - split utf-8 string into bytes in python -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -