如何解决更快的图像识别?
Castimage = pag.locateCenterOnScreen('Cast.png',region=(426,579,643,676))
PullImage = pag.locateCenterOnScreen('pull.png',676))
stopper = pag.locateCenterOnScreen('stopper.png')
ensure = pag.locateCenterOnScreen('ensure.png',region=(154,88,624,132))
我希望这部分代码更快,因为在屏幕上搜索照片会消耗太多时间(我什至指定了要搜索此照片的区域,但没有帮助)。也许我应该使用其他图书馆?如何更快地在屏幕上定位图像?
这是我的完整代码:
import pyautogui as pag
import time
def cast():
flag = True
while flag:
Castimage = pag.locateCenterOnScreen('Cast.png',676))
print('searching for cast image')
if Castimage is not None:
time.sleep(0.2)
click = pag.click(Castimage)
print('clicking cast image')
flag = False
def pull():
flag = True
while flag:
PullImage = pag.locateCenterOnScreen('pull.png',676))
print('searching for pull image')
if PullImage is not None:
time.sleep(0.2)
click1 = pag.click(PullImage)
print('clicking pull image')
flag = False
def strength():
flag = True
stopper = pag.locateCenterOnScreen('stopper.png')
ensure = pag.locateCenterOnScreen('ensure.png',132)) # ensures that this is right window(with game)
while flag:
print('Searching for strengthBAR')
strengthgreen = pag.locateOnScreen('strength.png',region=(355,304,774,528))
if strengthgreen is None and ensure is not None:
clickPull = pag.mouseDown(534,634) # FIXED VALUE
print('PULLING')
if stopper is not None:
flag = False
print('Stopping strength function')
while True:
cast()
pull()
strength()
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。