OpenCV的模板匹配算法
cv.TM_CCOEFF
cv.TM_CCOEFF_NORMED
cv.TM_CCORR
cv.TM_CCORR_NORMED
cv.TM_SQDIFF
cv.TM_SQDIFF_NORMED
匹配代码模板
image = cv2.imread(r"scene.png", cv2.IMREAD_GRAYSCALE)
template = cv2.imread(r"element.png", cv2.IMREAD_GRAYSCALE)
res = cv2.matchTemplate(img, template, cv2.TM_CCOEFF_NORMED)
min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(res)
if max_val > 0.8:
print("Detected")
else:
print("Not detected")
Note:文章来源地址https://www.toymoban.com/news/detail-685365.html
-
cv2.TM_CCOEFF_NORMED
:相较于其它方法,通常被认为具有较好的鲁棒性
文章来源:https://www.toymoban.com/news/detail-685365.html
到了这里,关于【图像处理】模板匹配的学习笔记的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!