Easy Kinect Mouse Controller for Windows

This sample will show you how to build a simple controller for the Kinect that will let you control the mouse on your Windows desktop using a Kinect device.

C# (4.2 MB)
 
 
 
 
 
(2)
8,456 times
Add to favorites
10/3/2012
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question


  • How to use "IsInGripInteraction" without KinectRegion
    1 Posts | Last post June 23, 2014
    • Thank you for your help, Walt.
      One last question, I have a difficulty using IsInGripInteraction property in your script. Some tutorial tells me I need to create KinectRegion to use IsInGripInteraction. But I want this to be working on windows desktop enviroment, not just in an application with KinectRegion set. Would you please guide me to the way?
  • How to trigger Mouse Left Button double Click event when right hand is closed.
    2 Posts | Last post June 19, 2014
    • Hell Walt,
      
      Thanks for the great tutorial. I am wondering how we can add Mouse Left Button double Click event, hopely it triggers when right hand is closed. Native MS kinect support "Grip". Would you show me little more tutorial on "how to add more mouse event" to your current tutorial, please?
    • Hi quadratic,
      The code in MainWindow.xaml.cs already contains a method called "CheckForClickHold" which is using a timer to click the left mouse button if the user hovers over a location for a set period of time.  If I were you, I would probably write another, similar method called "CheckForGrip" and place the grip checking code in that method.  Then I would comment out the CheckForClickHold method call in the SensorSkeletonFrameReady method and substitute a call for your new method, something like:
      
      var leftClick = CheckForGrip(scaledRightHand);
      
      That will cause the SendMouseInput method in the next line of code to send the result of your grip check over to the mouse input handler in Windows, which should give you the effect you desire.
      
      Hope that helps you.
  • Error when running solution
    3 Posts | Last post May 16, 2013
    • Hey Walt, this is the error I'm getting.
      
      "Provide value on 'System.Windows.Baml2006.TypeConverterMarkupExtension' threw an exception." on the MainWindows.xaml file.
      
      I just want to know why?
      
      Thanks!
    • Tobias,  Your issue is a common problem with Visual Studio.  There are several things that might be causing the problem, none of which are related to the actual project.  You might check out this link for some possible solutions.  If you can't get it working, you might raise the issue on the Visual Studio forum where others apparently have had this same problem.
      
      http://connect.microsoft.com/VisualStudio/feedback/details/533882/provide-value-on-system-windows-baml2006-typeconvertermarkupextension-threw-an-exception
      
    • I ran into this same exact problem and spent lots of time trying to fix it. The issue was the icon in the XAML.
      
      Simply delete this line and run it.
      Icon="CursorControl.ico"
      
      P.S. Thanks for the code Walt!
  • Problems w/ sample?
    2 Posts | Last post October 10, 2012
    • So I see that the ScaleTo method in the sample code is based in an extension of the the Joint object - how can I bring this into my own custom application?
      
      Similiarly, with SystemParameters, I can see that it is in System.Windows, but in my own custom project, the only child of System.Windows is Forms, SystemParameters is not to be seen.
      
      Lastly, when I download the sample code, I get a NullPointerException in the xaml when I attempt to run it - why is this?
    • Hi Tobias,
      Thank you for the questions.  Let me see if I can answer them for you.
      
      1) The ScaleTo method is included in the Coding4Fun.Kinect.Wpf dll, which is in turn part of the Coding4Fun.Kinect project, which you can find here - http://c4fkinect.codeplex.com.
      
      2) To get SystemParameters, you should be able to reference System.Windows in your own code as I have done in my code with "using System.Windows;" in the source code.  You might have to add the reference into your own project if it is not there by default.
      
      3) Lastly, I am not sure where you are getting the null pointer exception, but you might be able to get rid of that by looking at the dependencies in the project, such as having the proper Kinect SDK (1.5), the Kinect Developer Toolkit, or the Coding4Fun packages.  If you post some more detail about your error like maybe a call stack or something, I might be able to help you further.