我正在用OpenCv for python进行对象检测:我使用matchTemplate方法检测图像,但结果是同一对象的多个坐标
[(798, 540), (799, 540), (800, 540), (798, 541), (799, 541), (800, 541), (798, 542), (799, 542), (800, 542), (798, 543), (799, 543), (800, 543), (798, 544), (799, 544), (800, 544)]
我只希望每个检测到的图像有一个坐标,所以我应用了所有坐标的平均值,结果非常好(图像上的红点):(799, 542)
问题是,有时在同一帧中检测到两个图像,而平均法(给出两个坐标的中间)不起作用
你有什么(非天真的)想法如何为2,3,4做到这一点。。。检测到的图像
谢谢:)
我的代码既不完美也不最优;但这可能是一个好的开始:)
这段代码不能解决集群数量的问题,如果您知道集群的数量,我认为它目前很有用
更新:
阅读评论后(特别是@Christoph Rackwitz的完整描述);我得出结论,我提出的方法可能不是正确的
更新:
我更多地考虑了解释和讨论。我认为如果你有一个来自points的面具,如果你尝试这样的东西可能不是最坏的主意:
在这种情况下,您可以找到簇、簇的范围以及每个簇的大致中心。在下一步中,您可以更详细地检查每个集群的范围
相关问题 更多 >
编程相关推荐