图像识别工具

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)

  

posted @ 2023-11-13 14:09  jiguanghover  阅读(18)  评论(0编辑  收藏  举报