net.sourceforge.javaocr.ocrPlugins.mseOCR
Class TrainingImageLoader

java.lang.Object
  extended by net.sourceforge.javaocr.scanner.DocumentScannerListenerAdaptor
      extended by net.sourceforge.javaocr.ocrPlugins.mseOCR.TrainingImageLoader
All Implemented Interfaces:
DocumentScannerListener

public class TrainingImageLoader
extends DocumentScannerListenerAdaptor

Utility class to load an image file, break it into individual characters, and create and store multiple TrainingImage objects from the characters. The source image must contain a range of characters specified in the character range passed into the load() method.

Author:
Ronald B. Cemer

Field Summary
private  int charValue
           
private  boolean debug
           
private  HashMap<Character,ArrayList<TrainingImage>> dest
           
private  DocumentScanner documentScanner
           
private static Logger LOG
           
 
Constructor Summary
TrainingImageLoader()
           
 
Method Summary
 DocumentScanner getDocumentScanner()
           
 void load(Image image, CharacterRange charRange, HashMap<Character,ArrayList<TrainingImage>> dest, String imageFilename)
           
 void load(String imageFilename, CharacterRange charRange, HashMap<Character,ArrayList<TrainingImage>> dest)
          Load an image containing training characters, break it up into characters, and build a training set.
 void processChar(PixelImage pixelImage, int x1, int y1, int x2, int y2, int rowY1, int rowY2)
           
 void setDebug(boolean debug)
           
 
Methods inherited from class net.sourceforge.javaocr.scanner.DocumentScannerListenerAdaptor
beginDocument, beginRow, endDocument, endRow, processSpace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

charValue

private int charValue

dest

private HashMap<Character,ArrayList<TrainingImage>> dest

debug

private boolean debug

documentScanner

private DocumentScanner documentScanner

LOG

private static final Logger LOG
Constructor Detail

TrainingImageLoader

public TrainingImageLoader()
Method Detail

getDocumentScanner

public DocumentScanner getDocumentScanner()
Returns:
The DocumentScanner instance that is used to load the training images. This is useful if the caller wants to adjust some of the scanner's parameters.

load

public void load(String imageFilename,
                 CharacterRange charRange,
                 HashMap<Character,ArrayList<TrainingImage>> dest)
          throws IOException
Load an image containing training characters, break it up into characters, and build a training set. Each entry in the training set (a Map) has a key which is a Character object whose value is the character code. Each corresponding value in the Map is an ArrayList of one or more TrainingImage objects which contain images of the character represented in the key.

Parameters:
imageFilename - The filename of the image to load.
charRange - A CharacterRange object representing the range of characters which is contained in this image.
dest - A Map which gets loaded with the training data. Multiple calls to this method may be made with the same Map to populate it with the data from several training images.
Throws:
IOException

setDebug

public void setDebug(boolean debug)

load

public void load(Image image,
                 CharacterRange charRange,
                 HashMap<Character,ArrayList<TrainingImage>> dest,
                 String imageFilename)
          throws IOException
Throws:
IOException

processChar

public void processChar(PixelImage pixelImage,
                        int x1,
                        int y1,
                        int x2,
                        int y2,
                        int rowY1,
                        int rowY2)
Specified by:
processChar in interface DocumentScannerListener
Overrides:
processChar in class DocumentScannerListenerAdaptor


Copyright © -2012. All Rights Reserved.