2015-12-20 58 views
1

我不能讓tess4j到Windows下工作10tess4j 10

http://tess4j.sourceforge.net/tutorial/狀態:

正方體,Leptonica,和Ghostscript的Windows 32位和64位的DLL 嵌入tess4j.jar;它們將自動被提取並且在運行時加載 。

事實上,它會嘗試,但它似乎對之前的Windows版本10.優化,我需要把權限給予各種目錄,但現在它說 (Toegang geweigerd =「拒絕訪問」)

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中創建一些dirs,但無濟於事。

回答

2

我已經解決了。在VM屬性中,設置爲

-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文件的路徑這是一種offtopic,但您會遇到以下錯誤。

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不起作用。

+1

tmpdir通常是'C:\ Users \ YourUserName \ AppData \ Local \ Temp',但它可能與您的不同。 – nguyenq