def image_is_on_screen(template_name):
template = cv2.imread(os.path.join(
'screenshots',
template_name + '.png'),
cv2.IMREAD_GRAYSCALE)
image = cv2.cvtColor(
np.array(pyautogui.screenshot(
region=(0, 0, 1300, 750))),
cv2.COLOR_BGR2GRAY)
res = cv2.matchTemplate(image, template, cv2.TM_CCOEFF_NORMED)
loc = np.where(res >= CLOSENESS_THRESHOLD)
# Not sure why this works but okay
for pt in zip(*loc[::-1]):
return True
return False
评论列表
文章目录