public Distribution ClassifySignal(Gesture signal) { var distribution = new Distribution(); var sampledSignal = FeatureExtractor.SampleSignal(signal); foreach (var s in trainingSet) { distribution.AddEntry(s.Label, DTWAlgorithm.CalcDistance(s, sampledSignal)); } return distribution; }
// gesture recognition callbacks public void OnGestureRecognized(GestureRecognitionService source, Distribution distribution) { if (source == internalRecognitionService) { if (distribution.BestDistance > 8) return; RunOnUiThread(() => vibrator.Vibrate(100)); } else if (source == externalRecognitionService) { if (distribution.BestDistance > 8) return; RunOnUiThread(() => Toast.MakeText(this, "Gesture " + distribution.BestMatch + " recognized", ToastLength.Short).Show()); } if (distribution.BestMatch == "left") { PreviousSlide(); } else if (distribution.BestMatch == "right") { NextSlide(); } else if (distribution.BestMatch == "pause") { SwitchPause(); } }