您的位置:首页 > 编程语言 > Python开发

python 识别图片中的文字信息

2017-12-06 15:37 816 查看
最近朋友需要一个可以识别图片中的文字的程序,以前做过java验证码识别的程序;

刚好最近在做一个python项目,所以顺便用Python练练手

1.需要的环境:

2.7或者3.4版本的python

2.需要安装pytesseract库

依赖PIL和tesseract-ocr库

本地环境是ubuntu,下面说一下 具体步骤:

2.7

1.安装PIL:

直接使用pip 安装; pip install Pillow

2.安装tesseract-ocr:

apt-get install tesseract-ocr

3.安装pytesseract

pip install pytesseract

使用python 3.4安装时;将pip 命令修改为pip3(都知道)

测试:

import pytesseract

from PIL import Image

img = Image.open('hb1.png')

data = pytesseract.image_to_string(img)

print (data)注意: 会出现乱码

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  python PIL