fr.lri.swingstates.gestures.dollar1
Class Dollar1Classifier

java.lang.Object
  extended by fr.lri.swingstates.gestures.AbstractClassifier
      extended by fr.lri.swingstates.gestures.dollar1.Dollar1Classifier

public class Dollar1Classifier
extends AbstractClassifier

A classifier that implements $1 algorithm to classify gestures.

Author:
Caroline Appert

Constructor Summary
Dollar1Classifier()
           
 
Method Summary
 int addClass(java.lang.String className)
          Adds a class of gestures to this classifier.
 void addExample(java.lang.String className, Gesture example)
          Adds a gesture example to this classifier.
 java.lang.String classify(Gesture g)
          Recognizes a gesture.
 double getCurrentDistance()
           
 java.util.Vector<Gesture> getExamples(java.lang.String className)
          Returns the vector of gesture examples for a given class.
 double getMaximumDistance()
           
 int getNbPoints()
           
 CPolyLine getRepresentative(java.lang.String className)
          Returns a graphical representation for a given class of gestures.
 double getSizeScaleToSquare()
           
static Dollar1Classifier newClassifier(java.io.File filename)
          Builds a new classifier by loading its definition in a file.
static Dollar1Classifier newClassifier(java.lang.String file)
          Builds a new classifier by loading its definition in a file.
static Dollar1Classifier newClassifier(java.net.URL url)
          Builds a new classifier by loading its definition in a url.
 void removeClass(java.lang.String className)
          Removes a class of gestures from this classifier.
 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 setMaximumDistance(double maximumDistance)
          Sets a minimum score threshold for recognition.
 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 fr.lri.swingstates.gestures.AbstractClassifier
getClassesNames, getTemplate, getTemplates, save, setTemplate
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Dollar1Classifier

public Dollar1Classifier()
Method Detail

classify

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

Specified by:
classify in class AbstractClassifier
Parameters:
g - The gesture to recognize
Returns:
The name of the class of gestures that best fit to g.

getRepresentative

public 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.

Specified by:
getRepresentative in class AbstractClassifier
Parameters:
className - the name of the gesture class.
Returns:
A representative polyline for the gesture class having name className.

newClassifier

public static Dollar1Classifier newClassifier(java.lang.String file)
Builds a new classifier by loading its definition in a file.

Parameters:
file - The name of the file containing the definition of the classifier.
Returns:
The newly created classifier.

newClassifier

public static Dollar1Classifier newClassifier(java.io.File filename)
Builds a new classifier by loading its definition in a file.

Parameters:
filename - The name of the file containing the definition of the classifier.
Returns:
The newly created classifier.

newClassifier

public static Dollar1Classifier newClassifier(java.net.URL url)
Builds a new classifier by loading its definition in a url.

Parameters:
url - The url containing the definition of the classifier.
Returns:
The newly created classifier.

addClass

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

Overrides:
addClass in class AbstractClassifier
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).

removeClass

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

Overrides:
removeClass in class AbstractClassifier
Parameters:
className - The name of the class of gestures to remove.

getNbPoints

public int getNbPoints()
Returns:
The number of points used for resampling a gesture during $1 recognition process.

getSizeScaleToSquare

public double getSizeScaleToSquare()
Returns:
The size of the bounding box side used for rescaling a gesture during $1 recognition process.

getMaximumDistance

public double getMaximumDistance()
Returns:
The maximum score threshold for recognition.

setMaximumDistance

public void setMaximumDistance(double maximumDistance)
Sets a minimum score threshold for recognition. If the distance is greater than this maximum distance, the gesture is not recognized (i.e. method classify returns null.

Parameters:
maximumDistance - The minimum score threshold for recognition.

getCurrentDistance

public double getCurrentDistance()
Returns:
The distance of the last recognized gesture.

sortedClasses

public 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.

Specified by:
sortedClasses in class AbstractClassifier
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).

removeExample

public void removeExample(Gesture gesture)
Removes a gesture example from this classifier.

Specified by:
removeExample in class AbstractClassifier
Parameters:
gesture - the gesture to remove

addExample

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

Specified by:
addExample in class AbstractClassifier
Parameters:
className - the gesture example's class
example - the gesture example

renameClass

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

Overrides:
renameClass in class AbstractClassifier
Parameters:
previousClassName - The current name of this class of gestures
newClassName - The new name of this class of gestures

reset

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

Overrides:
reset in class AbstractClassifier

getExamples

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

Specified by:
getExamples in class AbstractClassifier
Parameters:
className - The name of the class
Returns:
The set of examples for the class className.
Throws:
java.lang.UnsupportedOperationException