程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> tesseract ocr-Tesseract OCR - tess4j tessdata目錄設置問題

tesseract ocr-Tesseract OCR - tess4j tessdata目錄設置問題

編輯:編程綜合問答
Tesseract OCR - tess4j tessdata目錄設置問題

eclipse 總說tessdata找不到

已在 run configuration中設置TESSDATA_PREFIX
public static void main(String[] args) {

    System.out.println(new File(System.getenv("TESSDATA_PREFIX"),"./tessdata/eng.traineddata").exists());
    File imageFile = new File("f:\\testocr.png");
    ITesseract instance = new Tesseract();  // JNA Interface Mapping

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

true
Exception in thread "main" java.lang.Error: Invalid memory access
at com.sun.jna.Native.invokePointer(Native Method)
at com.sun.jna.Function.invokePointer(Function.java:470)
at com.sun.jna.Function.invoke(Function.java:404)
at com.sun.jna.Function.invoke(Function.java:315)
at com.sun.jna.Library$Handler.invoke(Library.java:212)
at com.sun.proxy.$Proxy0.TessBaseAPIGetUTF8Text(Unknown Source)
at net.sourceforge.tess4j.Tesseract.getOCRText(Tesseract.java:429)
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:284)
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:205)
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:189)
at com.cone.englishutill.OCRUtil.main(OCRUtil.java:18)
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

最佳回答:


自己解決了,雖然繞了一步,提供出來參考
instance.setDatapath("youdir");
看官網教程沒這步,是哪裡設置不對,有知道的說一下

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved