Content Archived

This content is no longer current. Our recommendation for up to date content: http://channel9.msdn.com/Series/KinectQuickstart/Skeletal-Tracking-Fundamentals

Skeletal Tracking Fundamentals (Beta 2 SDK)

Sign in to queue

The Discussion

  • User profile image
    Alex

    Superb. Microsoft is back.

  • User profile image
    Bruno Alves

    Muito bom isto!
    Abre novas e incríveis possibilidades!!!

    Testarei assim que puder!

  • User profile image
    adam

    cant wait to play with all this! thank you

  • User profile image
    Michael Scherotter

    Well done, Dan! You make it look very easy - I can't wait to try it out!

  • User profile image
    Joshy

    that's too cool, i cant wait to try it myself.

  • User profile image
    Chris

    Can you use Kinect directly from a Silverlight app?

  • User profile image
    nadia

    Great! I tried the kinect and it is fantastic!

  • User profile image
    ebraminio

    GREAT!

  • User profile image
    Henry ramirez

    AWESOME!!!!!!!!!!!!!!!!!!!!!!

  • User profile image
    Ray Chambers

    This is amazeaballs! - Have already got my feet and elbow tracked etc.. awesome :) Will now and try some simple if statements to detect if balls are touching... all progress haha - well done and thankyou!

  • User profile image
    Squirrel

    Just curious, is finger tracking going to become available at some point? I see loads more of potential for this if it is

  • User profile image
    El Pibe

    Great tutorial and had fun with Kinect. If it could only talk back to me Wink

  • User profile image
    Dan

    @El Pibe: While it technically wouldn't be through your Kinect, you can use Text-To-Speech (TTS) to have a computerized-style voice talk back to you. The TTS engine is built into Microsoft.Speech APIs

  • User profile image
    Bas

    If two of the six skeletons are tracked... why are the other four returned?

  • User profile image
    Carlos Bittencourt

    Thank you!!!!!

  • User profile image
    alex

    is it possible to post the complete code. I have some problems to have all this coded together... thanks!

  • User profile image
    Dan

    @alex: Yes, the full source code is the first link in the article, posted here for your convenience - http://files.ch9.ms/coding4fun/KinectForWindowsSDKQuickstarts.zip

  • User profile image
    Patrick

    This is really great, but do you have any examples of how to do gesture tracking?

  • User profile image
    Deacon Frost

    Nice.

  • User profile image
    Dan

    @Patrick: For some best practices watch Ali Vassigh and Arturo Toledo's talk during the Kinect SDK Beta Launch - Designing for the Body: UX Considerations for Kinect Applications as that discusses gestures and gesture interpretation.   

  • User profile image
    Alex

    Hi,

    I can't get the Examples running. When I try to start any of the Quick Start Projects VS2010 shows an "Unspecified Error". Here's the stack trace. Can anyone help me please!?

    System.Runtime.InteropServices.COMException (0x80004005): Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
    at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
    at Ankh.VS.SolutionExplorer.SolutionExplorerWindow.get_SolutionExplorerFrame()
    at Ankh.VS.SolutionExplorer.SolutionExplorerWindow.Initialize()
    at Ankh.VS.VsActivatorCommand.OnExecute(CommandEventArgs e)
    at Ankh.Commands.CommandMapItem.OnExecute(CommandEventArgs e)
    at Ankh.Commands.CommandMapper.Execute(AnkhCommand command, CommandEventArgs e)

  • User profile image
    Alex

    Hi,

    I've fixed the problem. It was due to a plugin which I didn't even need and deactivated. All samples work just fine. Looking forward to play arround with the SDK :)

    A.

  • User profile image
    Barzimeron

    Anyone want to be a guinea pig for me? I have Pong working on my computer and am looking for someone to try my .exe.

    Thanks,

    Barzimeron

  • User profile image
    Logan

    when I add in the SetEllipsePosition(...) it gives me the error:
    'Microsoft.Research.Kinect.Nui.Joint' does not contain a definition for 'ScaleTo' and no extension method 'ScaleTo' accepting a first argument of type 'Microsoft.Research.Kinect.Nui.Joint' could be found (are you missing a using directive or an assembly reference?)

    I added a reference to Microsoft.Research.Kinect, and Coding4Fun.Kinect.Wpf as well as the two using statements for the Microsoft Research references

    Thanks, Logan

  • User profile image
    Momentum

    Exelente para realizar muchisimas aplicaciones realmente muy muy bueno

    Very good for make good aplications in some way .

    Im very glad to see these new hardward by Microsoft

  • User profile image
    Rock

    Great tutorial, thanks a lot.

    Is there a way to get the xyz position data of the tracked joints? Maybe output in a matrix in some way?
    If anyone knows how this can be done, please let me know!

  • User profile image
    Paul

    What's the trick to getting:
    1) The player index to activate and
    2) The joints to establish tracking?

    I have to gesticulate wildly to accomplish either of these, and it doesn't happen reliably. Somehow, it doesn't seem deterministic.

  • User profile image
    Pradeep

    The Joint object does not seem to have the scaleTo method any more. I get compile error when n I try to use the method.

    ScaleTo is not a member of 'Microsoft.Research.Kinect.Nui.Joint'

  • User profile image
    Santhosh

    Awesome Dan,

    Thank you for the samples and I have been able to create an application using this and control through hand gestures :). Works great and everyone liked it.

    Now cant wait for the release version of the SDK. Sure you guys must have lots of advancements.

    I failed to find more information on TransformSmoothParameters and ScaleTo on how to control the distance from the sensor and still be able to render a standard size skeleton everytime.

    Appreciate if you can share something on this.

    Regards
    Santhosh

  • User profile image
    omar

    Hi, I have a problem, I try running this code sample using c # and KinectForWindowsSDKQuickstarts I have the following error:

    WAS NullReferenceException unhandled by user code.

    In the line:

    SetEllipsePosition (headEllipse, skeleton.Joints [JointID.Head]);

    I have no problem with the other examples just this.

    thanks for your help

  • User profile image
    Firdosh Tangri

    @Omar - Thats because when you start the app none of the Skeletons are being tracked so the skeleton variable is null. This should fix it

    //set position
    if (skeleton != null)
    {
    SetEllipsePosition(headEllipse, skeleton.Joints[JointID.Head]);
    SetEllipsePosition(leftEllipse, skeleton.Joints[JointID.HandLeft]);
    SetEllipsePosition(rightEllipse, skeleton.Joints[JointID.HandRight]);
    }

    Cheers,
    Firdosh

  • User profile image
    omar

    THANK YOU Firdosh.
    I solved my problem. Although it seems strange that this detail was not mentioned in this tutorial.

  • User profile image
    Thomas

    The article says "A Joint position returns X,Y,Z values as explained below..."

    But how does one get the z position of a joint?

  • User profile image
    omarfuzzer

    How do I downloadCoding4Fun.Kinect.WinForm.dll?

  • User profile image
    michaelgree​nwald

    Thanks, these tutorials are great.

    How would I go about changing the color of an ellipse with hand movement? Here's what I have so far:

    private void SetEllipseProperties(FrameworkElement ellipse, Joint joint)
            {
                var scaledJoint = joint.ScaleTo(640, 480, .5f, .5f);
    
                // change position
                Canvas.SetLeft(ellipse, scaledJoint.Position.X);
                Canvas.SetTop(ellipse, scaledJoint.Position.Y);
               
                //change color
                ellipse.Fill = someColorFunction(scaledJoint.Position.Y);
                
            }

    but it doesn't like ellipse.Fill. It tells me "System.Windows.FrameworkElement' does not contain a definition for 'Fill' and no extension method 'Fill' accepting a first argument of type 'System.Windows.FrameworkElement' could be found (are you missing a using directive or an assembly reference?)", yet here, myEllipse.Fill is directly changed.

    I'm very new at this -- any help is appreciated!

    Michael

  • User profile image
    Alexey

    Can I see only part of skeletan for example in a sitting pose?

  • User profile image
    David

    Say if i dont want to use the Ellipse but i want to use the mouse Cursor, how do i do this?

  • User profile image
    Hieu

    Yah. Got it!!
    Tks alot.

  • User profile image
    Irfan

    hi..
    how do i add to track other parts..
    not switch but to add..
    currently the program track head,left hand & right hand,
    how do i make it track maybe, left feet & right feet too?
    i actually try to add the SetEllipsePosition but it come out that it is defined more than once

  • User profile image
    outforce

    hey guys,

    this is some exciting stuff. i was trying the code out and everything works really gr8.
    the only problem i am facing is my application freezes after 8sec. like i can see the Ellipses moving with my movements but it just freezes after 8 secs.

    please help!!!
    thank you!!

  • User profile image
    irfan

    Hi thanks for this videos but i have a question,
    how do i get the x & y coordinates? as i want to use it to control the x & y coordinates of the mouse cursor

    Irfan

  • User profile image
    Fernando Cardenas

    I have the same problem:

    Thanks, these tutorials are great.

    How would I go about changing the color of an ellipse with hand movement? Here's what I have so far:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    private void SetEllipseProperties(FrameworkElement ellipse, Joint joint)
    {
    var scaledJoint = joint.ScaleTo(640, 480, .5f, .5f);

    // change position
    Canvas.SetLeft(ellipse, scaledJoint.Position.X);
    Canvas.SetTop(ellipse, scaledJoint.Position.Y);

    //change color
    ellipse.Fill = someColorFunction(scaledJoint.Position.Y);

    }
    but it doesn't like ellipse.Fill. It tells me "System.Windows.FrameworkElement' does not contain a definition for 'Fill' and no extension method 'Fill' accepting a first argument of type 'System.Windows.FrameworkElement' could be found (are you missing a using directive or an assembly reference?)", yet here, myEllipse.Fill is directly changed.

    I'm very new at this -- any help is appreciated!

    Michael

  • User profile image
    Manuel

    No me funciona el scaleto.
    Pone que no se encontró el método ScaleTo en el joint.

  • User profile image
    piresbruno

    @Alex:Can you tell me how do you solved that problem? I have the same issue and can't seem to solve it.

    Thanks

  • User profile image
    piresbruno

    Hi,

    I've fixed the problem. It was due to a plugin which I didn't even need and deactivated. All samples work just fine. Looking forward to play arround with the SDK Smiley

    A.

     

    Can you tell me witch plugin was giving you this problem?

    Thanks

  • User profile image
    anu7477
    Hi, I am working on project detection of suicide boombers and I need to carry out experiment in order to detect concealed device on their body, for that I am using kinect technology ,Please can any help me with their ideas in this project and how to download kinect software.
  • User profile image
    Nashtastic

    Is it just me or is this example busted with Beta 2? I get a FileNotFound Exception on Microsoft.Research.Kinect when the skeleton tracking starts.

  • User profile image
    Nozue

    Here is what I get:

    Error    1    'mySkeletalTracking.MainWindow' does not contain a definition for 'Window_Unloaded' and no extension method 'Window_Unloaded' accepting a first argument of type 'mySkeletalTracking.MainWindow' could be found (are you missing a using directive or an assembly reference?)    C:\Users\Nelson\Documents\Visual Studio 2010\Projects\mySkeletalTracking\mySkeletalTracking\MainWindow.xaml    4    110    mySkeletalTracking

    Can anybody help me? What am I missing?

  • User profile image
    alexM

    I am always getting a NullReferenceException for this:

    Dim HandRight = skeleton.Joints(JointID.HandRight).ScaleTo(320, 240, 0.5F, 0.5F)

    declaration and setting HandRight to null won't help, nor did resetting the project file...

  • User profile image
    bijan

    hi
    my programing is poor
    can you send a project(exe and source for windows 7 64bit) that return skeleton.Joints to text file?
    i need it hard
    thanks

  • User profile image
    bijan

    my email is:
    bijanasb@gmail.com

  • User profile image
    ivangolod

    hey guys,

    this is some exciting stuff. i was trying the code out and everything works really gr8.
    the only problem i am facing is my application freezes after 8sec. like i can see the Ellipses moving with my movements but it just freezes after 8 secs.

    please help!!!
    thank you!!

     

    Have  the same problem.  And it doesn't matter if it debugging session or just using .exe 

    hm...  

  • User profile image
    ignacio

    hey guys!! great tutorial!! i've done everything exaclty as it shows here but when i try to run it it says that the " reference of the object its not define as the instance of the object"
    what can be the problem?? thanks!!

  • User profile image
    George

    I have a quick question guys if its no bother. I got the project set up and it works except that after a few seconds the ellipses freeze. I would go to debug but it's kind of hard debugging movement alone. It seems as if the event handler stops firing or something.

  • User profile image
    George

    Just noticed my infrared light turns off at the moment the circles stop moving. I don't know what could be going on.

  • User profile image
    kminant

    Hello everybody,

    i'm just following the quicktutorials and they are fantastic, i had only the NullReferenceException fail but thanks to @Firdosh Tangri answer now it is solved.

    Thanks!!

  • User profile image
    Rui

    I have your problem.
    I receive the "System.NullReferenceException: Object reference not set to an instance of an object." error and i dont know what to do more.

    Do you know the solution?

    best regards

  • User profile image
    Jerry

    Got everything working. I'm still learning C#, but I did figure out how to add different joints, change the ellipses to rectangles and change colors, etc.
    Now on to bigger and better things. I'd like to add a button to the window and the right hand ellipse hovers over it, that would then activate the click event (like it does on the XBox).
    I'll be working on that, but right now, I have no idea how to do it, but any suggestions would be appreciated!!

  • User profile image
    Roger

    For everybody having issues with the ScaledTo function, it's included in the "Coding4Fun Kinect Toolkit" located here: http://c4fkinect.codeplex.com/

    The actual code is this:
    public static Joint ScaleTo(this Joint joint, int width, int height, float skeletonMaxX, float skeletonMaxY)
    {
    Vector pos = new Vector()
    {
    X = Scale(width, skeletonMaxX, joint.Position.X),
    Y = Scale(height, skeletonMaxY, -joint.Position.Y),
    Z = joint.Position.Z,
    W = joint.Position.W
    };

    Joint j = new Joint()
    {
    ID = joint.ID,
    TrackingState = joint.TrackingState,
    Position = pos
    };

    return j;
    }

    public static Joint ScaleTo(this Joint joint, int width, int height)
    {
    return ScaleTo(joint, width, height, 1.0f, 1.0f);
    }

    private static float Scale(int maxPixel, float maxSkeleton, float position)
    {
    float value = ((((maxPixel / maxSkeleton) / 2) * position) + (maxPixel/2));
    if(value > maxPixel)
    return maxPixel;
    if(value < 0)
    return 0;
    return value;
    }

    Hope the formatting turns out OK.

  • User profile image
    Dave

    Hi Dan, I came across this webpage by for hacker who calls himself TechBitar. He got Kinect to control servos wired to an Arduino microcontroller. He used your tutorial as basis for his VB code that does the trick.

    http://www.instructables.com/id/Kinect-controls-Arduino-wired-Servos-using-Visual-/

  • User profile image
    Vahid

    Hi

    when I tried to run the sample code the skeleton detection is fired even if there is no skeleton to detect. Can you tell me what the problem could be?

    tnx

  • User profile image
    Vahid

    I found out what the problem was. I actually needed to put the ellipses in a canvas

  • User profile image
    Diego

    for those guys whose have problems with the SCALETO method... just need to write the USING for the Having4Fun dll!!! its works!!!

  • User profile image
    Josh

    I got your tutorial to work great. However we are attempting to track the position and joints of a manikin with the kinect and have seen it work on occasions. Are there any tips or tricks that you could provide to make this more reliable? How does the kinect determine what is a skeleton and what is not?

    Thanks!

  • User profile image
    Christian

    Hi, I also had the problem with the freezing video stream. In my case I had to remove the depricated "Runtime nui = new Runtime()" with "Runtime nui;" The nui is initialized later on by the "nui = Runtime.Kinects[0];" command.

    Greez

  • User profile image
    Hoare

    hello every i have a question , how can i gain the postion of one person from the video.the size of my video is 640*480. I know there is a method Joint.Position.X or Joint.Position.Y, but the data of i got if not exact? This problem bothering me!I need help!!

  • User profile image
    Hoare

    hello guies, i have a question , how can i gain the postion of one person from the video.the size of my video is 640*480. I know there is a method Joint.Position.X or Joint.Position.Y, but the data of i got if not exact? This problem bothering me!I need help!!

  • User profile image
    Hoare

    hello every i have a question , how can i gain the postion of one person from the video.the size of my video is 640*480. I know there is a method Joint.Position.X or Joint.Position.Y, but the data of i got if not exact? This problem bothering me!I need help!!
    Please contact me, 986461745@qq.com

  • User profile image
    Hoare

    hello everyone, i have a question , how can i get the postion of one person from the video.the size of my video is 640*480. I know there is a method Joint.Position.X or Joint.Position.Y, but the data of i got is not exact? This problem bothering me!I need help!!
    Please contact me, 986461745@qq.com

  • User profile image
    Hoare

    who can help!!

  • User profile image
    Vlatko

    Is it possible to add custom Joints on the tracked skeleton?
    Please contact me at toretorev@yahoo.com

  • User profile image
    terry

    Hi,

    I am new to Kinect SDK and C# too i am trying the bellow mentioned code i am not able to atrt the kinect itself can any one please help me on this.


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
    using Microsoft.Kinect;

    namespace WpfApplication2
    {
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
    Microsoft.Kinect.KinectSensor kinectSensor;
    public SkeletonFrame skeletonframe;
    bool closing = false;
    const int skeletonCount = 6; //API always returns 6 skeleton
    Skeleton[] allSkeletons = new Skeleton[skeletonCount];



    public MainWindow()
    {

    InitializeComponent();
    }

    private KinectSensor InitializeKinectServices(KinectSensor sensor)
    {
    sensor.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30);
    sensor.DepthStream.Enable(DepthImageFormat.Resolution320x240Fps30);
    /* var parameters = new TransformSmoothParameters
    {
    Smoothing = 0.7f,
    Correction = 0.3f,
    Prediction = 0.4f,
    JitterRadius = 1.0f,
    MaxDeviationRadius = 0.5f
    };
    sensor.SkeletonStream.Enable(parameters);*/

    sensor.Start();


    sensor.AudioSource.Start();
    return sensor;
    }
    private void Window_Loaded(object sender, RoutedEventArgs e)
    {

    //return sensor;
    InitializeKinectServices(kinectSensor);
    // kinectSensor.SkeletonStream.Enable();
    // kinectSensor.SkeletonFrameReady += new EventHandler<SkeletonFrameReadyEventArgs>(KinectAllFramesReady);

    }


    private void KinectAllFramesReady(object sender, SkeletonFrameReadyEventArgs e)
    {

    SkeletonFrame skeletonFrameData = e.OpenSkeletonFrame();

    skeletonFrameData.CopySkeletonDataTo(allSkeletons);

    //get the first tracked skeleton
    Skeleton skeleton = (from s in allSkeletons where s.TrackingState == SkeletonTrackingState.Tracked select s).FirstOrDefault();

    SetEllipsePosition(headEllipse, skeleton.Joints[JointType.Head] );
    SetEllipsePosition(leftEllipse, skeleton.Joints[JointType.HandLeft]);
    SetEllipsePosition(rightEllipse, skeleton.Joints[JointType.HandRight]);


    }
    private void SetEllipsePosition(FrameworkElement ellipse, Joint joint)
    {

    Canvas.SetLeft(ellipse, joint.Position.X);
    Canvas.SetTop(ellipse, joint.Position.Y);
    }

    private void Grid_Unloaded(object sender, RoutedEventArgs e)
    {
    //inectSensor.Stop();
    }

    private void Grid_Loaded(object sender, RoutedEventArgs e)
    {

    }





    }

    }

Add Your 2 Cents