Exemplo n.º 1
0
 protected void OnGestureRecognized(GestureModel gesture, double probability)
 {
     if (GestureReceived != null)
     {
         GestureEventArgs w = new GestureEventArgs(gesture, probability);
         GestureReceived(this, w);
     }
 }
Exemplo n.º 2
0
        /**
         * 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);
            }
        }
Exemplo n.º 3
0
        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;
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
 protected void OnGestureRecognized(GestureModel gesture, double probability)
 {
     if (GestureReceived != null)
     {
         GestureEventArgs w = new GestureEventArgs(gesture, probability);
         GestureReceived(this, w);
     }
 }
Exemplo n.º 6
0
 public void addGestureModel(GestureModel gm)
 {
     this.gesturemodel.Add(gm);
 }
Exemplo n.º 7
0
 public GestureEventArgs(GestureModel gesture, double probability)
 {
     Gesture = gesture;
     Probability = probability;
 }
Exemplo n.º 8
0
 public void addGestureModel(GestureModel gm)
 {
     this.gesturemodel.Add(gm);
 }