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); }
/// <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); }