none
Source Code for Microsoft.Samples.Kinect.SwipeGestureRecognizer? RRS feed

  • Question

  • Hello all.

    Is the source code for Microsoft.Samples.Kinect.SwipeGestureRecognizer available anywhere?  I'd like to look it over in order to learn more about creating gestures for the Kinect.

    Thanks!

    Monday, July 9, 2012 7:50 PM

Answers

  • Hi EvaldoMC,

    I've not found the code for SwipeGestureRecognizer but I have been able to write my own, based off a different example, and duplicate the swipe left/right.  I've also already been able to extend on the example and create a "zoom in" and "zoom out" function!

    The example I used is located here:
    http://blogs.msdn.com/b/mcsuksoldev/archive/2011/08/08/writing-a-gesture-service-with-the-kinect-for-windows-sdk.aspx 

    It is not updated for SDK 1.5, so a little tweaking had to be done.

    The service works by recognizing segments skeletal segments within the gesture.  For example, for a "swipe left" gesture it will watch your right hand to:
    (1) start to the right of your right shoulder
    (2) travel to the center of your body
    (3) pass to the left of your left shoulder

    If all 3 of those conditions are met in a row, you've got yourself a gesture!

    In the same way, I wrote my own "zoom in" gesture by looking for the following conditions:
    (1) both hands between the shoulders
    (2) both hands travel to the left/right of their respective shoulder
    (3) both hands travel to the left/right of their respective elbow

    ... reverse that, and you've got yourself a "zoom out"!

    The example is pretty well put together.  It certainly is robust enough to handle small gestures for small scale applications.

    Events only fire after a gesture is recognized though.  So you can't, for example, dynamically spin a globe as your hands move up and down.  You do a gesture, and discrete action happens, then you do the gesture again if you want that action to repeat.

    You might also want to check out the Kinect Toolbox:
    http://kinecttoolbox.codeplex.com/

    It can be set up to detect gestures in the same way, but also has a math engine -- so you can write a function to define your gesture.

    I tried the toolbox, but it seemed to be slower to me.  I could have been doing something wrong with my setup though (I write demo apps, then let someone else crank out production code).

    Good luck.  Give me a yell on this thread if you have questions about it!


    Thursday, July 12, 2012 8:53 PM
  • Hi EvaldoMC & littlelighty,

    I've uploaded the gesture library I wrote, along with a small demo application that uses it.  I've also written a simple blog post that explains the basic of how to use the library.  You can check it out at the link below, the source code is linked in the post:

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

    Wednesday, July 25, 2012 5:29 PM

All replies

  • I'm also looking for more informations about it...
    Thursday, July 12, 2012 7:21 PM
  • Hi EvaldoMC,

    I've not found the code for SwipeGestureRecognizer but I have been able to write my own, based off a different example, and duplicate the swipe left/right.  I've also already been able to extend on the example and create a "zoom in" and "zoom out" function!

    The example I used is located here:
    http://blogs.msdn.com/b/mcsuksoldev/archive/2011/08/08/writing-a-gesture-service-with-the-kinect-for-windows-sdk.aspx 

    It is not updated for SDK 1.5, so a little tweaking had to be done.

    The service works by recognizing segments skeletal segments within the gesture.  For example, for a "swipe left" gesture it will watch your right hand to:
    (1) start to the right of your right shoulder
    (2) travel to the center of your body
    (3) pass to the left of your left shoulder

    If all 3 of those conditions are met in a row, you've got yourself a gesture!

    In the same way, I wrote my own "zoom in" gesture by looking for the following conditions:
    (1) both hands between the shoulders
    (2) both hands travel to the left/right of their respective shoulder
    (3) both hands travel to the left/right of their respective elbow

    ... reverse that, and you've got yourself a "zoom out"!

    The example is pretty well put together.  It certainly is robust enough to handle small gestures for small scale applications.

    Events only fire after a gesture is recognized though.  So you can't, for example, dynamically spin a globe as your hands move up and down.  You do a gesture, and discrete action happens, then you do the gesture again if you want that action to repeat.

    You might also want to check out the Kinect Toolbox:
    http://kinecttoolbox.codeplex.com/

    It can be set up to detect gestures in the same way, but also has a math engine -- so you can write a function to define your gesture.

    I tried the toolbox, but it seemed to be slower to me.  I could have been doing something wrong with my setup though (I write demo apps, then let someone else crank out production code).

    Good luck.  Give me a yell on this thread if you have questions about it!


    Thursday, July 12, 2012 8:53 PM
  • I'm having difficulty adapting code from an older version of the SDK,
    I'm currently working on-screen interaction (Hover Button / Hover Control) 

    See if you can help me...

    Friday, July 13, 2012 3:48 AM
  • Hello EvaldoMC,

    I would suggest adapting only the gesture portions of the example I linked, and use the KinectSensorManager to handle connecting to the Kinect.  Check out the examples that come with the SDK -- specifically the "Kinect Explorer" and "Slideshow Gestures" example, which will give you a good overview of how the KinectSensorManager works as well as an introduction to gestures.

    The "Slideshow Gesture" project does not use the KinectSensorManager (if I remember correctly), so porting the that project to use the manager will help understand how to quickly use it to get a Kinect app up and running.  Microsoft did a great job with this manager -- it is quick and easy to get an app talking to the Kinect and parsing events.

    Now you have a slide show viewer, using the KinectSensorManager, which already has support for the swipe gestures.  Go back into the example code I linked to and start to dissect how the gestures are being captured and pulled out.  When I was done, I had a created a library (so I could include it easily in any project) with the following files and structure:

    +- Project Root
    +- Segments
    ----- MenuSegments.cs
    ----- SwipeLeftSegments.cs
    ----- SwipeRightSegments.cs
    ----- ZoomSegments.cs
    - Gestures.cs
    - GestureController.cs
    - GestureEnumTypes.cs
    - GestureEventArgs.cs
    - IRelativeGestureSegment.cs

    The "Segments" directory holds all the gesture definition files.  The example broke each segment check class into a different file; I chose to put all classes into a single file (personal preference).  So, "SwipeLeftSegments.cs" has the three segment class files from the examples rolled into a single file.

    With a little bit of tweaking the files above are all you need to create a reusable class library to capture gesture events in any Kinect enabled application!


    Friday, July 13, 2012 4:12 PM
  • Hi Evil Closet Monkey,

    I'm kind of new to this Kinect thing and language C#. And I've been working on adding more gesture in addition to swipe left and right. A few days ago I found this site and saw the example you gave. As you said, it was written for an older version and does not adapt to SDK 1.5. So I was working on it, and yet I have the same problem as EvaldoMC did. Just wondering if it is possible for you to upload the source code. It would be very helpful. I can understand if you don't feel like doing it and it is perfectly fine. Anyways, many thanks to you.

    Friday, July 20, 2012 5:39 AM
  • Hi LittleLighty,

    I will see what I can do over the next several days.  I can certainly ZIP up the code and post it somewhere, and I'll see about writing up a short description of what I did and what folks might want look at a better way of doing.

    Friday, July 20, 2012 4:05 PM
  • Hi Evil Closet Monkey,

    I've been working on the same thing these days, but I still can't get it right. It is kind of depressing when you thought you might eventually get it right this time, and then found out that you are wrong again the very next second. I tried to google all the info I needed, like what exactly are the changes between two versions. I changed Runtime into KinectSensor, I changed Microsoft.Research.Kinect.dll into Microsoft.Kinect.dll, and etc, yet there are still some code parts I have no idea how to deal with. For example, in "KinectConnection.cs",  the method "sensor_SkeletonFrameReady" is a nightmare to me. I have no clue how to get it right. Really need some (or a lot) help with that. Thank you again.

    Tuesday, July 24, 2012 5:52 AM
  • (Sorry for my bad English)

    I changed all references still gave error.

    I'm redoing the code (as suggested Evil Closet Monkey), but I'm newbie too.

    In some parts of code that do not understand

    Evil Closet Monkey if you can help us I also thank.

    Tuesday, July 24, 2012 2:58 PM
  • Hi all,

    I am working on a blog post with code and descriptions, to make things as clear as I can on what I did and how I suggest things be done.  I am striving to have it done by the end of today.

    In the meantime, I would suggest that you look at one of the demos included in the Kinect SDK that uses the KinectSensorManager class (in Microsoft.Kinect.Toolkit).  Use these examples to learn how to get connected to and use the services coming from the Kinect.  DO NOT use the example I linked above to access the Kinect itself.

    What I did for the Gestures was create a library that takes the skeleton updates and acts upon them, firing events of it own.  What this does is allow you to connect to and deal with the Kinect hardware in any way.  Just send the gesture library a skeleton update and it will tell you if a gesture was executed.

    I'll do my best to get that detailed blog post put together for everyone as quickly as possible.

    Tuesday, July 24, 2012 3:13 PM
  • Hi EvaldoMC & littlelighty,

    I've uploaded the gesture library I wrote, along with a small demo application that uses it.  I've also written a simple blog post that explains the basic of how to use the library.  You can check it out at the link below, the source code is linked in the post:

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

    Wednesday, July 25, 2012 5:29 PM
  • Thanks, I'll look at later post here.
    Wednesday, July 25, 2012 5:41 PM
  • Thank you so much Evil Closet Monkey. I can finally get it work and create my own gesture now. Really really appreciate that!!
    Monday, July 30, 2012 6:25 AM