python opencv 标记目标(使用Python的OpenCV模块识别滑动验证码的缺口推荐)
python opencv 标记目标
使用Python的OpenCV模块识别滑动验证码的缺口推荐最近终于找到一个好的方法,使用python的opencv模块识别滑动验证码的缺口,可以将滑动验证码中的缺口识别出来了。
测试使用如下两张图片:
target.jpg" alt="python opencv 标记目标(使用Python的OpenCV模块识别滑动验证码的缺口推荐)" border="0" />
template.jpg" alt="python opencv 标记目标(使用Python的OpenCV模块识别滑动验证码的缺口推荐)" border="0" />
现在想要通过“template.jpg" alt="python opencv 标记目标(使用Python的OpenCV模块识别滑动验证码的缺口推荐)" border="0" />
main()运行结果见本文最上面,通过运行结果可以知道,已经正确的找到了缺口位置。
总结
以上所述是小编给大家介绍的使用python的opencv模块识别滑动验证码的缺口,希望对大家有所帮助,如果大家有任何疑问欢迎给我留言,小编会及时回复大家的!
原文链接:https://www.linuxidc.com/Linux/2019-05/158585.htm
# encoding=utf8
import
cv2
import
numpy as np
def
show(name):
cv2.imshow(
'show'
, name)
cv2.waitkey(
0
)
cv2.destroyallwindows()
def
main():
otemp
=
'template.jpg" alt="python opencv 标记目标(使用Python的OpenCV模块识别滑动验证码的缺口推荐)" border="0" />
oblk
=
'target.jpg" alt="python opencv 标记目标(使用Python的OpenCV模块识别滑动验证码的缺口推荐)" border="0" />
target
=
cv2.imread(otemp,
0
)
template
=
cv2.imread(oblk,
0
)
w, h
=
target.shape[::
-
1
]
temp
=
'temp.jpg" alt="python opencv 标记目标(使用Python的OpenCV模块识别滑动验证码的缺口推荐)" border="0" />
targ
=
'targ.jpg" alt="python opencv 标记目标(使用Python的OpenCV模块识别滑动验证码的缺口推荐)" border="0" />
cv2.imwrite(temp, template)
cv2.imwrite(targ, target)
target
=
cv2.imread(targ)
target
=
cv2.cvtcolor(target, cv2.color_bgr2gray)
target
=
abs
(
255
-
target)
cv2.imwrite(targ, target)
target
=
cv2.imread(targ)
template
=
cv2.imread(temp)
result
=
cv2.matchtemplate(target, template, cv2.tm_ccoeff_normed)
x, y
=
np.unravel_index(result.argmax(), result.shape)
# 展示圈出来的区域
cv2.rectangle(template, (y, x), (y
+
w, x
+
h), (
7
,
249
,
151
),
2
)
show(template)
if
__name__
=
=
'__main__'
:
热门推荐
- h5禁用返回键(可能这些是你想要的H5软键盘兼容方案小结)
- mysql 双主双备(MySQL配置了双主,是如何避免出现数据回环冲突的)
- nginx虚拟主机配置推荐(nginx配置虚拟主机的详细步骤)
- linuxnfs服务教程(使用Docker的NFS-Ganesha镜像搭建nfs服务器的详细过程)
- mysql缓存和redis查询效率(浅谈MySQL与redis缓存的同步方案)
- docker如何简化部署(Docker使用Portainer搭建可视化界面的方法)
- html网页设计排版布局(HTML利用九宫格原理进行网页布局)
- html5新增特性(总结html5自定义属性有哪些)
- docker插件容器使用(Docker容器开jupyter不能访问到的解决方法)
- mysql整体架构设计(MySQL 整体架构介绍)
排行榜
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9