【问题标题】:OpenCV template matching flag for failure condition失败条件的 OpenCV 模板匹配标志
【发布时间】:2016-03-06 19:11:36
【问题描述】:

此链接有模板匹配示例。理想情况下,有一个图像和一个模板进行匹配。如果我提供了错误的模板,我如何获得结果状态为真/假。 http://opencv-python-tutroals.readthedocs.org/en/latest/py_tutorials/py_imgproc/py_template_matching/py_template_matching.html

在下面的语句中,如果没有匹配,我们可以得到假吗?

应用模板匹配

res = cv2.matchTemplate(img,template,method)

【问题讨论】:

    标签: opencv flags template-matching


    【解决方案1】:

    不,你不能。我不熟悉 OpenCV 的 python 接口。但是,模板匹配返回匹配的映射,最佳匹配是强度最高的点。您可以从您的链接中看到这一行:

    loc = np.where( res >= threshold)
    

    阈值是您正在寻找的。您可以调整不接受低于此阈值的匹配的特定数字。祝你好运,因为这个阈值非常敏感。

    附:在现实世界的问题中,模板匹配很少能很好地工作。您可以尝试找到更好的方法。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-20
      • 1970-01-01
      • 1970-01-01
      • 2016-03-08
      相关资源
      最近更新 更多