JAVA Tess4j doOCR() not working, Exception “Invalid memory access”

拟墨画扇 提交于 2019-12-05 16:03:53

You probably would need to call setDatapath to tell it where to find the tessdata folder for .traineddata files.

Also, you may no longer need to set jna.library.path variable as tess4j now can auto-extract and load the native libraries.

In this case selection of language also matters - I was processing image with lang=hin+eng, but it was giving the same error (mentioned in this post)

As English text was less in the image so I changed lang=hin and I got the expected result.

public static void main(String[] args) {
        Tesseract in = new ReadImageText().getTesseractInstance("C:/Program Files (x86)/Tesseract-OCR/tessdata/", "hin");
        try {
            String resultText = in.doOCR(new File("C:/EA/app-result/im/01-001/34/0.png"));
            log.info("resultText {}", resultText);
        } catch (TesseractException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!