protected void OnGestureRecognized(GestureModel gesture, double probability) { if (GestureReceived != null) { GestureEventArgs w = new GestureEventArgs(gesture, probability); GestureReceived(this, w); } }
/** * This method recognize a specific gesture, given to the procedure. * For classification a bayes classification algorithm is used. * * @param g gesture to classify */ public GestureModel classifyGesture(Gesture g) { // Calculate the denominator, Bayesian double sum = 0; foreach (var model in gesturemodel) { sum += model.DefaultProbability * model.GetMatchProbability(g); } GestureModel recognized = null; // which gesture has been recognized double recogprob = Int32.MinValue; // probability of this gesture double probgesture = 0; // temporal value for bayes algorithm double probmodel = 0; // temporal value for bayes algorithm foreach (var model in gesturemodel) { double tmpgesture = model.GetMatchProbability(g); double tmpmodel = model.DefaultProbability; if (((tmpmodel * tmpgesture) / sum) > recogprob) { probgesture = tmpgesture; probmodel = tmpmodel; recogprob = ((tmpmodel * tmpgesture) / sum); recognized = model; } } // a gesture could be recognized if (recogprob > 0 && probmodel > 0 && probgesture > 0 && sum > 0) { this.lastprob = recogprob; return(recognized); } else { // no gesture could be recognized return(null); } }
public GestureModel FinishTrainingSession() { if (!this.analyzing && !this.learning) { if (this.trainsequence.Any()) { // Training the model with this.trainsequence.Count gestures... this.learning = true; GestureModel m = new GestureModel(); m.Train(this.trainsequence); this.classifier.addGestureModel(m); this.trainsequence = new List<Gesture>(); this.learning = false; return m; } } return null; }
public GestureModel FinishTrainingSession() { if (!this.analyzing && !this.learning) { if (this.trainsequence.Any()) { // Training the model with this.trainsequence.Count gestures... this.learning = true; GestureModel m = new GestureModel(); m.Train(this.trainsequence); this.classifier.addGestureModel(m); this.trainsequence = new List <Gesture>(); this.learning = false; return(m); } } return(null); }
protected void OnGestureRecognized(GestureModel gesture, double probability) { if (GestureReceived != null) { GestureEventArgs w = new GestureEventArgs(gesture, probability); GestureReceived(this, w); } }
public void addGestureModel(GestureModel gm) { this.gesturemodel.Add(gm); }
public GestureEventArgs(GestureModel gesture, double probability) { Gesture = gesture; Probability = probability; }
public void addGestureModel(GestureModel gm) { this.gesturemodel.Add(gm); }