BAEL-3874 - OCR with Tesseract

This commit is contained in:
Anshul BANSAL
2020-03-08 17:46:11 +02:00
parent b88006def4
commit ea65b0d074
14 changed files with 641 additions and 80 deletions

View File

@@ -0,0 +1,33 @@
package com.baeldung.tesseract;
import org.bytedeco.javacpp.BytePointer;
import org.bytedeco.leptonica.PIX;
import org.bytedeco.tesseract.TessBaseAPI;
import org.bytedeco.tesseract.Tesseract;
public class TesseractPlatformExample {
@SuppressWarnings("resource")
public static void main(String[] args) {
try {
TessBaseAPI tessApi = new TessBaseAPI();
tessApi.Init("src/main/resources/tessdata", "eng", 3);
tessApi.SetPageSegMode(1);
PIX image = org.bytedeco.leptonica.global.lept.pixRead("src/main/resources/images/baeldung.png");
tessApi.SetImage(image);
BytePointer outText = tessApi.GetUTF8Text();
System.out.println(outText.getString());
tessApi.End();
Tesseract t = new Tesseract();
t.
} catch(Exception e) {
e.printStackTrace();
}
}
}