将Asprise OCR实现到您自己的代码中

时间:2017-02-23 10:08:47

标签: java ocr implementation

我已将Asprise OCR SDK下载到我的系统,但我无法在自己的代码中实现OCR。我在运行时才收到任何错误。

我现在得到的错误是:错误:无法找到或加载主类

是否有人试图在自己的代码中实现OCR,如果是这样的话?

我跟随Asprise的开发者指南但是没有成功

测试代码: import 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();

}

}

1 个答案:

答案 0 :(得分: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);
    }
}
相关问题