码迷,mamicode.com
首页 > 其他好文 > 详细

验证码识别——图形验证码

时间:2018-07-23 21:12:18      阅读:192      评论:0      收藏:0      [点我收藏+]

标签:没有   range   ble   style   验证   strong   point   二值化   分享   

先找了一个简单的图形验证码进行测试,比如知网,从网页里把验证码下载到本地

进行简单的灰度处理和二值化处理,能够提高不少识别正确率

验证码:

  技术分享图片

代码:

 

 1 import tesserocr
 2 from PIL import Image
 3 
 4 image = Image.open(code.jpg)
 5 #灰度处理
 6 image = image.convert(L)
 7 #阈值
 8 threshold = 127
 9 table = []
10 #阈值处理
11 for i in range(256):
12     if i < threshold:
13         table.append(0)
14     else:
15         table.append(1)
16 
17 image = image.point(table, 1)
18 result = tesserocr.image_to_text(image)
19 print(result)

 

结果:

技术分享图片

 

如果没有灰度处理和二值化处理这个9就总识别错了

 

验证码识别——图形验证码

标签:没有   range   ble   style   验证   strong   point   二值化   分享   

原文地址:https://www.cnblogs.com/MC-Curry/p/9356828.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!