3
votes

I was hoping someone could help point me in the right direction.

I'm looking for a way to use the Microsoft Kinect to turn off a lamp. The lamp is connected to a Home Easy remote socket switch which is paired with a Telldus Tellstick. I am using C# to write the application, now I have a vague idea in my head what I would like to do, and after using the Kinect SDK I have a better understanding of how to use the Kinect.

What I would like to know is what would be the most logical way to create this application? I was thinking something along the lines of: Initialize Kinect > When Kinect ready then scan for skeleton > when skeleton detected, mark boolean value as 'true' > when value true, turn light on.

I know that is very vague, but I am new to developing with the kinect and overall my I'm still learning C#. Any help, no matter how small would be greatly appreciated!

Regards, John.

1
Initialize Kinect > When Kinect ready then scan for skeleton > when skeleton detected, mark boolean value as 'true' its more logical wayMustafa Ekici
Thanks Mekici, I was curious to know whether or not I would have to collect any data from the skeletal tracking or if i can just specify the boolean command without any further issues?J.Doe
Infact skeleton tracking doesnt necessary! why you have to use skeleton processing? your approach can be simple image processing which is Motion Detection?Mustafa Ekici
I would like to be able to show Live skeletal data whilst the application is running just to enhance the GUI.J.Doe
I don't know if this is true in the SDK, but in the beta versions whenever i used a bool to tell if someone was detected everything froze. I would guess they fixed that(I hope)Liam McInroy

1 Answers

1
votes

You can't set a simple boolean for this because the SDK's event driven approach will return 6 skeletal structures even if they are all empty. Using a bit of LINQ and a null check will get you what you are looking for though.

Steps:

  1. Initialize Kinect (I would use the included KinectSensorChooser for this app WPFViewers) enable and register for the skeletal stream.
  2. In the skeletal event check to make sure you didn't get a null skeleton collection (it happens)
  3. Use LINQ to get the first skeleton that has it's tracking property set to tracked. You can also just use a for loop, I just find LINQ to be useful for these types of iteration.
  4. If your skeleton after the LINQ query is not null do something.

If you are wanting to get this up quick and with some flair you can utilize the sample that is included when you download the SDK Kinect Explorer. There is a skeletal viewer along with KinectSensorChooser that will allow you to have a fully functioning app with very little code. read more about the Skeletal Viewer included with this sample here


I stumbled a little bit with wether to provide code for this or not. I thought it better to answer this with the logic needed to perform the action rather than the actual code... since you asked :) however, if you want code for this you can either get it from Channel 9's Quickstarts or my book chapter four


Edit (Extending KinectExplorer):

In order to extend KinectExplorer to respond when a skeleton is detected just find the function KinectAllFramesReady in KinectSkeletonViewer.xaml.cs. Inside of this function there is a bool check for haveSkeletonData, this if statement will get called when there is a skeleton present in the viewable frame of the Kinect. so:

   private void KinectAllFramesReady(object sender, AllFramesReadyEventArgs e)
   {
    //Checking for Skeleton
    if (haveSkeletonData)
    {
     //Do Stuff Here
    }
   }