pytesser,OCR in Python using the Tesseract engine from Google。是谷歌OCR开源项目的一个模块,可将图片中的文字转换成文本(主要是英文)
如果要识别中文还需要下载对应的训练集:https://github.com/tesseract-ocr/tessdata
,下载”chi_sim.traineddata”,然后copy到训练数据集的存放路径。下面是一个例子的代码。
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import pytesseract
from PIL import Image
# open image
image = Image.open('test.png')
code = pytesseract.image_to_string(image, lang='chi_sim')
print(code)