fr.lri.swingstates.gestures
Class AbstractClassifier

java.lang.Object
  extended by fr.lri.swingstates.gestures.AbstractClassifier
Direct Known Subclasses:
Dollar1Classifier, RubineClassifier, ShapeMatchingClassifier

public abstract class AbstractClassifier
extends java.lang.Object

The base class for a gesture classifier.

Author:
Caroline Appert

Constructor Summary
AbstractClassifier()
           
 
Method Summary
 int addClass(java.lang.String className)
          Adds a class of gestures to this classifier.
abstract  void addExample(java.lang.String className, Gesture example)
          Adds a gesture example to this classifier.
abstract  java.lang.String classify(Gesture g)
          Recognizes a gesture.
 java.util.ArrayList<java.lang.String> getClassesNames()
           
abstract  java.util.Vector<Gesture> getExamples(java.lang.String className)
          Returns the vector of gesture examples for a given class.
abstract  CPolyLine getRepresentative(java.lang.String className)
          Returns a graphical representation for a given class of gestures.
 java.util.Vector<java.awt.geom.Point2D> getTemplate(java.lang.String className)
           
 java.util.ArrayList<java.util.Vector<java.awt.geom.Point2D>> getTemplates()
           
 void removeClass(java.lang.String className)
          Removes a class of gestures from this classifier.
abstract  void removeExample(Gesture gesture)
          Removes a gesture example from this classifier.
 void renameClass(java.lang.String previousClassName, java.lang.String newClassName)
          Renames a class of gestures.
 void reset()
          Resets this classifier (i.e.
 void save(java.io.File filename)
          Saves the definition of this classifier in a file.
 void setTemplate(java.lang.String className, java.util.Vector<java.awt.geom.Point2D> template)
          Sets the template gesture for a given existing class of gestures in this classifier.
abstract  java.util.Vector<Score> sortedClasses(Gesture g)
          Computes a sorted list of classes contained in this recognizer from the best match to the the worst match given a gesture.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractClassifier

public AbstractClassifier()
Method Detail

removeExample

public abstract void removeExample(Gesture gesture)
                            throws java.lang.UnsupportedOperationException
Removes a gesture example from this classifier.

Parameters:
gesture - the gesture to remove
Throws:
java.lang.UnsupportedOperationException

getRepresentative

public abstract CPolyLine getRepresentative(java.lang.String className)
Returns a graphical representation for a given class of gestures. The graphical representation is the one which minimizes the distance with vector of features characterizing this gesture class.

Parameters:
className - the name of the gesture class.
Returns:
A representative polyline for the gesture class having name className.

addClass

public int addClass(java.lang.String className)
Adds a class of gestures to this classifier.

Parameters:
className - The name of the class of gestures to add.
Returns:
the index of this class in the list of classes (-1 if this class already exists and thus has not been added).

addExample

public abstract void addExample(java.lang.String className,
                                Gesture example)
                         throws java.lang.UnsupportedOperationException
Adds a gesture example to this classifier.

Parameters:
className - the gesture example's class
example - the gesture example
Throws:
java.lang.UnsupportedOperationException

getExamples

public abstract java.util.Vector<Gesture> getExamples(java.lang.String className)
                                               throws java.lang.UnsupportedOperationException
Returns the vector of gesture examples for a given class.

Parameters:
className - The name of the class
Returns:
The set of examples for the class className.
Throws:
java.lang.UnsupportedOperationException

removeClass

public void removeClass(java.lang.String className)
Removes a class of gestures from this classifier.

Parameters:
className - The name of the class of gestures to remove.

renameClass

public void renameClass(java.lang.String previousClassName,
                        java.lang.String newClassName)
Renames a class of gestures.

Parameters:
previousClassName - The current name of this class of gestures
newClassName - The new name of this class of gestures

classify

public abstract java.lang.String classify(Gesture g)
Recognizes a gesture.

Parameters:
g - The gesture to recognize
Returns:
The name of the class of gestures that best fit to g.

sortedClasses

public abstract java.util.Vector<Score> sortedClasses(Gesture g)
Computes a sorted list of classes contained in this recognizer from the best match to the the worst match given a gesture.

Parameters:
g - The gesture
Returns:
a vector of scores for all the classes registered in this classifier sorted from the best match (index 0) to the worst match (index n-1), with n the number of classes. A score is a couple (class_name, distance).

save

public void save(java.io.File filename)
Saves the definition of this classifier in a file.

Parameters:
filename - The name of the file where to write the definition of the classifier.

reset

public void reset()
Resets this classifier (i.e. removes all the classes of gestures).


setTemplate

public void setTemplate(java.lang.String className,
                        java.util.Vector<java.awt.geom.Point2D> template)
Sets the template gesture for a given existing class of gestures in this classifier.

Parameters:
className - the name of the class of gestures.
template - the template for the class className.

getTemplate

public java.util.Vector<java.awt.geom.Point2D> getTemplate(java.lang.String className)
Parameters:
className - the name of the class of gestures.
Returns:
the template for the class className if it exists, null otherwise.

getClassesNames

public java.util.ArrayList<java.lang.String> getClassesNames()
Returns:
The list of gesture class names in this classifier.

getTemplates

public java.util.ArrayList<java.util.Vector<java.awt.geom.Point2D>> getTemplates()
Returns:
The list of templates in this classifier (in the order corresponding to the classes names order returned by getClassesNames).