Home > Back-end >  Tess4j call error problem
Tess4j call error problem

Time:11-23

For personal use tess4j all versions (from 1.3.0-4.5.0), in the configuration TESSDATA_PREFIX variables under the premise of confirmation TESSDATA directory can be accessed without any problems at the same time, the source images can be accessed without any problems (in fact in other OCR has been parsed the picture), use the following code has been submitted to the following error,

The source code is as follows:
String imagePath="C:/Users/it/Desktop/temp/ABC - 1. PNG";
String TESSDATA="D:/ABC/BCD/tessj4/TESSDATA";

The File imageFile=new File (imagePath);
ITesseract instance=new Tesseract ();//JNA Interface Mapping
//ITesseract instance=new Tesseract1 ();//JNA Direct Mapping
The instance. SetDatapath (TESSDATA);//path to tessdata directory

The String result=instance. DoOCR (imageFile);
System. The out. Println (result);

Error is as follows:
SLF4J: Actual binding is of type [ch. Qos. Logback. Classic. Util. ContextSelectorStaticBinder]
Error opening the data file D:/ABC/BCD tessj4/tessdata/eng. Traineddata
Both Please make sure the TESSDATA_PREFIX environment variable is set to "tessdata" directory.
Failed loading language 'eng'
Tesseract couldn 't load any languages!
The Exception in the thread "main" Java. Lang. Error: Invalid memory access
At com. Sun. Jna. Native. InvokePointer (Native Method)
At com. Sun. Jna. Function. InvokePointer (470) Function. The Java:
At com. Sun. Jna. Function. Invoke (404) Function. The Java:
At com. Sun. Jna. Function. Invoke (315) Function. The Java:
At com. Sun. Jna. Library $Handler. Invoke (212) Library. Java:
At com. Sun. Proxy. $Proxy0. TessBaseAPIGetUTF8Text (Unknown Source)
At net. Sourceforge. Tess4j. Tesseract. GetOCRText (Tesseract. Java: 491)
At net. Sourceforge. Tess4j. Tesseract. DoOCR (Tesseract. Java: 354)
At net. Sourceforge. Tess4j. Tesseract. DoOCR (Tesseract. Java: 228)
At net. Sourceforge. Tess4j. Tesseract. DoOCR (Tesseract. Java: 195)
At com. Jason. Test. The OCR. TestOcr. Main (TestOcr. Java: 21)

Bosses to help see, thank you,
Said TESSDATA path problem need not see, can ensure that whether the environment variables or local code set mode, there will be little effect in the path of right,
And whether using PREFIXE or absolute path ways are also tried, not the same, feels the phenomenon is not very like setting problem, but don't know what reason is caused,

Which bosses had a similar experience to help give an idea, thank you,



CodePudding user response:

Optical scanning, image recognition so commonly used function under no one came to grant instruction? The great spirit is how to implement?
  • Related