コード例 #1
0
        public double DistanceTo(Gesture other)
        {
            double[] current = new double[other.Count];
            double[] previous = new double[other.Count];

            current[0] = 2 * localDist(data[0], other.data[0]);
            for (int j = 1; j < other.Count; j++)
                current[j] = current[j - 1] + localDist(data[0], other.data[j]);
            for (int i = 1; i < data.Count; i++)
            {
                { double[] aux = current; current = previous; previous = aux; }
                current[0] = previous[0] + localDist(data[i], other.data[0]);
                for (int j = 1; j < other.data.Count; j++)
                {
                    double d = localDist(data[i], other.data[j]);
                    current[j] = Math.Min(Math.Min(current[j - 1], previous[j]), previous[j - 1] + d) + d;
                }
            }
            return current[other.data.Count - 1] / (data.Count + other.data.Count);
        }
        public void OnGestureCaptured(Gesture gesture)
        {
            if (Prototypes.Count == 0) return;

            double mindist = double.MaxValue;
            Gesture bestGesture = null;

            foreach (var g in Prototypes)
            {
                double distance = gesture.DistanceTo(g);
                if (distance < mindist)
                {
                    mindist = distance;
                    bestGesture = g;
                }
            }

            if (GestureRecognized != null)
                GestureRecognized(bestGesture.Name);
        }
コード例 #3
0
        public void OnWiimoteChanged(WiimoteState state)
        {
            bool buttonBpressed = state.ButtonState.B;
            Point3F sample = state.AccelState.Values;

            if (buttonBpressedOld)
            {
                if (buttonBpressed)
                    gesture.AddSample(new double[] { sample.X, sample.Y, sample.Z });
                else if (GestureCaptured != null)
                    GestureCaptured(gesture);
            }
            else
            {
                if (buttonBpressed)
                    gesture = new Gesture();
                else
                    ; //Nada
            }
            buttonBpressedOld = buttonBpressed;
        }
 public void AddPrototype(Gesture gesture)
 {
     Prototypes.Add(gesture);
 }
コード例 #5
0
 void gc_GestureCaptured(Gesture gesture)
 {
     gestureRecognizer.OnGestureCaptured(gesture);
 }