hhreco.recognition
Class HHRecognizer

java.lang.Object
  extended byhhreco.recognition.HHRecognizer
All Implemented Interfaces:
MultiStrokeRecognizer, StrokeRecognizer

public class HHRecognizer
extends java.lang.Object
implements MultiStrokeRecognizer

This is a general purpose recognizer in which feature extractors and the classifier can be user-specified. By default, the magnitudes of Zernike's moments to the 8th order are used as features.


Field Summary
static double CX
           
static double CY
           
static double SIZE
           
 
Constructor Summary
HHRecognizer()
          Create a recognizer that uses the default Zernike Moments feature extractor and the default SVM classifier.
HHRecognizer(FeatureExtractor[] extractors)
          Create a recognizer that uses the specified set of feature extractors and the default SVM classifier.
HHRecognizer(FeatureExtractor[] extractors, TrainableClassifier c)
          Create a recognizer that uses the specified set of feature extractors and the classifier.
HHRecognizer(TrainableClassifier c)
          Create a recognizer that uses the default Zernike Moments feature extractor and the specified classifier.
 
Method Summary
 int addAndRetrain(MSTrainingModel model)
          Add the given set of data to the existing training set and retrain the recognizer.
 int addAndRetrain(java.lang.String type, TimedStroke[] strokes)
          Add the given shape to the existing training set and retrain the recognizer.
static FeatureExtractor[] defaultFeatureExtractors()
           
static FeatureSet extractFeatures(FeatureExtractor[] extractors, TimedStroke[] strokes)
          Extract features from the given set of strokes.
static TimedStroke[] preprocess(TimedStroke[] s, ApproximateStrokeFilter approxFilter, InterpolateStrokeFilter interpFilter, java.awt.geom.AffineTransform at)
          This preprocessing routine normalizes the scaling and the translation of the given shape.
 RecognitionSet sessionCompleted(TimedStroke[] strokes)
          Perform recognition on the given shape.
 RecognitionSet strokeCompleted(TimedStroke s)
          Invoked when a stroke is completed.
 RecognitionSet strokeModified(TimedStroke s)
          Invoked when a stroke has been modified, for example, points have been added to the stroke.
 RecognitionSet strokeStarted(TimedStroke s)
          Invoked when a stroke starts.
 int train(MSTrainingModel model)
          Extract features from the training examples and train the classifier with them.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SIZE

public static double SIZE

CX

public static double CX

CY

public static double CY
Constructor Detail

HHRecognizer

public HHRecognizer()
Create a recognizer that uses the default Zernike Moments feature extractor and the default SVM classifier.


HHRecognizer

public HHRecognizer(FeatureExtractor[] extractors)
Create a recognizer that uses the specified set of feature extractors and the default SVM classifier.


HHRecognizer

public HHRecognizer(TrainableClassifier c)
Create a recognizer that uses the default Zernike Moments feature extractor and the specified classifier.


HHRecognizer

public HHRecognizer(FeatureExtractor[] extractors,
                    TrainableClassifier c)
Create a recognizer that uses the specified set of feature extractors and the classifier.

Method Detail

defaultFeatureExtractors

public static FeatureExtractor[] defaultFeatureExtractors()

addAndRetrain

public int addAndRetrain(java.lang.String type,
                         TimedStroke[] strokes)
Add the given shape to the existing training set and retrain the recognizer.


addAndRetrain

public int addAndRetrain(MSTrainingModel model)
Add the given set of data to the existing training set and retrain the recognizer.


train

public int train(MSTrainingModel model)
Extract features from the training examples and train the classifier with them. The recognizer is trained from scratch, any previously existing training data will be thrown away.


extractFeatures

public static FeatureSet extractFeatures(FeatureExtractor[] extractors,
                                         TimedStroke[] strokes)
Extract features from the given set of strokes.


strokeStarted

public RecognitionSet strokeStarted(TimedStroke s)
Description copied from interface: StrokeRecognizer
Invoked when a stroke starts. This occurs when the mouse down event has been detected.

Specified by:
strokeStarted in interface StrokeRecognizer

strokeModified

public RecognitionSet strokeModified(TimedStroke s)
Description copied from interface: StrokeRecognizer
Invoked when a stroke has been modified, for example, points have been added to the stroke. It is probably safe to assume that this will be called every time a point is added to a stroke.

Specified by:
strokeModified in interface StrokeRecognizer

strokeCompleted

public RecognitionSet strokeCompleted(TimedStroke s)
Description copied from interface: StrokeRecognizer
Invoked when a stroke is completed. This occurs when the mouse up event has been detected.

Specified by:
strokeCompleted in interface StrokeRecognizer

sessionCompleted

public RecognitionSet sessionCompleted(TimedStroke[] strokes)
Perform recognition on the given shape. The shape is assumed to have been scale and translation normalized.

Specified by:
sessionCompleted in interface MultiStrokeRecognizer

preprocess

public static TimedStroke[] preprocess(TimedStroke[] s,
                                       ApproximateStrokeFilter approxFilter,
                                       InterpolateStrokeFilter interpFilter,
                                       java.awt.geom.AffineTransform at)
This preprocessing routine normalizes the scaling and the translation of the given shape. The size becomes SIZE x SIZE, and the center of the shape locates at (0,0). The transform parameters are recorded in the 'at' passed in. It also approximates and interpolates the set of strokes using the specified filter.