使用OpenCV fitEllipse()进行圆拟合 [英] Using OpenCV fitEllipse() for circle fitting

查看:2688
本文介绍了使用OpenCV fitEllipse()进行圆拟合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用OpenCV是否有效 fitEllipse 用于圆拟合. fitEllipse()返回cv::RotatedRect如何平均宽度和高度以获得拟合的圆半径?

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?

推荐答案

我认为使用cv::fitEllipse进行拟合圆的有效性"取决于您拟合所需的精度.

I think that the "validity" of using cv::fitEllipse for fitting circles depends on the precision you require for the fitting.

例如,您可以在测试集上运行算法,将点与cv::fitEllipse拟合,并记录椭圆的两个轴的长度,然后查看两个轴之比的分布或差异在长轴和短轴之间;您可以找到假定的圆与圆有多少不同,然后评估是否可以使用cv::fitEllipse.

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.

您可以取cv::fitEllipse返回的cv::RotatedRect的宽度和高度的平均值,以获得圆的直径的近似值(您写了 radius ,但我认为这是一个微不足道的错误.

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).

您可以看一下这篇易读的文章 UMBACH,戴尔; JONES,KerryN.将圆拟合到数据的几种方法. Instrumentation and Measurement,IEEE Transactions on ,2003,52.6:1881-1885.并编写自己的圆弧插值器.

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.

否则,您可以编写一个具有(II.8)到(II.15)公式的简单圆形插值器(闭合形式的解决方案会通过警告将几何错误以外的其他错误最小化:

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:

  1. 从实现的角度来看,您必须注意有关舍入错误和截断错误的通常警告.
  2. 在离群点的情况下,封闭式解决方案不能足够健壮,在这种情况下,您可能需要实现健壮的内插器,例如 MathWorld – Wolfram Web资源,计算共识并进行迭代).此警告也适用于发现几何误差最小的圆.
  1. from an implementation point of view you have to take care of the usually warnings about roundoff error and truncation error.
  2. the closed form solution cannot be robust enough in case of outlier points, in that case you may need to implement a robust interpolator like RANSAC (random choose three points, interpolate a circle with that three points with formulae from (25) to (34) from Weisstein, Eric W. "Circle." From MathWorld--A Wolfram Web Resource, compute the consensus and iterate). This warning applies also to the circle found with the minimization of the geometric error.

这篇关于使用OpenCV fitEllipse()进行圆拟合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆