python的locateCenterOnScreen怎么定位不到图片

 时间:2024-11-03 22:56:03

1、首先安装pycharm,这是实现python编程的常用软件。安装好后,点击打开pycharm。

python的locateCenterOnScreen怎么定位不到图片

2、如图导入pyautogui库,这样才能应用locateCenterOnScreen函数定位图片。

python的locateCenterOnScreen怎么定位不到图片

3、如图输入:pyautogui.locateCenterOnScreen(r'C:\Users\Administrator\desktop\python\bjh_zhijiefabu.png' , grayscale=False, confidence=0.7),其中可选参数confidence的设置是关键,一般很多人不设置,数值在0-1之间,1为100%相似,要求最高,如果太高的话,很容易识别不到图片。适当降低该值,有利于提高成功率,也不宜设置过低,导致错误识别点击。

python的locateCenterOnScreen怎么定位不到图片

4、使用confidence还需要安装opencv,terminal命令行中输入:pip install opencv-python。

python的locateCenterOnScreen怎么定位不到图片

5、上述设置成功运行识图定位一般都会成功。如图所示。

python的locateCenterOnScreen怎么定位不到图片
  • 原生js如何添加class
  • 如何在SQL Server数据库中差异备份数据库
  • 解决谷歌浏览器打开主页是毒霸网址导航问题
  • 如何用js将一个input的值放到另一个input里
  • 怎样用VBS运行计算器
  • 热门搜索
    knee怎么读 川崎病是怎么引起的 感冒了怎么办 紫外线过敏怎么办 痛风是怎么引起的 怎么变白皮肤简单有效 精油怎么用 u盘打不开怎么办 手机照片删除了怎么恢复 面筋怎么做好吃