墨水熊

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
# -*- coding:utf-8 -*-
import aircv as ac
from PIL import Image,ImageDraw
import jietu
import win32gui,win32ui,win32api
import time

jietu.jietu()#网上当的 简单好用
imsrc = ac.imread('desktop.bmp') # 原始图像
imsch = ac.imread('flag.bmp') # 带查找的部分


print ac.find_template(imsrc, imsch)#抓取相似度最高的一张图片 废
af= ac.find_all_template(imsrc, imsch)#抓取所有相似的图片
img=Image.open('desktop.bmp')
p=ImageDraw.Draw(img)
for t1 in af:
    if t1['confidence'] > 0.9:#筛选出高相似度的位置

        i=t1['result'][0]
        j=t1['result'][1]

        p.text([i, j], 'this', 'red',None)#在截图内写字表示抓到图位置
        win32api.SetCursorPos((i, j))#放置鼠标
        time.sleep(1)
img.save('1.bmp','bmp')#添加文字后的保存图片

 

 
posted on 2019-09-19 10:48  墨水熊  阅读(601)  评论(0编辑  收藏  举报