Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tessj4 - Error opening data file ./tessdata/eng.traineddata

Tags:

java

tess4j

I have this problem in my web application in Tomcat 9:

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

I create folder C:\Tess4J from Tess4J 3.0.4 zip, with subfolders:

  • dist
    • tess4j-3.0.jar
  • lib
    • LIBS
  • nbproject
  • src
  • tessdata
    • Downloaded ZIP with languages and extracted here
  • test

In catalina.properties i add:

  • C:/Tess4J/dist/tess4j-3.0.jar,C:/Tess4J/lib

In environments i try to add both, and doesn't work:

  • TESSDATA_PREFIX --> C:/Tess4J
  • TESSDATA_PREFIX --> C:/Tess4J/tessdata

Then i invoke my servlet whit doOCR method, and i've got error.

May you help me please?

like image 416
kete nefrega Avatar asked Mar 21 '16 14:03

kete nefrega


People also ask

Why did I get an error when opening the tessdata file?

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!

Why does tesseract fail to recognize text from an image?

When you are using tesseract to recognize text from an image in python, you may get this error: pytesseract.pytesseract.TesseractError: (1, 'Error opening data file \Program Files (x86)\Tesseract-OCR\eng.traineddata Please make sure the TESSDATA_PREFIX environment variable is set to your "tessdata" directory.

What is the Directory of Tesseract-OCR tessdata?

C:\Program Files (x86)\Tesseract-OCR\ essdatais the directory of Tesseract-OCR tessdata. Run this code, you will find this error is fixed. Category: Python


1 Answers

You have to choose the up directory, in your case C:\Tess4J, try it:

tessInst= new Tesseract();
tessInst.setDatapath("C:\\Tess4J"); 
tessInst.setLanguage("eng");

Sorry about my english

like image 162
Genarito Avatar answered Oct 03 '22 08:10

Genarito