Exemple #1
0
        public override bool MatchesCriterion(SkeletonStamp skeletonStamp)
        {
            double alignmentValue = 0.0;

            Joint[] trackedJoints = new Joint[Joints.Length];
            Joint   centerJoint;
            int     i = 0;

            // get the joints to be aligned
            foreach (XmlJointType type in Joints)
            {
                trackedJoints[i++] = skeletonStamp.GetTrackedSkeleton().Joints[type.GetJointType()];
            }
            switch (Alignment)
            {
            case Alignment.Point:
                centerJoint    = skeletonStamp.GetTrackedSkeleton().Joints[CenterJoint.GetJointType()];
                alignmentValue = JointAnalyzer.AreJointsAligned(centerJoint, trackedJoints);
                break;

            case Alignment.Horizontal:
                alignmentValue = JointAnalyzer.AlignedHorizontally(trackedJoints[0], trackedJoints[1]);
                break;

            case Alignment.Vertical:
                alignmentValue = JointAnalyzer.AlignedVertically(trackedJoints[0], trackedJoints[1]);
                break;
            }
            return(alignmentValue > MaximumAcceptedRange);
        }
Exemple #2
0
        /// <summary>
        /// Finds the angle between the provided joints.
        /// </summary>
        /// <param name="skeletonStamp"></param>
        /// <param name="vertexJoint"></param>
        /// <param name="adjacentJoints"></param>
        /// <returns></returns>
        private int FindAngle(SkeletonStamp skeletonStamp, out Joint vertexJoint, out Joint[] adjacentJoints)
        {
            // Test bone orientations
            Skeleton        skeleton = skeletonStamp.GetTrackedSkeleton();
            BoneOrientation bo       = skeleton.BoneOrientations[Vertex.GetJointType()];

            // get the vertex and other joints off the skeleton stamp
            vertexJoint = skeletonStamp.GetTrackedSkeleton().Joints[Vertex.GetJointType()];

            adjacentJoints    = new Joint[2];
            adjacentJoints[0] = skeletonStamp.GetTrackedSkeleton().Joints[OtherJoints[0].GetJointType()];
            adjacentJoints[1] = skeletonStamp.GetTrackedSkeleton().Joints[OtherJoints[1].GetJointType()];
            int convertedDotAngle = JointAnalyzer.FindAngle(vertexJoint, adjacentJoints);

            return(convertedDotAngle);
        }
Exemple #3
0
        /// <summary>
        /// Checks the alignment of the joints. returns a value for each joint measured
        /// </summary>
        /// <param name="skeletonStamp"></param>
        /// <returns></returns>
        private double[] FindAlignment(SkeletonStamp skeletonStamp)
        {
            // initialize the values of the array to -2 since the value we're returning is between -1 and +1
            double[] alignmentValue = Enumerable.Repeat(-999.0, 20).ToArray();
            Joint[]  trackedJoints  = new Joint[Joints.Length];
            Joint    centerJoint;
            int      i = 0;

            // get the joints to be aligned
            foreach (XmlJointType type in Joints)
            {
                trackedJoints[i++] = skeletonStamp.GetTrackedSkeleton().Joints[type.GetJointType()];
            }
            double tempValue;

            switch (Alignment)
            {
            case Alignment.Point:
                centerJoint = skeletonStamp.GetTrackedSkeleton().Joints[CenterJoint.GetJointType()];
                tempValue   = 1 - JointAnalyzer.AreJointsAligned(centerJoint, trackedJoints);
                alignmentValue[(int)CenterJoint.GetJointType()] = tempValue;
                alignmentValue[(int)trackedJoints[0].JointType] = tempValue;
                alignmentValue[(int)trackedJoints[1].JointType] = tempValue;
                break;

            case Alignment.Horizontal:
                tempValue = 1 - JointAnalyzer.AlignedHorizontally(trackedJoints[0], trackedJoints[1]);
                alignmentValue[(int)trackedJoints[0].JointType] = tempValue;
                alignmentValue[(int)trackedJoints[1].JointType] = tempValue;
                break;

            case Alignment.Vertical:
                tempValue = 1 - JointAnalyzer.AlignedVertically(trackedJoints[0], trackedJoints[1]);
                alignmentValue[(int)trackedJoints[0].JointType] = tempValue;
                alignmentValue[(int)trackedJoints[1].JointType] = tempValue;
                break;
            }

            return(alignmentValue);
        }