Tess4J: Invalid memory access

故事扮演 提交于 2019-12-28 07:03:05

问题


I am trying to use Tess4J in my project to extract text from an image. I am getting the following error when I try run the OCR: Exception in thread "main" java.lang.Error: Invalid memory access

    try {
        File imageFile = new File("example4.jpg");
        Tesseract instance = Tesseract.getInstance(); // JNA Interface Mapping
        //Tesseract1 instance = new Tesseract1();
        String result = instance.doOCR(imageFile);
        System.out.println(result);
    } catch (Exception e) {
        e.printStackTrace();
    }   

回答1:


you can set the data path i am getting same problem when i set the data path that problem is solved
try try this

instance1.setDatapath("D://Hotel_project//Tess4J-1.2-src//Tess4J//tessdata");




回答2:


You must define the datapath of the traineddata to use. If you don't specify the language it will assume it is eng.

For instance, it your project path is PROJECT and your trained data is at PROJECT/data/tessdata/eng.traineddata

tess.setDatapath("data");
tess.setLanguage("eng");

Remember that "tessdata" shoundn't be in the path you specify




回答3:


if you are running on 32 bit JVM

Please try with Tesseract1 instance = new Tesseract1();

instead of using Tesseract instance = Tesseract.getInstance();



来源:https://stackoverflow.com/questions/19894890/tess4j-invalid-memory-access

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!