Created
April 3, 2014 12:52
-
-
Save tkowalczyk/9953733 to your computer and use it in GitHub Desktop.
Stick on one skeleton via ID
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int _trackedSkeletonId = 0; | |
Skeleton _currentSkeleton; | |
void sensor_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e) | |
{ | |
_currentSkeleton = null; | |
using (SkeletonFrame frame = e.OpenSkeletonFrame()) | |
{ | |
if (frame == null) | |
return; | |
if (_skeletons == null) _skeletons = new Skeleton[frame.SkeletonArrayLength]; | |
frame.CopySkeletonDataTo(_skeletons); | |
bool bSklFound = false; | |
foreach (Skeleton skl in _skeletons) | |
{ | |
if (skl.TrackingState == SkeletonTrackingState.Tracked) | |
{ | |
if (_currentSkeleton == null) | |
{ | |
_currentSkeleton = skl; | |
bSklFound = true; | |
break; | |
} | |
else if (skl.TrackingId == _trackedSkeletonId) | |
{ | |
_currentSkeleton = skl; | |
bSklFound = true; | |
break; | |
} | |
} | |
} | |
if (bSklFound == true) | |
{ | |
_trackedSkeletonId = _currentSkeleton.TrackingId; | |
//do what you want with one found skeleton | |
} | |
else | |
{ | |
_currentSkeleton = null; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment