def exists(image, template, thresh):
"""
Returns True if template is in Image with probability of at least thresh
:param image:
:param template:
:param thresh:
:return:
"""
digit_res = cv2.matchTemplate(image, template, cv2.TM_CCOEFF_NORMED)
loc = np.where(digit_res >= thresh)
if len(loc[-1]) == 0:
return False
for pt in zip(*loc[::-1]):
if digit_res[pt[1]][pt[0]] == 1:
return False
return True
评论列表
文章目录