1、安装tesseract
Index of /tesseract
https://digi.bib.uni-mannheim.de/tesseract/tesseract-ocr-w64-setup-v5.3.0.20221214.exe
2、安装中文语言包
https://digi.bib.uni-mannheim.de/tesseract/tessdata_fast/
拷贝到C:\Program Files\Tesseract-OCR\tessdata
3、注意环境变量是否设置好
TESSDATA_PREFIX=C:\Program Files\Tesseract-OCR\tessdata
4、python 测试识别
pip install pytesseract
import pytesseract
from PIL import Image
pytesseract.pytesseract.tesseract_cmd = r"C:\Program Files\Tesseract-OCR\tesseract.exe"
# 列出支持的语言
print(pytesseract.get_languages(config=''))
# 打开图像文件
image = Image.open("F:/projects/pythons/c.jpg")
# 使用Tesseract进行OCR
text = pytesseract.image_to_string(image, lang='chi_sim')
print(text)