Tesseract 是一个将图像翻译成文字的OCR库(光学文字识别,Optical Character Recognition)
安装pytesseract模块:pip3 install pytesseract
demo.py(pytesseract,识别图片中的文字):
# coding=utf-8
from PIL import Image
import pytesseract # 需要pip安装
img = Image.open("/xxx.jpg")
print(pytesseract.image_to_string(img)) # 识别图片中的文字。
电脑(ubuntu)中安装Tesseract: sudo apt-get install tesseract-ocr
命令行终端中: $ tesseract ./demo.jpg text.txt 识别图片中的文字,并保存到指定文件中。