windows 10 下的 tess4j

tess4j under windows 10

我无法让 tess4j 在 Windows 10 下工作。

http://tess4j.sourceforge.net/tutorial/ 状态:

Tesseract, Leptonica, and Ghostscript Windows 32- and 64-bit DLLs are embedded in tess4j.jar; they will automatically be extracted and loaded at run-time.

确实它尝试了,但它似乎针对 10 之前的 windows 版本进行了优化。我需要授予对各种目录的权限,但现在它说 (Toegang geweigerd = "Access denied")

Exception in thread "main" java.lang.UnsatisfiedLinkError: Failed to create  temporary file
for /com/sun/jna/win32-x86-64/jnidispatch.dll library: Toegang geweigerd
at com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:776)
at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:736)
at com.sun.jna.Native.<clinit>(Native.java:131)
at net.sourceforge.tess4j.util.LoadLibs.getTessAPIInstance(LoadLibs.java:78)
at net.sourceforge.tess4j.TessAPI.<clinit>(TessAPI.java:40)
at net.sourceforge.tess4j.Tesseract.init(Tesseract.java:360)
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:273)
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:256)
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:237)
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:221)
at LPokerbot.LPokerbot.Card.ocrChar(Card.java:42)
at LPokerbot.LPokerbot.Card.recognize(Card.java:37)
at LPokerbot.LPokerbot.App.start(App.java:38)
at LPokerbot.LPokerbot.App.main(App.java:27)

我不知道 tmp 目录可能是什么。我试图在 C:\temp 中创建一些目录,但无济于事。

我已经解决了。在虚拟机属性中,设置

-Djava.io.tmpdir=C:\Temp -DTESSDATA_PREFIX=C:\Users\user\workspace\LPokerbot\src\main\resources\

C:\Temp 将被创建并且它将起作用。最初,java.io.tmpdir 将是 C:\WINDOWS,当然它在那里没有权限。第二个 -D 设置 eng.traineddata 文件的路径 这有点离题,但你会 运行 进入以下错误。

Error opening data file ./tessdata/eng.traineddata
Please make sure the TESSDATA_PREFIX environment variable is set to the parent directory of your "tessdata" directory.
Failed loading language 'eng'
Tesseract couldn't load any languages!

您需要下载该文件,在我的例子中,它位于

C:\Users\user\workspace\LPokerbot\src\main\resources\tessdata\

在您的代码中,检索 属性 并设置它:

tesseract.setDatapath(System.getProperty("TESSDATA_PREFIX"));

出于某种原因,设置环境变量 TESSDATA_PREFIX 不起作用。