0
votes
 public static void main(String[] args) throws TesseractException {
    ITesseract instance = new Tesseract();
    instance.setLanguage("osd");
    instance.setDatapath("/usr/local/Cellar/tesseract/3.04.01_1/share/");
    String tent = instance.doOCR(new File("/Users/qwf/Desktop/111.jpg"));
    System.out.println(tent);
}

when i run the code ,there is 2 error:

Failed loading language 'osd'

Tesseract couldn't load any languages!

i don't konw how tess4j find there is any languages can be use

and when i run the "tesseract --list-langs" in iterm

the result is "eng osd"

i think the tesseract works well but why tess4j don't work

i have set the TESSDATA_PREFIX environment variable

echo $TESSDATA_PREFIX
output : /Users/qwf/tessdata/3.04.01_1/

i install tessdata by homebrew

1

1 Answers

-1
votes

Wrong order: set the datapath before the language.

instance.setDatapath("/usr/local/Cellar/tesseract/3.04.01_1/share/");
instance.setLanguage("osd");