Java OCR
alphaScreenshots
Description
Java OCR is a suite of pure java libraries for image processing and character recognition. Small memory footprint and lack of external dependencies makes it suitable for android development. Provides modular structure for easier deployment
Java OCR Web SiteFeatures
- Cross Platform
- 100% Java
- Graphical User Interface
- suitable for android
User Ratings
User Reviews
-
I had no trouble using the GUI to train and analyze a simple photo of some text. I also quickly created my own code that did the same, with no UI (just a console app). Fast and easy! However, my goal is to run this on Android [as is mentioned elsewhere here - right?] but I think there's a show-stopper: JavaOCR uses AWT and ImageIO (javax.imageio, that is), neither of which are supported under Android. That said, this seems to be a quite worthwhile effort, for what it is. /rob PS - Here's a quick example of how to use this code. I created 4 training files containing images of "123456789", "ABCDE", "A" and "4", because with just the first two files, the OCR confused "A" and "4" sometimes (not surprising). The test files had "45A3" and "46B3" in them, and the code got it correct! <code> package net.robcranfill.javaocr.test; import java.awt.image.BufferedImage; import java.io.File; import java.util.ArrayList; import java.util.List; import java.util.Map; import javax.imageio.ImageIO; import net.sourceforge.javaocr.gui.GUIController; import net.sourceforge.javaocr.gui.meanSquareOCR.TrainingImageSpec; import net.sourceforge.javaocr.ocrPlugins.mseOCR.CharacterRange; import net.sourceforge.javaocr.ocrPlugins.mseOCR.OCRScanner; import net.sourceforge.javaocr.ocrPlugins.mseOCR.TrainingImage; public class Test1 { /** * @param args - unused. */ public static void main(String[] args) { new Test1().test1(); } private void test1() { // All files are here: String imageLoc = "D:/proj/_misc/JavaOCR/test1/"; // Load 4 training files List<TrainingImageSpec> images = new ArrayList<TrainingImageSpec>(0); TrainingImageSpec tis = null; tis = new TrainingImageSpec(); tis.setFileLocation(imageLoc + "1-9-Arial.png"); tis.setCharRange(new CharacterRange('1', '9')); images.add(tis); tis = new TrainingImageSpec(); tis.setFileLocation(imageLoc + "A-E-Arial.png"); tis.setCharRange(new CharacterRange('A', 'E')); images.add(tis); tis = new TrainingImageSpec(); tis.setFileLocation(imageLoc + "A-actual-small.png"); tis.setCharRange(new CharacterRange('A', 'A')); images.add(tis); tis = new TrainingImageSpec(); tis.setFileLocation(imageLoc + "4-actual-small.png"); tis.setCharRange(new CharacterRange('4', '4')); images.add(tis); // Run the OCR on our 'test' files OCRScanner ocrScanner = new OCRScanner(); try { Map<Character, List<TrainingImage>> trainingImages = GUIController.getTrainingImageHashMap(images); ocrScanner.addTrainingImages(trainingImages); // test image 1 String targImageLoc = imageLoc + "45A3-crop-rot-inv.png"; BufferedImage targetImage = ImageIO.read(new File(targImageLoc)); String text = ocrScanner.scan(targetImage, 0, 0, 0, 0, null); System.out.printf("OCR %s: '%s'\n", targImageLoc, text); // test image 2 targImageLoc = imageLoc + "46B3-crop-rot-inv.png"; targetImage = ImageIO.read(new File(targImageLoc)); text = ocrScanner.scan(targetImage, 0, 0, 0, 0, null); System.out.printf("OCR %s: '%s'\n", targImageLoc, text); } catch (Exception e) { e.printStackTrace(); } } } </code>
-
I'm getting the same error when I try train. In the GUI, it isn't clear what values I am supposed to enter for starting and ending characters (A and Z did not work for the corresponding training images, didn't have any luck with ASCII values when I tried it either). A walkthrough with the GUI and some hints on using the code would be really helpful.
-
Excellent work.
-
very good program javaocr.
-
Fantastic library, works perfectly when I compile from the source myself. However I'm scratching my head here when trying to use the latest JAR (javaocr-20100605.zip). The TrainingImageLoader class expects a Component as the first parameter of load(). What for? I can't seem to find any JavaDocs to tell me, the latest TrainingImageLoader source (from SVN) doesn't expect this parameter.
-
First, if you are lost I'll recommend you take a look at the performMSEOCR method in the guiController class. It's the method that does the "processing" per-se. kudos to Rob Cranfill for the code, a little bi of searching and found the method. Second, i really like this library. Although I wish i knew how to make it a bit more accurate/use more than 1 font at once. Other than that, it's great. The only working java OCR I've been able to find that doesn't have any external dependencies. If i could make a recommendation it would be the ability to use more than one font. Wonderful library, I'm using it in my sudoku solver. 4/5.