1

I have used the SwipeGestureRecognizer where it has only swipe left and swipe right gesture recognization but i want swipe up/down for both the hands how to do it ..

Any idea......

SwipeGestureRecognizer is a dll so I am unable to see the logic for the swipe recognizer.

  public event EventHandler<KinectGestureEventArgs> SwipeLeftDetected;
  public event EventHandler<KinectGestureEventArgs> SwipeRightDetected;

Can any one have the code for SwipeGestureRecognizer logic so that I can understand and try to implement for swipe up also.

Thanks in advance!

pnuts
  • 58,317
  • 11
  • 87
  • 139

4 Answers4

2

I'm taking a bit of a shot in the dark here, but if you're referring to the Kinect Toolbox, there's a Codeplex project set up for it. Specifically, you should take a look at SwipeGestureDetector.cs.

Actually, looking at your description and the code on Codeplex, you might not be using the Kinect Toolbox, but this might be a good time to start. Also, it should be relatively simple to add in Up/Down swipe recognition to the linked .cs file.

Coeffect
  • 8,772
  • 2
  • 27
  • 42
2

Have a look here http://blog.exceptontuesdays.com/post/27989563563/gestures-with-microsoft-kinect-for-windows-sdk-v1-5

It doesn't have UP/DOWN gestures but anyway it has a lot of others.

Source code is available there as well.

 switch (e.GestureType)
            {
                case GestureType.Menu:
                    Debug.WriteLine("Menu");
                    Gesture = "Menu";
                    break;
                case GestureType.WaveRight:
                    Debug.WriteLine("Wave Right");
                    Gesture = "Wave Right";
                    break;
                case GestureType.WaveLeft:
                    Debug.WriteLine("Wave Left");
                    Gesture = "Wave Left";
                    break;
                case GestureType.JoinedHands:
                    Debug.WriteLine("Joined Hands");
                    Gesture = "Joined Hands";
                    break;
                case GestureType.SwipeLeft:
                    Debug.WriteLine("Swipe Left");
                    Gesture = "Swipe Left";
                    break;
                case GestureType.SwipeRight:
                    Debug.WriteLine("Swipe Right");
                    Gesture = "Swipe Right";
                    break;
                case GestureType.ZoomIn:
                    Debug.WriteLine("Zoom In");
                    Gesture = "Zoom In";
                    break;
                case GestureType.ZoomOut:
                    Debug.WriteLine("Zoom Out");
                    Gesture = "Zoom Out";
                    break;

                default:
                    break;
NoWar
  • 36,338
  • 80
  • 323
  • 498
  • 3
    To comment on the lack of up/down gestures, they could be easily added by using the left/right swipes as examples. You would just need to change the reference points that you are wanting to pass to recognize the event. For example: instead of tracking the x-coord of the hand past the shoulder, you could track the y-coord past the shoulder center. – Nicholas Pappas Oct 16 '12 at 18:35
  • This link is now broken. If this content has been moved, I'd appreciate it if you could update the link - this seems useful! – Benjamin Biggs Sep 03 '15 at 08:23
1

I think you are using kinect.toolbox. As @Coeffect reffered you to the link of the source code you can access the source code and change it as you want. here is a very usefull resource showing how to use kinect.toolbox and also how to add new gestures to it. You can add Swipe up gesture very similarly. I think you can add something like this to SwipeGestureDetector.cs

LookforGesture()
{

     // from down to up
     if (ScanPositions ((P1, P2) => Math.Abs ??(p2.X - p1.X) <0.20f, 
       (P1, P2) => p2.Y - p1.Y <0.01f, (P1, P2) => 
       Math.Abs ??(p2.Y - p1.Y)> 0.2f, 250, 2500))
     {
         RaiseGestureDetected ("SwipeUp");
         return;
     }
     ...
 }
mahsa.teimourikia
  • 1,664
  • 9
  • 32
  • 64
  • Very good answer! Could u share code for UP/DOWN gestures as well as for direct hit, pls? – NoWar Oct 09 '12 at 11:05
  • This was only a guess from the Swipe gestures that are already implemented in kinect.toolbox... You should add it to SwipeGestureDetector.cs -> LookForGesture(), and after compiling you can use the new dll files... What do you mean by it does not compile? – mahsa.teimourikia Oct 09 '12 at 11:59
0

Swipes are very easy gestures to recognize. Use simple math. You need to "cut" the gesture into 3 phases. Start, middle and end

If you want to recognize swipe from top to bottom your start gesture is when your hand is somewhere above a head. For example 10 cm above your head. So in every frame you check if your hand is 10 cm above your hand. If yes you need to check will it get to the middle possition. I would use here hand on the height of my shoulders. I would also implement way mark so cause IMO this kind of gesture should be made in straight line. If you the hand went from above the head to shoulder in straight line you need to check will get to the end position. I would use height somewhere below the chest. That way using simple math and just by checking position of your hand in each frame you can implemenet your own swipe recognition

Fixus
  • 4,631
  • 10
  • 38
  • 67
  • He asked about READY code to to use where we can use ready-to-use events. – NoWar Oct 09 '12 at 11:01
  • 1
    @Peretz cool story bro. I'll will ask for full plan of robbing the bank. I won't give him ready code cause I don't have it but I'll give him some advices that may be more usefull than ready code. But nevermind. I'm happy for you :) Thanks for tip about my work here. I'll be a better person from now. – Fixus Oct 09 '12 at 12:56