1

I am trying to detect upward and downward swipes using the same logic used for Right and Left swipe. Thats what I came up with.

// Upward Swipe
        if (ScanPositions((p1, p2) => Math.Abs(p2.Y - p1.Y) > 0.4f,  // Height
            (p1, p2) => p2.Y - p1.Y > -0.01f, // Progression Upwards
            (p1, p2) => Math.Abs(p2.X - p1.X) < 0.2f, // Length
            SwipeMininalDuration, SwipeMaximalDuration))// Duration
        {
                RaiseGestureDetected("Upward Swipe Gesture Detected");
            return;
        }

        // Downward Swipe
        if (ScanPositions((p1, p2) => Math.Abs(p2.Y - p1.Y) > 0.4f,  // Height
            (p1, p2) => p2.Y - p1.Y < 0.01f, // Progression Downwards
            (p1, p2) => Math.Abs(p2.X - p1.X) < 0.2f, // Length
            SwipeMininalDuration, SwipeMaximalDuration))// Duration
        {
                RaiseGestureDetected("Downward Swipe Gesture Detected");
            return;
        }

Using similar logic as for Swipe left/right, for the heightFuntion, I have said that the difference between p2 and p1 in the y axis should be more than 40 and so on and so forth (as you can see from the code). I was very confident that this would work but it still doesn’t give me accurate gesture outputs when I tested. Sometimes it gives output “downward swipe detected” when in fact it’s upward. Sometimes it gets mistaken between Left swipe and upward swipe. Can you tell me where I am making a mistake? Does the algorithm I just posted contain errors? Or I need to modify something somewhere else in the Kinect Toolbox? I want to be able to detect upward, downward, left and right hand swipes in the same application. Thanks

Nicholas Pappas
  • 10,439
  • 12
  • 54
  • 87
  • I've not used the Kinect Toolbox algorithms much, but the following library (using a different method of recognition) already has a swipe up and down: https://github.com/EvilClosetMonkey/Fizbin.Kinect.Gestures – Nicholas Pappas Mar 27 '13 at 13:36

0 Answers0