Of course our first Kinect for Windows SDK Project has to involve a Light Saber!

Description

Kinect Sabre

Augmented reality WPF C# application (with XNA) that adds a Sith Light Saber to your left hand.

Project Information URL: http://blogs.msdn.com/b/eternalcoding/archive/2011/06/13/unleash-the-power-of-kinect-for-windows-sdk.aspx
Update for the Kinect for Windows SDK v1: http://blogs.msdn.com/b/eternalcoding/archive/2012/02/09/kinect-keyboard-simulator-amp-kinect-sabre-for-kinect-for-windows-sdk-1-0.aspx

Project Download URL: http://www.catuhe.com/msdn/Kinect Sabre.zip (v1 Compatible version: http://www.catuhe.com/msdn/kinecttools.zip)

Kinect Sabre Screenshot

image

Code Snip:

void kinectRuntime_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
 {
     SkeletonFrame skeletonFrame = e.SkeletonFrame;

     bool player1 = true;

     foreach (SkeletonData data in skeletonFrame.Skeletons)
     {
         if (data.TrackingState == SkeletonTrackingState.Tracked)
         {
             foreach (Joint joint in data.Joints)
             {
                 if (joint.Position.W < 0.8f)
                     continue;
                 switch (joint.ID)
                 {
                     case JointID.HandLeft:
                         if (player1)
                             game.P1LeftHandPosition = joint.Position.ToVector3();
                         else
 game.P2LeftHandPosition = joint.Position.ToVector3();
                         break;
                     case JointID.HandRight:
                         if (player1)
                             game.P1RightHandPosition = joint.Position.ToVector3();
                         else
 game.P2RightHandPosition = joint.Position.ToVector3();
                         break;
                     case JointID.WristLeft:
                         if (player1)
                             game.P1LeftWristPosition = joint.Position.ToVector3();
                         else
 game.P2LeftWristPosition = joint.Position.ToVector3();
                         break;
                     case JointID.ElbowLeft:
                         if (player1)
                             game.P1LeftElbowPosition = joint.Position.ToVector3();
                         else
 game.P2LeftElbowPosition = joint.Position.ToVector3();
                         break;
                 }
             }

             if (player1)
             {
                 player1 = false;
                 game.P1IsActive = true;
             }
             else
 {
                 game.P2IsActive = true;
                 return;
             }
         }
     }

     if (player1)
         game.P1IsActive = false;

     game.P2IsActive = false;
 }

Contact Information:

Tag:

Kinect

The Discussion

  • User profile image
    Ian2

    Geek heaven ...

  • User profile image
    dijzon

    hell yeah

  • User profile image
    Dev

    Cool, a Syntax highlighter will be very cool thanks

    ------------------
    Sorry for my English...

  • User profile image
    davewill

    I'll have to download this and try it out just to determine if the text reference to "left hand" or the picture shown using "right hand" is the actual output.  Smiley

  • User profile image
    Deltakosh

    In fact it is effectively the left hand but the picture was inverted Big Smile

  • User profile image
    aL_

    hotness Wink

  • User profile image
    casey

    i cant get this to run

  • User profile image
    casey

    oops. it keeps saying can not open (.csproj) is not supported by this version of the application. i have Microsoft Visual Studio 2010 Express and whatever they told u to get on the sdk site. any ideas?

  • User profile image
    gduncan411

    @casey: That error usually means that C# (since you're trying to open a CSProj) is not installed, or installed fully.

    There's a couple different versions of Visual Studio 2010 Express. There's VB, C#, C++, Web and Phone versions (and one does not include the other). Can you confirm that you have the C# version installed (http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-csharp-express)?

  • User profile image
    Andy Goodfellow

    I have VS2010 (Full Version) and I'm getting the same errors. See below. Your thoughts?


    C:\Users\andyg\Repositories\KinectSabre\KinectSabre.Render\KinectSabre.Render\KinectSabre.Render.csproj : error : The project file 'C:\Users\andyg\Repositories\KinectSabre\KinectSabre.Render\KinectSabre.Render\KinectSabre.Render.csproj' cannot be opened.

    The project type is not supported by this installation.

    C:\Users\andyg\Repositories\KinectSabre\KinectSabre.Render\KinectSabre.RenderContent\KinectSabre.RenderContent.contentproj : error : The project file 'C:\Users\andyg\Repositories\KinectSabre\KinectSabre.Render\KinectSabre.RenderContent\KinectSabre.RenderContent.contentproj' cannot be opened.

    The project type is not supported by this installation.

  • User profile image
    gduncan411

    @Andy Goodfellow: Ah... In looking at the solution, those are XNA based project types. Do you have the XNA Game Studio v4 installed? http://www.microsoft.com/download/en/details.aspx?id=23714 (I didn't think of that in my first response... sorry about that...)

  • User profile image
    glenster75

    Stuck on RenderGames.cs UpdateColorTexture where it can't evaluate colorTexture.Width and colorTexture.Height for the for loop because it is null. Any hints as initiating colorTexture before that for loop so that it is not null?

  • User profile image
    Espionage724

    Can someone please upload a pre-compiled folder with the file(s)?

  • User profile image
    uforualways

    Hello, Greg Duncan Have you recorded any videos ?

     

  • User profile image
    gduncan411

    @uforualways: No, I can't say that I have...

  • User profile image
    nicosama

    i have a little problem it do not recognize "using KinectSabre.Render"
    have you a solution

    sorry for the english ^^

  • User profile image
    nicosama

    the error i have is

    The type or namespace name 'Render' does not exist in the namespace 'KinectSabre' (are you missing an assembly reference ?)

  • User profile image
    Clint

    @nicosama:I just opened up the project compiled and runs fine.  Do you have XNA installed?

  • User profile image
    casey

    still having the :\Users\andyg\Repositories\KinectSabre\KinectSabre.Render\KinectSabre.Render\KinectSabre.Render.csproj : error : The project file 'C:\Users\andyg\Repositories\KinectSabre\KinectSabre.Render\KinectSabre.Render\KinectSabre.Render.csproj' cannot be opened.

    The project type is not supported by this installation.

    C:\Users\andyg\Repositories\KinectSabre\KinectSabre.Render\KinectSabre.RenderContent\KinectSabre.RenderContent.contentproj : error : The project file 'C:\Users\andyg\Repositories\KinectSabre\KinectSabre.Render\KinectSabre.RenderContent\KinectSabre.RenderContent.contentproj' cannot be opened.

    The project type is not supported by this installation.

    i have xna installed and sq server 2008 and kinect skd.

    this is driving me nuts!

  • User profile image
    gduncan411

    @casey: As I understand it what happens is that Visual Studio will use ProjectTypeGuids value in the csproj to compare what the project needs against what's on the given machine.

    For KinectSabre.Render.csproj there's two;

    <ProjectTypeGuids>{6D335F3A-9D43-41b4-9D22-F6F17C4BE596};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> 

    Here's a good list for the ProjectTypeGuids

    http://www.mztools.com/Articles/2008/MZ2008017.aspx

    Type ProjectTypeGuids for this project are;

    Windows (C#) {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
    XNA (Windows) {6D335F3A-9D43-41b4-9D22-F6F17C4BE596}

    You've already said you have all these installed, so I'm not sure why you can't get this project to load...

    I've seen where someone with a like problem in another solution removed that line from the csprog file to get a project to load. I can't recommend this as it bypasses important system checks, but...

  • User profile image
    Deltakosh

    Yes, the XNA Game Studio 4 is required to run this sample.

    Another post on gestures:

    http://blogs.msdn.com/b/eternalcoding/archive/2011/07/04/gestures-and-tools-for-kinect.aspx

  • User profile image
    MarkE59

    I am trying to run this on a laptop that does not support hidef. I have changed it to reach instead but still getting an error.

    XNA Framework Reach profile requires TextureAddressMode to be Clamp when using texture sizes that are not powers of two.

     

  • User profile image
    Unbong_Choi

    ,glenster75 wrote

    Stuck on RenderGames.cs UpdateColorTexture where it can't evaluate colorTexture.Width and colorTexture.Height for the for loop because it is null. Any hints as initiating colorTexture before that for loop so that it is not null?

    Hi, I have the same situation as you. Did you get any solution?

    Please, Help me!!!

  • User profile image
    Miroslav

    Same problem here...

  • User profile image
    Judavi

    OWESOME!! Works great!

  • User profile image
    Moh

    Please does anyone know how I can create and navigate an avatar using the Kinect SDK if it has the capability of doing so? Thank you very much in anticipation.

  • User profile image
    Chuck

    I to had the same thing. I kept going through the messages and it would say download this and I would then I would have the failure records of the same contentproj type codes show and I would read on and it would tell you, oh yea, you have to download this and I would download it and again, the same problem. Now I have a hard drive full of crap that doesn't work. Not worth it. Glad I was just trying to play around with it and wasn't nothing serious. It's a beta version I guess. Depends on what connection you have whether you write all the lines in the program as it down loads. Give up myself. Don't need a saber light sword anyway.

  • User profile image
    nigelgos

    Won't compile for me :(

    The type or namespace name 'Research' does not exist...

    Sounds like it's to do with the sdk version but I have downloaded and installed the 01 Feb release. I had a beta sdk prior to this.

  • User profile image
    gduncan411

    @nigelgos:Yep, this was written in the Beta 1 time frame. I know he's got an updated version that should be available online soon, but in the mean time check out, http://robrelyea.wordpress.com/2012/02/01/k4w-code-migration-from-beta2-to-v1-0-managed/, which will help in the migration of code from the Beta to the RTM of the SDK

  • User profile image
    nigelgos

    @gduncan411 - Thanks for that. I had a quick play and got rid of alot of the issues but some required a bit more understanding of the code in order to re-jig things. I've given up now. Does anyone have a compiled binary file? I really want to swing a light saber :)

  • User profile image
    gduncan411

    @nigelgos:Keep an eye on David's blog, http://blogs.msdn.com/b/eternalcoding/. I know he has an updated version and I'm sure they will appear there soon...

  • User profile image
    nigelgos

    He posted it up yesterday [8th feb](http://blogs.msdn.com/b/eternalcoding/archive/2012/02/09/kinect-keyboard-simulator-amp-kinect-sabre-for-kinect-for-windows-sdk-1-0.aspx)

    Thanks the pointer.

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to send us feedback you can Contact Us.