ActionVisualizer.MainWindow.detectGestures C# (CSharp) Метод

detectGestures() приватный Метод

private detectGestures ( ) : void
Результат void
        private void detectGestures()
        {
            ignoreFrames++;

            // Simple 1D gesture recognition heuristics.
            if (selectedChannels == 1)
            {
                foreach (List<int> subList in history)
                {
                    int signChanges = 0, bandwidth = 0, step = 0, lastSig = 0;
                    for (int i = 1; i < subList.Count; i++)
                    {
                        step++;
                        if (subList[i - 1] != 0)
                            lastSig = subList[i - 1];
                        if (subList[i] * lastSig < 0)
                        {
                            signChanges++;
                            bandwidth += step;
                            step = 0;
                        }
                    }

                    if (KF[0].isBoth && KF[0].inverse_state > 5)
                        gestureDetected.Text = "Two Handed ";
                    else if (signChanges == 0 && (lastSig != 0))
                        gestureDetected.Text = "Scrolling ";
                    else if (signChanges == 2 || signChanges == 1)
                        gestureDetected.Text = "SingleTap ";
                    else if (signChanges >= 3)
                        gestureDetected.Text = "DoubleTap ";

                    // Naive segmentation, not a primary concern.
                    if (subList.Count > 25 && gestureDetected.Text != "")
                    {
                        gestureDetected.Text = "";
                        subList.Clear();
                    }
                }
            }
            // We generate the combined vector V from each channel and do various segmentation related things here.
            else if (selectedChannels == 2)
            {
                double tot_X = 0, tot_Y = 0;
                foreach (KeyFrequency now in KF)
                {
                    tot_X += now.x;
                    tot_Y += now.y;
                }

                pointHist.Add(new Point(tot_X, tot_Y));

                if (!gesture_started && tot_X == 0 && tot_Y == 0)
                {
                    pointHist.Clear();
                    foreach (List<int> sublist in history)
                        sublist.Clear();
                    foreach (List<int> sublist in inverse_history)
                        sublist.Clear();
                }
                if (gesture_started && tot_X == 0 && tot_Y == 0)
                    motion_free++;
                if (tot_X != 0 || tot_Y != 0)
                {
                    gesture_started = true;
                    motion_free = 0;
                }

                // create the stroke representation for recognition.
                generateStroke(pointHist);
            }

            // Go check if a gesture was completed.
            gestureCompleted();
        }