Example #1
0
        /// <summary>
        /// Retruns the height of the specified body.
        /// </summary>
        /// <param name="body">The specified user body.</param>
        /// <returns>The height of the body in meters.</returns>
        public static double Height(this Body body)
        {
            const double HEAD_DIVERGENCE = 0.1;

            var head       = body.Joints[JointType.Head];
            var neck       = body.Joints[JointType.Neck];
            var shoulders  = body.Joints[JointType.SpineShoulder];
            var spine      = body.Joints[JointType.SpineMid];
            var waist      = body.Joints[JointType.SpineBase];
            var hipLeft    = body.Joints[JointType.HipLeft];
            var hipRight   = body.Joints[JointType.HipRight];
            var kneeLeft   = body.Joints[JointType.KneeLeft];
            var kneeRight  = body.Joints[JointType.KneeRight];
            var ankleLeft  = body.Joints[JointType.AnkleLeft];
            var ankleRight = body.Joints[JointType.AnkleRight];
            var footLeft   = body.Joints[JointType.FootLeft];
            var footRight  = body.Joints[JointType.FootRight];

            // Find which leg is tracked more accurately.
            int legLeftTrackedJoints  = JointExtensions.NumberOfTrackedJoints(hipLeft, kneeLeft, ankleLeft, footLeft);
            int legRightTrackedJoints = JointExtensions.NumberOfTrackedJoints(hipRight, kneeRight, ankleRight, footRight);

            double legLength = legLeftTrackedJoints > legRightTrackedJoints?JointExtensions.Distance(hipLeft, kneeLeft, ankleLeft, footLeft) : JointExtensions.Distance(hipRight, kneeRight, ankleRight, footRight);

            return(JointExtensions.Distance(head, neck, shoulders, spine, waist) + legLength + HEAD_DIVERGENCE);
        }
Example #2
0
 /// <summary>
 /// Given a collection of joints, calculates the number of the joints that are tracked accurately.
 /// </summary>
 /// <param name="joints">A collection of joints.</param>
 /// <returns>The number of the accurately tracked joints.</returns>
 public static int NumberOfTrackedJoints(this Body body)
 {
     return(JointExtensions.NumberOfTrackedJoints(body.Joints.Values));
 }