I know how to convert in pixels the value obtained from Joint.Position.X and Joint.Position.Y . There is an example in which I do this:
void kinectSensor_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e) { using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame()) { if (skeletonFrame != null) { Skeleton[] skeletonData = new Skeleton[skeletonFrame.SkeletonArrayLength]; //conterrà tutti gli skeleton skeletonFrame.CopySkeletonDataTo(skeletonData); Skeleton playerSkeleton = (from s in skeletonData where s.TrackingState == SkeletonTrackingState.Tracked select s).FirstOrDefault(); if (playerSkeleton != null) { Joint rightHand = playerSkeleton.Joints[JointType.HandRight]; Joint leftHand = playerSkeleton.Joints[JointType.HandLeft]; //EDIT: The following formulas used to convert X and Y coordinates in pixels are wrong. //Please, see the answer for details rightHandPosition = new float[] { (((0.5f * rightHand.Position.X) + 0.5f) * (640)), (((-0.5f * rightHand.Position.Y) + 0.5f) * (480)) }; leftHandPosition = new float[] { (((0.5f * leftHand.Position.X) + 0.5f) * (640)), (((-0.5f * leftHand.Position.Y) + 0.5f) * (480)), leftHand.Position.Z }; } } } }
Now what I want to do is get the real depth (in millimeters) using Joint.Depth.Z . Referring to the previous example, I want to get two 3D arrays for rightHandPosition and leftHandPosition , with the last coordinate representing the depth. What is the correct formula for converting the value returned from rightHand.Position.Z and leftHand.Position.Z to the corresponding value in millimeters?
EDIT: The formulas used to convert the X and Y coordinates in pixels in the above code are incorrect. Please read the following answer from me.
source share