Good day! I'm trying to implement an example of using Tess4j, I encountered this exception:

SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/C:/Users/oleg/workspace/ocr/lib/logback-classic-1.1.7.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/C:/Users/oleg/workspace/ocr/lib/logback-classic-1.2.1.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder] Exception in thread "main" java.lang.Error: Invalid memory access at com.sun.jna.Native.invokePointer(Native Method) at com.sun.jna.Function.invokePointer(Function.java:470) at com.sun.jna.Function.invoke(Function.java:404) at com.sun.jna.Function.invoke(Function.java:315) at com.sun.jna.Library$Handler.invoke(Library.java:212) at com.sun.proxy.$Proxy1.TessBaseAPIGetUTF8Text(Unknown Source) at net.sourceforge.tess4j.Tesseract.getOCRText(Tesseract.java:436) at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:291) at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:212) at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:196) at ocr.TesseractExample.main(TesseractExample.java:19) Error opening data file ./tessdata/ru.traineddata Please make sure the TESSDATA_PREFIX environment variable is set to the parent directory of your "tessdata" directory. Failed loading language 'ru' Tesseract couldn't load any languages! 

I work on Windows-x64, set the system variable: TESSDATA_PREFIX = C: \ Users \ oleg \ workspace \ ocr \ tessdata. The structure of the project on the screen in the attachment Screen project .

Help defeat a mistake, please!

  • Changed the environment variable: TESSDATA_PREFIX = C: \ Users \ oleg \ workspace \ ocr \ Did not help ..... - Oleg

1 answer 1

Everything turned out to be simpler: 1. The variable TESSDATA_PREFIX should point to the directory in which the tessdata lies. 2. in the tessdata directory should be the data for the Russian language, if the document is in Russian. 3. The most important thing is that the rus.traineddata file downloaded from github needs to be renamed ru.traineddata.

Only after that it will work.