安装 pytesseract 和 Tesseract OCR 引擎:
pip install pytesseract
sudo apt install tesseract-ocr
安装中文语言数据包:
sudo apt install tesseract-ocr-chi-sim
案例图片
使用 pytesseract 进行中文文字识别
from PIL import Image
import pytesseract
# 加载图像
image = Image.open('../target_img/image_88.png')
# 列出支持的语言
print(pytesseract.get_languages(config=''))
text = pytesseract.image_to_string(image, lang='chi_sim')
print(text)
效果