Tesseract-OCR

Tesseract的OCR引擎目前已作为开源项目发布在Google Project。
项目主页: https://github.com/tesseract-ocr,
它支持中文OCR,并提供了一个命令行工具。python中对应的包是pytesseract. 通过这个工具我们可以识别图片上的文字。

1.安装tesseract
下载地址:https://github.com/parrot-office/tesseract/releases/tag/3.5.1

解压到:F:\software\Tesseract-OCR
在此目录下创建 tessdata 文件夹

2.安装pytesseract
pip install pytesseract

3.安装语言库支持
语言库 https://github.com/tesseract-ocr/tessdata/tree/3.04.00
语言库 https://github.com/tesseract-ocr/tessdata
chi_sim.traineddata 就是中文简体语言库。

下载拷贝到 tesseract-ocr安装目录tessdata文件夹下面就行。
e.g: F:\software\Tesseract-OCR\tessdata

python程序:
备注:将 F:\software\Python\Python36\Lib\site-packages\pytesseract 目录下的test.png图片copy到程序目录下。
import pytesseract;
from PIL import Image
# open image
image = Image.open(‘201505081.jpg’)
code = pytesseract.image_to_string(image, lang=’chi_sim’)
print(code)

你可能感兴趣的:(python)