- 安装依赖包
-
安装PIL
pip install pillow
pip3 install pillow
-
安装tesseract
pip install tesseract
pip3 install tesseract
-
安装pytesseract
pip install pytesseract
pip3 install pytesseract
-
添加环境变量
vim ~/.bash_profile
添加如下环境变量,TESSDATA_PREFIX的值根据tesseract的安装路径做调整
export TESSDATA_PREFIX="/usr/local/Cellar/tesseract/3.05.02/share/tessdata" export PATH=$PATH:$TESSDATA_PREFIX使环境变量生效
source ~/.bash_profile
-
添加语言包
-
检查当前语言包
tesseract --list-langs
-
下载所需语言包
如‘chi_sim.traineddata’
Tesseract 4.0.0
https://github.com/tesseract-ocr/tessdataTesseract 3.04 or 3.05
https://github.com/tesseract-ocr/tessdata/tree/3.04.00 -
将语言包拷贝到对应目录下
如 /usr/local/Cellar/tesseract/3.05.02/share/tessdata
-
应用举例
from PIL import Image import pytesseract image = Image.open('1.jpg') text = pytesseract.image_to_string(image, lang='chi_sim')
这篇博客介绍了如何在Linux环境中配置tesseract OCR,包括安装PIL、tesseract和pytesseract库,设置环境变量,添加语言包,并提供了检查和下载语言包的步骤。
6248

被折叠的 条评论
为什么被折叠?



