如何检查轮廓是否为椭圆形? [英] how to check if a contour is an ellipse?

查看:261
本文介绍了如何检查轮廓是否为椭圆形?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用opencv检测图像中的椭圆.我找到了包括椭圆和其他轮廓的轮廓.

I am trying to detect ellipse in an image using opencv. I find the contours which include ellipse and also some other ones.

关于如何检查椭圆形的任何建议?

Any suggestions that how can I check which contours are ellipse?

推荐答案

如果我对您的理解是正确的,那么您已经检测到轮廓,其中一些是椭圆,有些不是,您希望能够确定哪些是椭圆.这样对吗? 如果是,我建议使用cv::fitEllipse().医生说,它使椭圆适合点向量,因此R平方最小.不幸的是,该函数没有显式返回R平方值.您也许可以自己实现它...

if I understand you correctly, you have detected contours some of them are ellipses and some are not and you want to be able to decide which ones are. Is it right? If yes, I would suggest to use cv::fitEllipse(). The doc says that it fits an ellipse to a vector of points so that R-squared is minimal. Unfortunately, the function does not return explicitly the R-squared value. You can maybe implement it yourself...

作为一种解决方法,您还可以使用诸如:

As a workaround, you can also use a something such as:

  1. 获取轮廓C
  2. 将椭圆E设置为C
  3. 将E与C进行比较.

要比较它们,可以使用矩(参见cv::moments()cv::matchShapes()). 不过,我认为您不需要在这里保持不变.

To compare them you can use moments (cf. cv::moments() and cv::matchShapes()). I do not think you need invariant moments here, though.

或者,您可以绘制C和E来找到表面重叠的比例.

Alternatively, you can draw C and E find what proportion of there surface overlap.

祝你好运

这篇关于如何检查轮廓是否为椭圆形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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