Ejemplo n.º 1
0
        public void TestAngleMatchesCriteria()
        {
            #region Setup Skeleton
            Skeleton[] skeletonData = new Skeleton[1];
            Skeleton skeleton = new Skeleton();
            skeleton.TrackingState = SkeletonTrackingState.Tracked;
            /* this needs to be done because you can't set properties directly on the skelton's Joint object:
             * you must create a new joint,
             * set the properties,
             * then set the new joint on the skeleton */
            SkeletonPoint hipPoint = new SkeletonPoint();
            hipPoint.X = 1.0F;
            hipPoint.Y = 1.0F;
            hipPoint.Z = 1.0F;
            Joint hip = skeleton.Joints[JointType.HipRight];
            hip.Position = hipPoint;
            skeleton.Joints[JointType.HipRight] = hip;

            SkeletonPoint kneePoint = new SkeletonPoint();
            kneePoint.X = 2.0F;
            kneePoint.Y = 1.0F;
            kneePoint.Z = 1.0F;
            Joint knee = skeleton.Joints[JointType.KneeRight];
            knee.Position = kneePoint;

            // slightly off 90 but should still match
            SkeletonPoint anklePoint = new SkeletonPoint();
            anklePoint.X = 2.0F;
            anklePoint.Y = 0.01F;
            anklePoint.Z = 1.0F;
            skeleton.Joints[JointType.KneeRight] = knee;
            Joint ankle = skeleton.Joints[JointType.AnkleRight];
            ankle.Position = anklePoint;
            skeleton.Joints[JointType.AnkleRight] = ankle;
            skeletonData[0] = skeleton;
            SkeletonStamp skeletonStamp = new SkeletonStamp(skeletonData, 1);
            #endregion
            Exercise angleExercise = new Exercise();

            #region Angle Matches
            angleExercise.StartingCriteria = new Criterion[1] { AngleCriterion };
            Assert.IsTrue(angleExercise.matchesCriteria(skeletonStamp,angleExercise.StartingCriteria));
            #endregion

            #region Angle Does Not Match
            SkeletonPoint misalignedPoint = new SkeletonPoint();
            misalignedPoint.X = 2.0F;
            misalignedPoint.Y = 0.0F;
            misalignedPoint.Z = 1.0F;
            hip = skeleton.Joints[JointType.HipRight];
            hip.Position = misalignedPoint;
            skeleton.Joints[JointType.HipRight] = hip;
            Assert.IsFalse(angleExercise.matchesCriteria(skeletonStamp, angleExercise.StartingCriteria));
            #endregion
        }
Ejemplo n.º 2
0
        public void TestAlignmentMatchesCriteria()
        {
            #region Setup Skeleton
            Skeleton[] skeletonData = new Skeleton[1];
            Skeleton skeleton = new Skeleton();
            skeleton.TrackingState = SkeletonTrackingState.Tracked;
            /* this needs to be done because you can't set properties directly on the skelton's Joint object:
             * you must create a new joint,
             * set the properties,
             * then set the new joint on the skeleton */
            SkeletonPoint sp = new SkeletonPoint();
            sp.X = 1.0F;
            sp.Y = 1.0F;
            sp.Z = 1.0F;
            Joint hip = skeleton.Joints[JointType.HipRight];
            hip.Position = sp;
            skeleton.Joints[JointType.HipRight] = hip;
            Joint knee = skeleton.Joints[JointType.KneeRight];
            knee.Position = sp;
            skeleton.Joints[JointType.KneeRight] = knee;
            Joint ankle = skeleton.Joints[JointType.AnkleRight];
            ankle.Position = sp;
            skeleton.Joints[JointType.AnkleRight] = ankle;
            skeletonData[0] = skeleton;

            System.Console.WriteLine("Hip Position X: " + hip.Position.X);
            System.Console.WriteLine("Skel Hip Position X: " + skeleton.Joints[JointType.HipRight].Position.X);
            SkeletonStamp skeletonStamp = new SkeletonStamp(skeletonData, 1);
            #endregion

            Exercise alignmentExercise = new Exercise();
            #region Matches Alignment
            alignmentExercise.StartingCriteria = new Criterion[] { VerticalAlignmentCriterion };
            Assert.IsTrue(alignmentExercise.matchesCriteria(skeletonStamp,alignmentExercise.StartingCriteria));
            #endregion

            #region Does Not Match Alignment
            SkeletonPoint misalignedPoint = new SkeletonPoint();
            misalignedPoint.X = 100.0F;
            misalignedPoint.Y = 1.0F;
            misalignedPoint.Z = 1.0F;
            hip = skeleton.Joints[JointType.HipRight];
            hip.Position = misalignedPoint;
            skeleton.Joints[JointType.HipRight] = hip;

            System.Console.WriteLine("Hip Position X: " + hip.Position.X);
            System.Console.WriteLine("Skel Hip Position X: " + skeleton.Joints[JointType.HipRight].Position.X);
            System.Console.WriteLine("Skel Knee Position X: " + skeleton.Joints[JointType.KneeRight].Position.X);
            Assert.IsFalse(alignmentExercise.matchesCriteria(skeletonStamp,alignmentExercise.StartingCriteria));
            #endregion
        }