发布时间:2019-09-16 07:15:41编辑:auto阅读(2280)
1、环境:
系统:XP
Python版本:2.7.5
2、所需文件:
(1)、pillow地址:https://pypi.python.org/pypi/Pillow/
(2)、tesseract地址:https://github.com/tesseract-ocr
(3)、pytesser地址:https://code.google.com/p/pytesser/
3、安装
(1)、pillow和tesseract直接双击安装,没什么值得注意的。
(2)、pytesser无需安装,解压到某个文件夹,让后添加环境变量(PYTHONPATH)。比如walker的PYTHONPATH环境变量值是 C:\Python27\Lib\site-packages\pytesser_v0.0.1
注意:将pytesser_v0.0.1目录下pytesser.py第6行的import Image改为from PIL import Image
4、测试
其中图片:
5、可以看到,识别并不是很精确。可以将得到的字符串转为大写,取出可能的字符,比如上面的验证码可能的字符集为 大写字母和数字,将两个字符串的大写字母和数字取出来是可以得到正确验证码的。
6、如果发现彩×××片不能识别,可以先将其转换为黑白图片再识别。(PIL模式介绍)
from PIL import Image
p_w_picpath = Image.open(r'D:\tmp\in.jpg')
p_w_picpath = p_w_picpath.convert("1") #转换成黑白图片
p_w_picpath.save(r'D:\tmp\out.jpg')推荐阅读:
3、Python图像处理库PIL的基本概念介绍。(pillow.readthedocs.io、pillow-zh-cn.readthedocs.io)
*** walker * 2014-01-20 ***
上一篇: shell-脚本集合3
下一篇: python中变量的声明和赋值
51316
50768
41363
38169
32651
29541
28386
23259
23229
21554
1629°
2363°
1967°
1910°
2240°
1947°
2640°
4426°
4266°
3037°