欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Unable to load library 'tesseract'

程序员文章站 2022-07-05 22:15:20
...

在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 加入到工程目录中

 Unable to load library 'tesseract'

运行项目测试会接着 出现

Warning: Invalid resolution 0 dpi. Using 70 instead.

解决方法

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