0
votes

Depth or Distance?

I am working on face tracking with Kinect with C# and I need to now about face's distance or depth to the Kinect camera.

Do you know how can I find the depth or distance?

Which command should I use? And in which window (main window or face tracking viewer)?

1
Have you done any research yourself such as reading a tutorial or checking the API?Quality Catalyst
Yes, I did. But unfortunately I didn't find any thing useful.ADanjer
The problem is that I am a beginner in C#, So I have problem with commands.ADanjer

1 Answers

1
votes

the answer is:

using (var skeletonFrame= e.OpenSkeletonFrame())
using (var depthFrame = e.OpenDepthImageFrame())
{
skeletonFrame.CopySkeletonDataTo(skeletons);
var skeletons = new Skeleton[skeletonFrame.SkeletonArrayLength];

foreach (var skeleton in skeletons)
{
        if (skeleton.TrackingState != SkeletonTrackingState.Tracked)        
continue;

        var head = skeleton.Joints[JointType.Head];
        if (head.TrackingState == JointTrackingState.NotTracked) continue;

        var depthImagePoint = depthFrame.MapFromSkeletonPoint(head.Position);

        int depthInMillimeters = depthImagePoint.Depth; // TADA!
}
}