在Mac上使用 tess4j 报的这个错误

Exception in thread "pool-1-thread-1" java.lang.UnsatisfiedLinkError: Unable to load library 'tesseract': Native library (darwin/libtesseract.dylib) not found in resource path ([file:/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/jre/lib/charsets.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/jre/lib/deploy.jar,

是因为在Mac上需要安装tesseract

执行命令

sudo apt-get install tesseract-ocr

安装过程中报下面的错误

https://homebrew.bintray.com/bottles/tesseract-4.1.1.catalina.bo

这个时候就需要出内网了,用外围安装成功后

This formula contains only the "eng", "osd", and "snum" language data files.

If you need any other supported languages, run `brew install tesseract-lang`.

==> Summary

🍺  /usr/local/Cellar/tesseract/4.1.1: 65 files, 29.6MB

运行项目 测试,出现

Error opening data file ./eng.traineddata
Please make sure the TESSDATA_PREFIX environment variable is set to your "tessdata" directory.
Failed loading language 'eng'
Tesseract couldn't load any languages!
Warning: Invalid resolution 0 dpi. Using 70 instead.

解决办法进入到 /usr/local/Cellar/tesseract/4.1.1/share/tessdata 把eng.traineddata 加入到工程目录中

 

运行项目测试会接着 出现

Warning: Invalid resolution 0 dpi. Using 70 instead.

解决方法

Tesseract instance = new Tesseract();
instance.setTessVariable("user_defined_dpi", "300");

 

 

 

 

GitHub 加速计划 / te / tesseract
60.1 K
9.29 K
下载
tesseract-ocr/tesseract: 是一个开源的光学字符识别(OCR)引擎,适用于从图像中提取和识别文本。特点是可以识别多种语言,具有较高的识别准确率,并且支持命令行和API调用。
最近提交(Master分支:2 个月前 )
bc490ea7 Don't check for a directory, because a symbolic link is also allowed. Signed-off-by: Stefan Weil <sw@weilnetz.de> 4 个月前
2991d36a - 4 个月前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐