2017-02-23 43 views
0

我已經將Asprise OCR SDK下載到我的系統,但我無法在自己的代碼中實現OCR。直到運行時才收到錯誤消息。在您自己的代碼中實現Asprise OCR

現在我得到的錯誤是:錯誤:無法找到或加載主類

曾有人試圖在自己的代碼來實現OCR,如果又如何?

我跟着從Asprise開發商指南,但一直不成功

測試代碼: 進口com.asprise.ocr.Ocr; import java.io. *;

公共類OCRTester {

public static void main(String[] args) { 

    Ocr.setUp(); // one time setup 
    Ocr ocr = new Ocr(); 
    ocr.startEngine("eng", Ocr.SPEED_FASTEST); 
    String s = ocr.recognize(new File[] { new File("images\test.png") }, Ocr.RECOGNIZE_TYPE_ALL, 
      Ocr.OUTPUT_FORMAT_PLAINTEXT, 0, null); 
    System.out.println("RESULT: " + s); 
    ocr.stopEngine(); 

} 

}

回答

0
I have extracted OCR from images using tesseract library 

[please go through this link][1] 


    [1]: https://github.com/tesseract-ocr/tesseract 


public class Test{ 

    public static void main(String[] args) { 
     File inputFile=new File(filePath); 
      System.out.println("processing file ...."+inputFile.getName()); 
      Tesseract instance = Tesseract.getInstance(); // 
      instance.setLanguage("hin+eng"); 
      BufferedImage bufferedImage=ImageIO.read(inputFile); 
      String ocrText = instance.doOCR(ImageHelper.convertImageToGrayscale(bufferedImage)); 
      System.out.println(ocrText); 
    } 
}