Taking joint data from the closest player only
-
Wednesday, April 25, 2012 10:08 AM
Hello!I would like to know how i can take the data from the closest player to kinect only.i want to recognize only the first person that appears to kinect and noone else above him.How can i convert this?
SkeletonData skeleton = (from s in allSkeletons.Skeletons
where s.TrackingState == SkeletonTrackingState.Tracked
select s).FirstOrDefault();
All Replies
-
Wednesday, April 25, 2012 11:38 AM
You can get it using Z or depth value
Please check the below code
Skeleton[] trackedskeletons = (from skl in _skeletonData where skl.TrackingState == SkeletonTrackingState.Tracked select skl).ToArray<Skeleton>(); Skeleton[] _skeleton; float depth = 0; foreach (Skeleton skl in trackedskeletons) { if (depth ==0 || skl.Position.Z<depth) { depth = skl.Position.Z; _skeleton = skl; } }
- Proposed As Answer by gowri shankar vvln Wednesday, April 25, 2012 11:38 AM
-
Wednesday, April 25, 2012 2:33 PM
Try to send all tracked skeletons to the following method and it will get you the closest player only
private static Skeleton GetPrimarySkeleton(IEnumerable<Skeleton> skeletons) { Skeleton primarySkeleton = null; foreach (Skeleton skeleton in skeletons) { if (skeleton.TrackingState != SkeletonTrackingState.Tracked) { continue; } if (primarySkeleton == null) primarySkeleton = skeleton; else if (primarySkeleton.Position.Z > skeleton.Position.Z) primarySkeleton = skeleton; } return primarySkeleton; }
Thanks,
MOHAMED A. SAKR | Software Development Lead Engineer | EgyptNetwork
Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members. Also try to Vote as Helpful- Proposed As Answer by MohamedSakr Wednesday, April 25, 2012 2:34 PM
- Edited by MohamedSakr Wednesday, April 25, 2012 2:35 PM
- Marked As Answer by Carmine Si - MSFTMicrosoft Employee, Owner Thursday, March 21, 2013 10:46 PM
-
Saturday, April 28, 2012 7:04 PM
Any updates
Please feedback
Thanks,
MOHAMED A. SAKR | Software Development Lead Engineer | EgyptNetwork
Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members. Also try to Vote as Helpful -
Thursday, May 10, 2012 8:08 PMit worked!thank you very much!
-
Saturday, March 16, 2013 7:45 PM
, code works great. Thanks!
I spent a night trying to do the same (get nearest player) using MS's KinectManager class, but there's no sample for using it with WinForms, only WPF sample. It would be great if someone could post an easy sample for using KinectManager class, which have option to get skeletons for most active player, sticky player etc. Would be handy in some more complex project.
For now, your code for getting the nearest player is working good for me :)
// chall3ng3r //
www.orison.biz/blogs/chall3ng3r/

