安卓ai自动化脚本 Yyds.Auto实现 示例 纯ai图像识别自动点击脚本

在这里插入图片描述


```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))
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
使用datax的python脚本可以自动创建表。根据引用中的信息,可以使用脚本文件`gen_import_config.py`生成datax的配置文件。然后,可以使用以下命令执行该脚本,生成相应的表: ``` python gen_import_config.py -d gmall2022 -t activity_info ``` 该命令将生成名为`gmall2022.activity_info.json`的配置文件。接下来,可以使用以下命令执行datax的python脚本自动建表: ``` python /opt/yyds/apps/datax/bin/datax.py -p"-Dtargetdir=/origin_data/gmall2022/db/activity_info_full/2020-06-14" /opt/yyds/apps/datax/job/import/gmall2022.activity_info.json ``` 这样,您就可以使用datax的python脚本自动创建表了。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [离线数仓(4) 使用dataX全量同步业务表(脚本实现mysql_to_hdfs)](https://blog.csdn.net/qq_44665283/article/details/124424633)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* [Python自动化脚本编程笔记3.md](https://download.csdn.net/download/weixin_52057528/88264569)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值