1.安装Tesseract-OCR 引擎
https://blog.csdn.net/Alexabc3000/article/details/124968169
下载地址:Index of /tesseract
设置环境变量:D:\Program Files\Tesseract-OCR
测试一下看看是否安装成功:
tesseract --version
安装完毕:重启电脑。
2.安装pytesseract
pip install pytesseract -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install Pillow -i https://pypi.tuna.tsinghua.edu.cn/simple
3.使用示例:
import pytesseract
from PIL import Image
if __name__ == '__main__':
languages = pytesseract.get_languages()
print('支持的语言:', languages)
result = pytesseract.image_to_string(Image.open('9.jpg'))
print('识别结果:\n', result)
运行结果: