获取图像位置

图像识别

import pyautogui
import cv2

# 截屏 返回img对象
pyautogui.screenshot("screen.png")

# region:匹配截屏(x,y,w,h)
pyautogui.screenshot("screen2.png", region=(200, 100, 600, 600))


# 获取截屏坐标   confidence:精确度:推荐0.9  安装OpenCV   grayscale=True:开启灰度匹配(加快识别)
pos = pyautogui.locateOnScreen("b.png", confidence=0.9, grayscale=True)

# 获取元素中心坐标
cent = pyautogui.center(pos)

你可能感兴趣的:(PyAutoGUI,python)