def matchTemplate(self, img, template):
res = cv2.matchTemplate(cv2.cvtColor(img, cv2.COLOR_RGB2GRAY),
template,
cv2.TM_CCOEFF_NORMED)
min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(res)
top_left = max_loc
bottom_right = (top_left[0] + template.shape[1],
top_left[1] + template.shape[0])
return top_left, bottom_right
评论列表
文章目录