public class BasicStrokeRecognizer extends Object implements StrokeRecognizer
A BasicStrokeRecognizer uses a classifier to perform classification. Different kinds of classifiers use different classification algorithm (e.g. Gaussian, Laplace, parametric, nonparametric, etc.). Suppose a classifier has been trained on square, circle, and triangle. When a user sketches a stroke, the classifier will try to determine how closely the strokes resembles each of the trained strokes by generating a confidence value for each stroke. On a scale of 0 through 100, if a stroke receives 95 for being a square, 40 for circle, and 5 for triangle, then it is verly likely that the strokes is a square.
Constructor and Description |
---|
BasicStrokeRecognizer()
Construct a basic recognizer that performs recognition using a
WeightedEuclideanClassifier, the default features, and an
ApproximateStrokeFilter.
|
BasicStrokeRecognizer(Classifier classifier)
Construct a basic recognizer that performs recognition using
the given classifier, the default features, and an
ApproximateStrokeFilter.
|
BasicStrokeRecognizer(Classifier classifier,
FeatureExtractor[] extractors,
StrokeFilter filter)
Construct a classifying recognizer that classifies with the
given classifier, set of feature extractors, and filter.
|
BasicStrokeRecognizer(Reader trainingFile)
Construct a basic recognizer that trains on the gestures in the
training file.
|
BasicStrokeRecognizer(Reader[] trainingFiles)
Construct a basic recognizer that trains on the gestures in the
training files.
|
Modifier and Type | Method and Description |
---|---|
static FeatureExtractor[] |
defaultFeatureExtractors()
Initialize an array of feature extractors which are used to
produce a feature set from a gesture.
|
FeatureSet |
extractFeatures(TimedStroke s)
First filter the stroke, then extract the features from the
filtered copy stroke by running each of the feature extractors
on the copy, in order, and setting the corresponding
i'th feature in the returned feature set to the
extracted value from the i'th feature extractor.
|
Classifier |
getClassifier()
Return the classifier that is used to perform
classification.
|
StrokeFilter |
getStrokeFilter()
Return the stroke filter that is used to preprocess
the strokes.
|
RecognitionSet |
strokeCompleted(TimedStroke s)
Perform recognition on the given completed stroke.
|
RecognitionSet |
strokeModified(TimedStroke s)
Returns NO_RECOGNITION; BasicStrokeRecognizer only operates
on completed strokes.
|
RecognitionSet |
strokeStarted(TimedStroke s)
Returns NO_RECOGNITION; BasicStrokeRecognizer only operates
on completed strokes.
|
void |
train(SSTrainingModel model)
This function takes in a SSTrainingModel, builds a TrainingSet
object from the examples in the model, and trains the
classifier with the training set data.
|
public BasicStrokeRecognizer()
defaultFeatureExtractors()
public BasicStrokeRecognizer(Classifier classifier)
defaultFeatureExtractors()
public BasicStrokeRecognizer(Classifier classifier, FeatureExtractor[] extractors, StrokeFilter filter)
public BasicStrokeRecognizer(Reader trainingFile) throws Exception
Exception
public BasicStrokeRecognizer(Reader[] trainingFiles) throws Exception
Exception
public static final FeatureExtractor[] defaultFeatureExtractors()
Be default the following set of feature extractors are used:
public FeatureSet extractFeatures(TimedStroke s) throws ClassifierException
If the feature extractor array is empty return null.
ClassifierException
public StrokeFilter getStrokeFilter()
public Classifier getClassifier()
public RecognitionSet strokeCompleted(TimedStroke s)
strokeCompleted
in interface StrokeRecognizer
public RecognitionSet strokeModified(TimedStroke s)
strokeModified
in interface StrokeRecognizer
public RecognitionSet strokeStarted(TimedStroke s)
strokeStarted
in interface StrokeRecognizer
public void train(SSTrainingModel model) throws ClassifierException
The following algorithm is applied:
ClassifierException
Copyright © 2025 Central Laboratory of the Research Councils. All Rights Reserved.