pytesseract.pytesseract.TesseractError: (1, 'Error opening data file /usr/local/Cellar/tesseract/3.05.01/share/tessdata/chi_sim.traineddata
Please make sure the TESSDATA_PREFIX environment variable is set to the parent directory of your "tessdata" directory.
Failed loading language \'chi_sim\' Tesseract couldn\'t load any languages! Could not initialize tesseract.')
首先是安装:
brew install tesseract
解决办法:
1、要设置环境变量 TESSDATA_PREFIX,它的值为tessdata目录
2、因为要用tesseract来识别中文所以需要chi_sim语言包支持
由于我是brew 安装所以我的目录是第二种
export TESSDATA_PREFIX=/usr/local/Cellar/tesseract/3.05.01/share/tessdata
export PATH=$PATH:$TESSDATA_PREFIX
现在tesseract 被托管到github上
https://github.com/tesseract-ocr/tessdata
然后看到里面可以下载相应的语言包
注意,上面的链接滑到底有提示
These language data files only work with Tesseract 4. They are based on the sources in tesseract-ocr/langdata on GitHub.
Get language data files for Tesseract 3.04 or 3.05 from the 3.04 tree.
More information and a complete list of all languages is available in the Tesseract wiki.
由于版本问题所以需要到对应的连接进行下载。
支持的语言查看
tesseract --list-langs
显示:
List of available languages (3):
chi_sim
eng
osd
终于ok了,不过识别率一般般吧,不是很理想
以上就是我解决问题的过程,如果对你有所帮助,希望你点个赞O(∩_∩)O
参考链接:
http://xiaosheng.me/2015/12/18/article10/
https://tonydeng.github.io/2016/07/28/on-the-use-of-tesseract-picture-text-recognition/