#About
Moses is mouse gesture recognition library implemented in ActionScript 3.
Core elements of library are:
- Samplers (handles mouse event and dispatch SamplerEvent with sampling data)
- Recognizers (handles SamplerEvent and process recognition on each registered pattern)
- Patterns (provide information about mouse gesture)
- Algorithm (recognition algorithm)
Pattern is a simple objects with name, data that describes pattern (it could be for example list of points) and algorithm used for recognition. Patterns are registered in recognizer. Recognizer handles sampler event for getting user data and examine it with each pattern's algorithm.
// 1. create sampler
var sampler:Sampler = new DistanceSampler(displayObjectToDraw);
// 2. create recognizer
var recognizer:Recognizer = new DefaultRecognizer();
// 3. register some patterns
recognizer.register(patternOne);
recognizer.register(patternTwo);
// 4. handle recognizer event
recognizer.addEventListener(RecognizerEvent.RECOGNITION_PROCEEDED, recognitionProceeded)
// 5. inject samplet to recognizer
recognizer.sampler = sampler
// 6. activate sampler
sampler.activate();
next you should define handler for recognizer event:
private function recognitionProceeded(e:RecognizerEvent):void {
if (e.recognized) {
trace("Pattern", e.recognitionData.bestMatching.pattern.name, "recognized");
}
else {
trace("No pattern recognized");
}
}
pattern could be defined as:
var patternOne:Pattern = new FlatPointsPattern("one", [0,0,10,10,20,20], new new DefaultMosesAlgorithm(0.6, 4));
You can use your own pattern definitions and own algorithms.
Moses library implements set of Moses algorithms. They are described on wiki
You must implement Algorithm interface which provides match method. It must return Matching object which include information about how much user data is similar to pattern. You can use DistanceSampler and DefaultRecognizer or implements your own.
Thanks to Didier Brun and his Mouse Gesture Recognition. I did not use his code but his concept gave me some inspirations. Thanks!