Reputation: 305
I am curious if is it possible to use the skeleton algorithm from Kinect sensor.
More specific I have some depth images and I want to extract the skeleton. Is it possible?
Upvotes: 2
Views: 2197
Reputation: 14426
Yes, it is possible.
But probably, it is not simple.
The algorithm that allows the skeletal tracking is called "Real-Time Human Pose Recognition in Parts from a Single Depth Image". In other words, it has been made to estimate the skeletal joints from one single depth image, that is what you need.
The advantage to use an SDK (like the Microsoft one, or any other you prefer) is that you don't need to reimplement the skeletal tracking algorithm. In fact, it is quite complex and it also needs a lot of training data to be artificially created and properly used.
However, if you want to know more about it, you can find everything you need on this page, in which there is a link to the original paper and some supplementary material about building the training data set used to implement the algorithm.
Upvotes: 2
Reputation: 876
To track skeletons with the Kinect, you have to enable the SkeletonStream and get frames with skeletal information inside them (as opposed to getting the information from depth frames. No skeletal information is stored inside them).
First you have to enable the skeleton stream in your application, just as you would with the depth stream or the color stream (I'm assuming you understand that, since you already have depth images).
sensor.SkeletonStream.Enable(new TransformSmoothParameters()
{
Smoothing = 0.5f,
Correction = 0.5f,
Prediction = 0.5f,
JitterRadius = 0.5f,
MaxDeviationRadius = 0.04f
});; // enable the skeleton stream, you could essentially not include any of the content in between the first and last curved brackets, as they are mainly used to stabilize the skeleton information (e.g. predict where a joint is if it disappears)
skeletonData = new Skeleton[kinect.SkeletonStream.FrameSkeletonArrayLength]; // this array will hold your skeletal data and is equivalent to the short array that holds your depth data.
sensor.SkeletonFrameReady += this.SkeletonFrameReady;
Then you have to have a method that is fired everytime the Kinect has a skeleton frame to display (a frame with all the skeletal information)
private void SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
{
using (SkeletonFrame skeletonFrame = e.SkeletonFrame()) //get all the skeleton data
{
if (skeletonFrame == null) //if there's no data, then exit
{
return;
}
skeletonFrame.CopySkeletonDataTo(skeletonData); //copy all the skeleton data into our skeleton array. It's an array that holds data for up to 6 skeletons
Skeleton skeletonOfInterest = (from s in skeletonData
where s.TrackingState == SkeletonTrackingState.Tracked
select s).ElementAtOrDefault(1); //define the first skeleton thats tracked
//put code to manipulate skeletons. You have to go do some reading to find out how to work with the skeletons.
}
}
MSDN is typically my goto resource for learning about how to work the Kinect. If you installed the Kinect SDK, there are also some good samples in the Developer Toolkit Browser. Finally, another good resource is Beginning Kinect Programming with the Microsoft Kinect SDK by Apress, which I've relied on extensively. You can find it on Amazon.
Upvotes: 0