Пример #1
0
        public void TestConstructorRef()
        {
            ulong trackingId = 125;
            Dictionary<JointType, Vector3> data = new Dictionary<JointType, Vector3>();
            data.Add(JointType.AnkleLeft, new Vector3(2, 4, 5));
            data.Add(JointType.ElbowLeft, new Vector3(7, 4, 5));
            data.Add(JointType.FootRight, new Vector3(-5, 4, 5));

            KinectJointTable table = new KinectJointTable(trackingId, data);

            Assert.AreEqual(trackingId, table.TrackingId);
            Assert.AreEqual(table.Joints, data);
        }
Пример #2
0
        public void TestConstructorRef()
        {
            ulong trackingId = 125;
            Dictionary <JointType, Vector3> data = new Dictionary <JointType, Vector3>();

            data.Add(JointType.AnkleLeft, new Vector3(2, 4, 5));
            data.Add(JointType.ElbowLeft, new Vector3(7, 4, 5));
            data.Add(JointType.FootRight, new Vector3(-5, 4, 5));

            KinectJointTable table = new KinectJointTable(trackingId, data);

            Assert.AreEqual(trackingId, table.TrackingId);
            Assert.AreEqual(table.Joints, data);
        }
Пример #3
0
        public void TestConstructorData()
        {
            ulong trackingId = 125;
            Dictionary<JointType, Vector3> data = new Dictionary<JointType,Vector3>();
            data.Add(JointType.AnkleLeft, new Vector3(2,4,5));
            data.Add(JointType.ElbowLeft, new Vector3(7,4,5));
            data.Add(JointType.FootRight, new Vector3(-5,4,5));

            KinectJointTable table = new KinectJointTable(trackingId, data);

            Assert.AreEqual(trackingId, table.TrackingId);
            Assert.AreEqual(table.Joints.Count, data.Count);
            foreach (JointType jt in data.Keys)
            {
                Assert.AreEqual(data[jt], table.Joints[jt]);
            }
        }
Пример #4
0
        public void TestConstructorData()
        {
            ulong trackingId = 125;
            Dictionary <JointType, Vector3> data = new Dictionary <JointType, Vector3>();

            data.Add(JointType.AnkleLeft, new Vector3(2, 4, 5));
            data.Add(JointType.ElbowLeft, new Vector3(7, 4, 5));
            data.Add(JointType.FootRight, new Vector3(-5, 4, 5));

            KinectJointTable table = new KinectJointTable(trackingId, data);

            Assert.AreEqual(trackingId, table.TrackingId);
            Assert.AreEqual(table.Joints.Count, data.Count);
            foreach (JointType jt in data.Keys)
            {
                Assert.AreEqual(data[jt], table.Joints[jt]);
            }
        }
Пример #5
0
        public void TesTransform()
        {
            ulong trackingId = 125;
            Dictionary<JointType, Vector3> data = new Dictionary<JointType, Vector3>();
            data.Add(JointType.AnkleLeft, new Vector3(2, 4, 5));
            data.Add(JointType.ElbowLeft, new Vector3(7, 4, 5));
            data.Add(JointType.FootRight, new Vector3(-5, 4, 5));

            KinectJointTable table = new KinectJointTable(trackingId, data);

            Matrix m = Matrix.Translation(-4.0f, 5.0f, 6.0f);

            KinectJointTable transformed = table.Transform(m);

            foreach (JointType jt in data.Keys)
            {
                Assert.AreEqual(Vector3.TransformCoordinate(data[jt], m), transformed.Joints[jt]);
            }
        }
Пример #6
0
        public void TesTransform()
        {
            ulong trackingId = 125;
            Dictionary <JointType, Vector3> data = new Dictionary <JointType, Vector3>();

            data.Add(JointType.AnkleLeft, new Vector3(2, 4, 5));
            data.Add(JointType.ElbowLeft, new Vector3(7, 4, 5));
            data.Add(JointType.FootRight, new Vector3(-5, 4, 5));

            KinectJointTable table = new KinectJointTable(trackingId, data);

            Matrix m = Matrix.Translation(-4.0f, 5.0f, 6.0f);

            KinectJointTable transformed = table.Transform(m);

            foreach (JointType jt in data.Keys)
            {
                Assert.AreEqual(Vector3.TransformCoordinate(data[jt], m), transformed.Joints[jt]);
            }
        }
Пример #7
0
        /// <summary>
        /// Process joint table
        /// </summary>
        /// <param name="jointTable"></param>
        public void Process(KinectJointTable jointTable)
        {
            var leftHand = jointTable.Joints[JointType.HandLeft];
            var rightHand = jointTable.Joints[JointType.HandRight];
            var hipLeft = jointTable.Joints[JointType.HipLeft];
            var hipRight = jointTable.Joints[JointType.HipRight];
            var shoulderLeft = jointTable.Joints[JointType.ShoulderLeft];
            var shoulderRight = jointTable.Joints[JointType.ShoulderRight];
            var elbowLeft = jointTable.Joints[JointType.ElbowLeft];
            var elbowRight = jointTable.Joints[JointType.ElbowRight];

            //First compute elevation, we consider min y at hip and max y at shoulder
            float leftE = ((leftHand.Y - hipLeft.Y) / (shoulderLeft.Y - hipLeft.Y)) * 2.0f - 1.0f;
            float rightE = ((rightHand.Y - hipRight.Y) / (shoulderRight.Y - hipRight.Y)) * 2.0f - 1.0f;

            this.elevation = this.elevationCurve.Apply(MathUtil.Clamp((leftE + rightE) * 0.5f, -1.0f,1.0f));

            float handDirX = leftHand.X - rightHand.X;
            float handDirY = leftHand.Y - rightHand.Y;

            float ang = Convert.ToSingle(Math.Atan2(handDirY, handDirX));
            float pi = (float)Math.PI;
            float halfpi = (float)Math.PI * 0.5f;

            //remap left steer from -halpi to -pi
            if (ang < 0.0f)
            {
                ang = (1.0f - (ang + halfpi) / (-halfpi)) * -1.0f;
            }
            else
            {
                ang = (ang - pi) / (-halfpi);
            }

            this.steeringY = this.steeringCurve.Apply(MathUtil.Clamp(ang, -1.0f, 1.0f));

            //Build z steering as per star wars game, hand angle in xz plane
            float handDirZ = leftHand.Z - rightHand.Z;
            float zang = Convert.ToSingle(Math.Atan2(handDirZ, handDirX));

            if (zang < 0.0f)
            {
                zang = (1.0f - (zang + halfpi) / (-halfpi)) * -1.0f;
            }
            else
            {
                zang = (zang - pi) / (-halfpi);
            }

            this.steeringZ = zang;

            //Last computes push amount, here we say min push is Z next to shoulder and max push is shoulder + arm length
            float leftArmLength = Vector3.Distance(shoulderLeft, elbowLeft) + Vector3.Distance(elbowLeft, leftHand);
            float rightArmLength = Vector3.Distance(shoulderRight, elbowRight) + Vector3.Distance(elbowRight, rightHand);

            float leftP = ((shoulderLeft.Z - leftHand.Z) / (leftArmLength)) * 2.0f - 1.0f;
            float rightP = ((shoulderRight.Z -rightHand.Z) / (rightArmLength)) * 2.0f - 1.0f;

            this.push = this.pushCurve.Apply(MathUtil.Clamp((leftP + rightP) * 0.5f, -1.0f, 1.0f));
        }
Пример #8
0
 public void TestNullData()
 {
     ulong            trackingId = 125;
     KinectJointTable table      = new KinectJointTable(trackingId, null);
 }
Пример #9
0
        /// <summary>
        /// Process joint table
        /// </summary>
        /// <param name="jointTable"></param>
        public void Process(KinectJointTable jointTable)
        {
            var leftHand      = jointTable.Joints[JointType.HandLeft];
            var rightHand     = jointTable.Joints[JointType.HandRight];
            var hipLeft       = jointTable.Joints[JointType.HipLeft];
            var hipRight      = jointTable.Joints[JointType.HipRight];
            var shoulderLeft  = jointTable.Joints[JointType.ShoulderLeft];
            var shoulderRight = jointTable.Joints[JointType.ShoulderRight];
            var elbowLeft     = jointTable.Joints[JointType.ElbowLeft];
            var elbowRight    = jointTable.Joints[JointType.ElbowRight];

            //First compute elevation, we consider min y at hip and max y at shoulder
            float leftE  = ((leftHand.Y - hipLeft.Y) / (shoulderLeft.Y - hipLeft.Y)) * 2.0f - 1.0f;
            float rightE = ((rightHand.Y - hipRight.Y) / (shoulderRight.Y - hipRight.Y)) * 2.0f - 1.0f;

            this.elevation = this.elevationCurve.Apply(MathUtil.Clamp((leftE + rightE) * 0.5f, -1.0f, 1.0f));

            float handDirX = leftHand.X - rightHand.X;
            float handDirY = leftHand.Y - rightHand.Y;

            float ang    = Convert.ToSingle(Math.Atan2(handDirY, handDirX));
            float pi     = (float)Math.PI;
            float halfpi = (float)Math.PI * 0.5f;

            //remap left steer from -halpi to -pi
            if (ang < 0.0f)
            {
                ang = (1.0f - (ang + halfpi) / (-halfpi)) * -1.0f;
            }
            else
            {
                ang = (ang - pi) / (-halfpi);
            }

            this.steeringY = this.steeringCurve.Apply(MathUtil.Clamp(ang, -1.0f, 1.0f));

            //Build z steering as per star wars game, hand angle in xz plane
            float handDirZ = leftHand.Z - rightHand.Z;
            float zang     = Convert.ToSingle(Math.Atan2(handDirZ, handDirX));

            if (zang < 0.0f)
            {
                zang = (1.0f - (zang + halfpi) / (-halfpi)) * -1.0f;
            }
            else
            {
                zang = (zang - pi) / (-halfpi);
            }

            this.steeringZ = zang;


            //Last computes push amount, here we say min push is Z next to shoulder and max push is shoulder + arm length
            float leftArmLength  = Vector3.Distance(shoulderLeft, elbowLeft) + Vector3.Distance(elbowLeft, leftHand);
            float rightArmLength = Vector3.Distance(shoulderRight, elbowRight) + Vector3.Distance(elbowRight, rightHand);

            float leftP  = ((shoulderLeft.Z - leftHand.Z) / (leftArmLength)) * 2.0f - 1.0f;
            float rightP = ((shoulderRight.Z - rightHand.Z) / (rightArmLength)) * 2.0f - 1.0f;

            this.push = this.pushCurve.Apply(MathUtil.Clamp((leftP + rightP) * 0.5f, -1.0f, 1.0f));
        }
Пример #10
0
 public void TestNullData()
 {
     ulong trackingId = 125;
     KinectJointTable table = new KinectJointTable(trackingId, null);
 }