安卓自动化任务软件求助


```py
import hashlib
def yolo_find_x(specify_labels=None, min_prob: float = 0.9, use_gpu=False) -> List[ResYolo]:
"""
通过yolo算法识别当前屏幕内容
:param specify_labels: 是否寻找指定label内容
:param min_prob:
最低置信率
:param use_gpu:
是否使用gpu运算
:returns: 识别结果列表
"""
if specify_labels is None:
specify_labels = []
str_fds = screen_yolo_locate(use_gpu=use_gpu)
sp_fds = str_fds.split('\n')
results: List[ResYolo] = list()
for fd in sp_fds:
if fd != "":
result = re.match(
r'{label=\'(.*)\', cx=(\d+), cy=(\d+), x=(\d+.\d+), y=(\d+.\d+), w=(\d+.\d+), h=(\d+.\d+), '
r'prob=(\d+.\d+)}',
fd).groups()
res_yolo = ResYolo(
result[0],
int(result[1]),
int(result[2]),
float(result[3]),
float(result[4]),
float(result[5]),
float(result[6]),
float(result[7]),
)
if res_yolo.prob >= min_prob:
if len(specify_labels) > 0:
for it in specify_labels:
if re.match(it, res_yolo.label):
results.append(res_yolo)
else:
results.append(res_yolo)
return results
# 对文件进行md5计算,检查文件是否完整
def md5_file(path):
md5 = hashlib.md5()
f = open(path, mode="rb")
md5.update(f.read())
f.close()
md5_sum = md5.hexdigest()
return md5_sum
def main():
m1 = os.path.exists("/data/local/tmp/yyds.bin") and md5_file("/data/local/tmp/yyds.bin")
m2 = os.path.exists("/data/local/tmp/yyds.bin") and md5_file("/data/local/tmp/yyds.param")
if m1 != "dd90463d425e889abb0015bca59f2537" or m2 != "e89facf887d5088177d262119a8fb89b":
toast("未正确下载ncnn模型文件, 正在下载")
download("https://----------.com/auto/last-sim-opt.bin", "/data/local/tmp/yyds.bin")
download("https://----------.com/auto/last-sim-opt.param", "/data/local/tmp/yyds.param")
else:
toast("模型已正确配置")
while True:
time.sleep(5)
print("扫描识别中")
yolo_res_list = yolo_find_x()
if len(yolo_res_list) > 0:
for yolo_res in yolo_res_list:
if yolo_res.label == "label2" or yolo_res.label == "label1":
print("点击:", yolo_res)
time.sleep(1)
click(yolo_res.cx, yolo_res.cy)
toast(str(yolo_res))

我要回帖

更多关于 安卓自动化任务软件 的文章