使用Python的OpenCV模块识别滑动验证码的缺口(推荐)
2019-05-18 18:01
2121 查看
最近终于找到一个好的方法,使用Python的OpenCV模块识别滑动验证码的缺口,可以将滑动验证码中的缺口识别出来了。
测试使用如下两张图片:
target.jpg
template.png
现在想要通过“template.png”在“target.jpg”中找到对应的缺口,代码实现如下:
# encoding=utf8 import cv2 import numpy as np def show(name): cv2.imshow('Show', name) cv2.waitKey(0) cv2.destroyAllWindows() def main(): otemp = 'template.png' oblk = 'target.jpg' target = cv2.imread(otemp, 0) template = cv2.imread(oblk, 0) w, h = target.shape[::-1] temp = 'temp.jpg' targ = 'targ.jpg' 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__':
main()运行结果见本文最上面,通过运行结果可以知道,已经正确的找到了缺口位置。
总结
以上所述是小编给大家介绍的使用Python的OpenCV模块识别滑动验证码的缺口,希望对大家有所帮助,如果大家有任何疑问欢迎给我留言,小编会及时回复大家的!
您可能感兴趣的文章:
相关文章推荐
- python_Opencv_使用Matplotlib模块
- Python3.5+sklearn 使用SVM自动识别字母验证码
- 使用python及工具包进行简单的验证码识别
- 使用OpenCV_python中的DNN调用CaffeModel识别图像只需30行代码
- 使用python以及工具包进行简单的验证码识别
- Python 使用Pillow模块生成验证码
- python爬虫之验证码篇3-滑动验证码识别技术
- Python使用PIL模块生成随机验证码
- python使用PIL模块生成验证码
- 滑动验证码的破解(python+opencv+selenium)
- python使用第三方模块实现给注册用户发送验证码
- Python 使用python-nmap模块实现端口扫描器 推荐
- python中如何使用pip安装自己的第三方模块 推荐
- python使用opencv进行人脸识别
- python使用opencv实现人脸识别系统
- [PyImageSearch] Ubuntu16.04 使用OpenCV和python识别信用卡 OCR
- python3使用Pillow、tesseract-ocr与pytesseract模块的图片识别
- 使用python pillow模块生成随机验证码
- 使用OpenCV+PCA+KNN/SVM进行人脸检测和识别-Python
- 基于Python使用SVM识别简单的字符验证码的完整代码开源分享