I am looking out for an example code or API name from OCR (Optical character recognition) in Java using which I can extract all text present from an image file. Without comparing it with any image which I am doing using below code.
public class OCRTest {
static String STR = "";
public static void main(String[] args) {
OCR l = new OCR(0.70f);
l.loadFontsDirectory(OCRTest.class, new File("fonts"));
l.loadFont(OCRTest.class, new File("fonts", "font_1"));
ImageBinaryGrey i = new ImageBinaryGrey(Capture.load(OCRTest.class, "full.png"));
STR = l.recognize(i, 1285, 654, 1343, 677, "font_1");
System.out.println(STR);
}
}
You can try javaocr on sourceforge: http://javaocr.sourceforge.net/
There is also a great example with an applet which uses Encog: http://www.heatonresearch.com/articles/42/page1.html
That said, OCR requires a lot of power, so it means that if you are looking for a heavy use, you should look after OCR libraries written in C and integrate that with Java.
OCR is hard. So be sure to qualify your needs before adventuring yourself in it.
Tesseract and opencv (with javacv for integration for instance) are common choices. There are also commercial solutions such as ABBYY FineReader Engine and ABBYY Cloud OCR SDK.
You can try Tess4j or JavaCPP Presets for Tesseract. I perfer later as its easier than the former. Add the dependency to your pom `
` And its simple to code
Tess4j is little complex as its requires specific VC++ redistributable package to be installed.
Open Source OCR engine is available from Google for OCR. It can be processed using CMD. You can process the CMD using java for web applications easily.
Please visit https://www.youtube.com/watch?v=Mjg4yyuqr5E . You will get the step by step details to process OCR using CMD.