def match_template(screenshot, template):
# Perform match template calculation
matches = cv2.matchTemplate(screenshot, template, cv2.TM_CCOEFF_NORMED)
# Survey results
(min_val, max_val, min_loc, max_loc) = cv2.minMaxLoc(matches)
# Load template size
(template_height, template_width) = template.shape[:2]
return {
"x1": max_loc[0],
"y1": max_loc[1],
"x2": max_loc[0] + template_width,
"y2": max_loc[1] + template_height,
"center": {
"x": max_loc[0] + (template_width / 2),
"y": max_loc[1] + (template_height / 2)
},
"score": max_val
}
评论列表
文章目录