Is it valid to use OpenCV fitEllipse for circle fitting.
fitEllipse() returns cv::RotatedRect
how about averaging width and height to get fitted circle radius?
I think that the "validity" of using cv::fitEllipse
for fitting circles depends on the precision you require for the fitting.
For example you can run your algorithm on a test set, fitting points with cv::fitEllipse
and logging the length of the two axes of the ellipse, then have a look at the distributions of the ratio of two axes or at the difference between the major and the minor axis; you can find how much your supposed circles differ from a circle and then asses if you can use the cv::fitEllipse
.
You can take the average of the width and the height of the cv::RotatedRect
returned by cv::fitEllipse
to get an approximation of the diameter of the circle (you wrote the radius but I think it was a trivial error).
You can have a look at this very readable article UMBACH, Dale; JONES, Kerry N. A few methods for fitting circles to data. Instrumentation and Measurement, IEEE Transactions on, 2003, 52.6: 1881-1885. and write your own circle interpolator.
If you want to minimize the geometric error (the sum of the squares of the distances from the points to the circle, as explained in the Introduction of the article) you maybe need a reliable implementation of a non linear minimization algorithm.
Otherwise you can write a simple circle interpolator with the formulae from (II.8) to (II.15) (a closed-form solution wich minimize an error different from the geometric one) with some warning:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With