失败条件的 OpenCV 模板匹配标志

OpenCV template matching flag for failure condition

此 link 在模板 matching.Ideally 上有样本 matching.How 有图像和模板 matching.How 如果我提供错误,我得到的结果状态是否为 True/False模板。 http://opencv-python-tutroals.readthedocs.org/en/latest/py_tutorials/py_imgproc/py_template_matching/py_template_matching.html

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

应用模板匹配

res = cv2.matchTemplate(img,模板,方法)

不,你不能。我不熟悉 OpenCV 的 python 接口。然而,模板匹配 return 匹配图和最佳匹配是强度最高的点。您可以从 link:

中看到这一行
loc = np.where( res >= threshold)

threshold 就是您要查找的内容。您可以调整一个特定的数字,您不接受低于此阈值的匹配项。祝你好运,因为这个阈值非常敏感。

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