首页 > 编程语言 > 详细

python 图片中查找子图片

时间:2020-03-21 10:17:46      阅读:464      评论:0      收藏:0      [点我收藏+]

import aircv as ac
import pyautogui

def matchImg(imgsrc, imgobj, confidencevalue=0.5): # imgsrc=原始图像,imgobj=待查找的图片
imsrc = ac.imread(imgsrc)
imobj = ac.imread(imgobj)

match_result = ac.find_template(imsrc, imobj,confidencevalue) # {‘confidence‘: 0.5435812473297119, ‘rectangle‘: ((394, 384), (394, 416), (450, 384), (450, 416)), ‘result‘: (422.0, 400.0)}
if match_result is not None:
match_result[‘shape‘] = (imsrc.shape[1], imsrc.shape[0]) # 0为高,1为宽

return match_result

imgsrc = "b.png"
imgobj = "a.png"
match_result = matchImg(imgsrc, imgobj)
print(match_result)

python 图片中查找子图片

原文:https://www.cnblogs.com/niuniuc/p/12536706.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!