python cv2 matchtemplate,带有透明性的python opencv cv2 matchTemplate

在OpenCV 3.0.0中,matchTemplate函数增加了指定掩模的功能。然而,当尝试匹配带有透明度的PNG模板时,会遇到错误。文章通过代码展示了如何创建和使用掩模解决此问题,并提供了使用不同匹配方法的示例。
摘要由CSDN通过智能技术生成

OpenCV 3.0.0 added the ability to specify a mask while performing templateMatch. When I specify a mask I get this error: error: (-215) (depth == CV_8U || depth == CV_32F) && type == _templ.type() && _img.dims() <= 2 in function matchTemplateMask

Template image (PNG with transparency):

3e092de4918f64c49eb7c6b8457ab08e.png

Source image:

98e92a05c1805147f9b06e99a02e2f79.png

Code

# read the template emoji with the alpha channel

template = cv2.imread(imagePath, cv2.IMREAD_UNCHANGED)

channels = cv2.split(template)

zero_channel = np.zeros_like(channels[0])</

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值