Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not reading provided ./tessdata/eng.traineddata #9

Closed
brnrc opened this issue Feb 10, 2015 · 8 comments
Closed

Not reading provided ./tessdata/eng.traineddata #9

brnrc opened this issue Feb 10, 2015 · 8 comments

Comments

@brnrc
Copy link

brnrc commented Feb 10, 2015

Just cloned the repo, built the .jar with

mvn assembly:single

Added the tess4j-2.0.0-SNAPSHOT-all.jar file to my classpath and tried to use it.
On the first call to

instance.doOCR(file);

it spits this out:

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!
AdaptedTemplates != NULL:Error:Assert failed:in file ..\..\classify\adaptmatch.cpp, line 174

Double checked and yes, I do have the TESSDATA_PREFIX set to:C:\Users\ribeirob\Applications\nguyenq\tess4j\src\main\resources\

@4F2E4A2E
Copy link
Collaborator

Hi there!

Please post here the main method or class you where are calling the doOCR() method, thx.

@brnrc
Copy link
Author

brnrc commented Feb 11, 2015

Sure!

        // Tess4J
        Tesseract instance = Tesseract.getInstance();
        instance.setPageSegMode(4);
        try {
            String content = instance.doOCR(page);
        } catch (TesseractException e) {
            e.printStackTrace();
        }

@4F2E4A2E
Copy link
Collaborator

The correct use of the TESS4J-API with the default tessdata folder:

File imageFile = new File("C:\\random.png");
Tesseract instance = Tesseract.getInstance();

//In case you don't have your own tessdata, let it also be extracted for you
File tessDataFolder = LoadLibs.extractTessResources("tessdata");

//Set the tessdata path
instance.setDatapath(tessDataFolder.getAbsolutePath());

try {
    String result = instance.doOCR(imageFile);
    System.out.println(result);
} catch (TesseractException e) {
    System.err.println(e.getMessage());
}

Please use the latest release: 1.4.1

@brnrc
Copy link
Author

brnrc commented Feb 11, 2015

Thank you, this worked!
Is there any documentation on this?

By the way, this led me to another bug #10

@4F2E4A2E
Copy link
Collaborator

We are working hard on the project right now, refactoring and testing are taking time, but soon we will deliver better documentation.
Thanks for creating the issue, please help us grow and let us know who is using tess4j: https://github.com/nguyenq/tess4j/wiki/Who-is-using-Tess4J

@ramesh-indutech
Copy link

ramesh-indutech commented Apr 27, 2017

Thank you, this worked! [4F2E4A2E]

@erochOnGit
Copy link

@4F2E4A2E Thank you, i'ts working now. I hope we could find more easily the doc in the futur ;) (maybe put the Tutorial directly in the readme file for a direct visioning in github ?)

@housme
Copy link

housme commented May 11, 2019

Is there a distinction between vertical reading and horizontal reading in picture reading?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants