【问题标题】:How can i calculate elongation of a convex hull in opencv?如何计算opencv中凸包的伸长率?
【发布时间】:2013-02-28 11:20:16
【问题描述】:

我找到了这种基于图像矩计算伸长率的方法

#ELONGATION
def elongation(m):
    x = m['mu20'] + m['mu02']
    y = 4 * m['mu11']**2 + (m['mu20'] - m['mu02'])**2
    return (x + y**0.5) / (x - y**0.5)

mom = cv2.moments(unicocnt, 1)    
elongation = elongation(mom)

如何计算凸壳的伸长率?

hull = cv2.convexHull(unicocnt)

其中 'unicocnt' 是通过查找轮廓获取的轮廓。

【问题讨论】:

  • 你不能在船体的轮廓上运行相同的函数吗?

标签: opencv computer-vision convex-hull feature-extraction


【解决方案1】:

默认情况下,convexHull 输出一个点索引向量。您必须将 returnPoints 参数设置为 1 以输出点向量,然后您可以将其传递给 cv2.moments。

【讨论】:

  • 只有船体和顺时针参数
  • 您使用哪个版本的 OpenCV? Here is cv2.convexHull 的文档,我可以看到 4 个参数。
猜你喜欢
  • 2019-02-28
  • 1970-01-01
  • 2013-01-18
  • 2013-08-11
  • 2016-06-10
  • 2017-04-21
  • 2015-06-06
  • 1970-01-01
  • 2020-02-16
相关资源
最近更新 更多