pytesseract.pytesseract.TesseractError

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语言包支持

一、tessdata目录

1.1 可能在/usr/share/tesseract
1.2 可能在/usr/local/Cellar/里

由于我是brew 安装所以我的目录是第二种

export TESSDATA_PREFIX=/usr/local/Cellar/tesseract/3.05.01/share/tessdata
export PATH=$PATH:$TESSDATA_PREFIX

二、chi_sim下载

现在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/

  • 3
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值