Updates for Kinect for Windows SDK Beta 2 (Nov, 2011)

The video has not been updated for Beta 2, but the following changes have been made:

Previously, the SkeletonFrameReady event would only fire when there was a tracked skeleton. The SkeletonFrameReady has been updated to fire continuously even when there are no skeletons being tracked. To get tracked skeletons, you can filter the list of skeletons to see if the TrackingState property is set to SkeletonTrackingState.Tracked.

Beta 2 includes a sample (Microsoft.Samples.Kinect.WpfViewers) set of user controls for visualizing data from the Color/RGB and Depth cameras that you can reuse in your application. The samples can be found at: "\Program Files\Microsoft SDKs\Kinect\v1.0 Beta2\Samples\KinectSDKSamples.zip"

Setup

Task: Setup skeleton tracking

Go to the properties window (F4), select the MainWindow, select the Events tab, and double click on the Loaded event to create the Window_Loaded event

Initializing the runtime

Create a new variable outside of the Window_Loaded event to reference the Kinect runtime.

C#

Runtime nui = new Runtime();

Visual Basic

Dim nui As New Runtime()

In the Window_Loaded event, initialize the runtime with the options you want to use. For this example, set RuntimeOptions.UseSkeletalTracking to receive skeletal data and register for the SkeletonFrameReady event.

Running the application

Add a breakpoint inside the SkeletonFrameReady event and run the application.

Note – You will need to stand far enough away that the Kinect can see all or most of your skeleton for the SkeletonFrameReady event to fire.

When the breakpoint fires, you can inspect the SkeletonFrameReadyEventArgs to see that the SkeletonFrame returns a collection of six skeletons as shown below.

Task: Add a basic hand tracked cursor

In this example, we're going to use the position of the tracked skeleton's, head, left hand, and right hand to move ellipse controls.

Designing your UI

Starting from the project above, switch to MainWindow.xaml and make sure you can see the XAML code. We will add three three ellipses of varying color onto a Canvas control named MainCanvas as shown in the XAML below.

You can also constrain the maximum values for the skeletal joints to a smaller range. For example, if you were designing an application where the user can reach around the screen to touch things, you may not want them to have to walk two feet left or right to reach the edges. By using the second version of the ScaleTo method, you can specify the range of the specified joint to something smaller as shown:

This code will make it so that your right hand only has to travel one meter (joint range of -0.5 to +0.5) to traverse the pixels at 0 to 640. If you set this value to –1 to +1, for example, then the right hand would have to travel two meters total, one meter to the left, one meter to the right to traverse the 640 pixels.

Also, as you can see above, you can get a particular Joint, like the HandRight Joint, by using the skeleton indexer for the Joints collection.

Setting an Ellipse Position

To move the ellipses in our MainWindow to the location of a Joint, we will use the method below that sets the Canvas.Left and Canvas.Top position to the X (Left) and Y (Top) value from the Joint parameter.

Task: Using TransformSmoothing to for less skeletal jitter

Using the same application as above, you may notice jitteriness in the hand positions as small changes between updates to the SkeletalFrameReady event change the location of the ellipses.

Using TransformSmoothParameters

To see the difference between using and not using TransformSmoothing, toggle the true/false TransformSmooth property. There are two ways to use TransformSmoothing, you can set it to true and it will use a default set of parameters, or you can customize and experiment with each of the parameters to find the parameters that work best for your application. To do that, you’ll need create the TransformSmoothParameters struct yourself and define the parameters.

You must set the TransformSmoothParameters after calling the nui.Initialize method.

Note: Since every application is different, you will need to experiment with the parameters to understand what's right for your application.

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!

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

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.

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

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.

}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.

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.

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

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

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!!

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.

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!!

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.

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?

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.

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!!

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!!

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

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

Remove this comment

Remove this thread

Comments Closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation,
please create a new thread in our Forums, or
Contact Us and let us know.