图像识别工具
1. OPenCV
import cv2 import numpy as np # 读取图像 img = cv2.imread('screenshot.png', 0) # 使用模板匹配 template = cv2.imread('template.png', 0) res = cv2.matchTemplate(img, template, cv2.TM_CCOEFF_NORMED) threshold = 0.8 loc = np.where(res >= threshold) if loc: print("图像匹配成功")
2. PyAutoGUI
import pyautogui
# 截取屏幕快照
screenshot = pyautogui.screenshot()
# 在屏幕快照中查找图像
location = pyautogui.locateOnScreen('image.png')
if location:
print("图像找到,位置:", location)
浙公网安备 33010602011771号