Mac配置Tesseract图片识别文字

python3

from PIL import Image
import pytesseract

# 上面都是导包,只需要下面这一行就能实现图片文字识别
text = pytesseract.image_to_string(Image.open('../picture/2.png'), lang='chi_sim')
print(text)

设置语言的环境变量:

TESSDATA_PREFIX=/usr/local/Cellar/tesseract/4.0.0_1/share/tessdata
export TESSDATA_PREFIX

原文地址:https://www.cnblogs.com/beaconSky/p/11965125.html