1 from PIL import Image 2 from pytesser import * 3 image = Image.open('7039.jpg') 4 print image_file_to_string('7039.jpg') 5 print image_to_string(image)
备注:若是出现报错ImportError: The _imaging C module is not installed,可能出现的缘由下载错了版本,更改下安装64位的版本python
pytesser是谷歌OCR开源项目的一个模块,在python中导入这个模块便可将图片中的文字转换成文本,可是在pytesser模块中调用了tesseract,因此须要先安装tesseractwindows
tesseract下载路径:https://bitbucket.org/3togo/python-tesseract/downloads/,选择合适的版本进行下载安装ide
图片识别源码google
1 from PIL import Image 2 from pytesser import * 3 image = Image.open('7039.jpg') 4 print image_file_to_string('7039.jpg') 5 print image_to_string(image)
文件示例 7039.jpgspa
可能遇到的问题及解决方案:code