Look at the source code:

Row := [100, 0, 100, 200, 100] Col := [61.098, 62.402, 61.525]//y Col := [154.747, 138.099, 130.394]//x * Specify how many points, arc rotation 16-20 points is sufficient. Row: = [24.052, 26.729, 28.815, 30.285, 31.124, 31.281, 30.792, 29.659, 27.943, 25.622] / / Col: y = [219.819, 214.325, 208.543, 202.413, 196.111, 189.965, 183.736, 177.558, 171.717, 165.898] / / x gen_contour_polygon_xld (Contour, Row, Col) fit_circle_contour_xld (Contour, 'atukey', -1, 2, 0, 10, 1, Row1, Column1, Radius1, StartPhi1, EndPhi1, PointOrder1) fit_circle_contour_xld (Contour, 'ahuber', -1, 2, 0, 3, 2, Row2, Column2, Radius2, StartPhi2, EndPhi2, Fit_circle_contour_xld (Contour, 'algebraic', -1, 0, 0, 3, 2, Row3, Column3, Radius3, StartPhi3, EndPhi3, PointOrder3) ** Contour fitting circle, rotation calibration algorithm should select 'geotukey', Fit_circle_contour_xld (Contour, 'geotukey', -1, 0, 0, 3, 2, Row_C, Column_C, Radius_C, StartPhi_C, EndPhi_C, PointOrder_C) dev_set_color ('magenta') gen_circle_contour_xld (ContCircle, Row2, Column2, Radius2, 0, 4 * acos(0), 'positive', 1) dev_set_color ('blue') gen_circle_contour_xld (ContCircle, Row3, Column3, Radius3, 0, 4 * acos(0), 'positive', 1) dev_set_color ('violet') gen_circle_contour_xld (ContCircle, Row_C, Column_C, Radius_C, 0, 4 * acos(0), 'positive', 1) stop()Copy the code

Use ‘geotukey’ for illustration: similar to ‘geometry’. Here, the tukey-based approach weights contour points and ignores outliers (see below).

For “* huber” and “* tukey”, reliable error statistics are used to estimate the standard deviation of the distance to the contour point without deviating from the approximate circle. The parameter ClippingFactor (scale factor of standard deviation) controls the number of outliers: the smaller the value selected for the ClippingFactor, the more outliers are detected. In the Tukey algorithm, the outliers are removed, whereas in the Huber algorithm, the outliers are only attenuated, or more precisely, they are linearly weighted. In the absence of any robust weighting, the square of the distance is used as the error value in the optimization, the least square formula. In practice, the Tukey approach is recommended.

The “number of iterations” parameter specifies the number of iterations for the algorithms “algebra”, “ahuber”, and “atukey”. For algorithms “geometry”, “geohuber”, and “geotukey”, this parameter is ignored. If “number of iterations” is set to zero, the algorithm does not perform iterative improvements on the fitting circle, but merely checks whether the initial guess is close enough based on the selected outliers.

To reduce computation, the fitting of a circle can be limited to a subset of contour points: if values other than -1 are assigned to MaxNumPoints, MaxNumPoints can only be used at most (evenly distributed over the contour).

For an arc, the points on the circle closest to the starting and ending points of the original contour are selected as the starting and ending points. Corresponding angles to the X-axis are returned in StartPhi and EndPhi, see also gen_ellipse_contour_xld. A contour whose distance between its start and end is less than or equal to MaxClosureDist is considered closed. Therefore, they are approximated by circles rather than arcs. Due to artifacts in preprocessing, the starting and ending points of the contour may be problematic. Therefore, ClippingEndPoints of contour starting and ending points can be excluded from circle fitting. However, they are still used to identify StartPhi and EndPhi.

The minimum number of contour points of the fitting circle is 3.