Esempio n. 1
0
 public void Read(BinaryReader reader)
 {
     JointType = (TJointType)reader.ReadInt32();
     Position  = new TSkeletonPoint();
     Position.Read(reader);
     TrackingState = (TJointTrackingState)reader.ReadInt32();
 }
Esempio n. 2
0
 public void Read(BinaryReader reader)
 {
     JointType = (TJointType)reader.ReadInt32();
     Position = new TSkeletonPoint();
     Position.Read(reader);
     TrackingState = (TJointTrackingState)reader.ReadInt32();
 }
Esempio n. 3
0
        public static Vector2 Convert( TSkeletonPoint position)
        {
            float width = 0;
            float height = 0;
            float x = 0;
            float y = 0;

            //if (sensor.ColorStream.IsEnabled)
            //{
            //    var colorPoint = sensor.MapSkeletonPointToColor(position, sensor.ColorStream.Format);
            //    x = colorPoint.X;
            //    y = colorPoint.Y;

            //    switch (sensor.ColorStream.Format)
            //    {
            //        case ColorImageFormat.RawYuvResolution640x480Fps15:
            //        case ColorImageFormat.RgbResolution640x480Fps30:
            //        case ColorImageFormat.YuvResolution640x480Fps15:
            //            width = 640;
            //            height = 480;
            //            break;
            //        case ColorImageFormat.RgbResolution1280x960Fps12:
            //            width = 1280;
            //            height = 960;
            //            break;
            //    }
            //}
            //else if (sensor.DepthStream.IsEnabled)
            //{
            //    var depthPoint = sensor.MapSkeletonPointToDepth(position, sensor.DepthStream.Format);
            //    x = depthPoint.X;
            //    y = depthPoint.Y;

            //    switch (sensor.DepthStream.Format)
            //    {
            //        case DepthImageFormat.Resolution80x60Fps30:
            //            width = 80;
            //            height = 60;
            //            break;
            //        case DepthImageFormat.Resolution320x240Fps30:
            //            width = 320;
            //            height = 240;
            //            break;
            //        case DepthImageFormat.Resolution640x480Fps30:
            //            width = 640;
            //            height = 480;
            //            break;
            //    }
            //}
            //else
            //{
            width = 640;
            height = 480;
            //}

            return new Vector2(x / width, y / height);
        }
Esempio n. 4
0
 public TSkeleton(Skeleton skeleton)
 {
     ClippedEdges = (TFrameEdges) skeleton.ClippedEdges;
     Joints = new TJoint[skeleton.Joints.Count];
     int i = 0;
     foreach (var joint in skeleton.Joints)
     {
         Joints[i] = new TJoint((Joint)joint);
         i++;
     }
     Position = new TSkeletonPoint(skeleton.Position);
     TrackingId = skeleton.TrackingId;
     TrackingState = (TSkeletonTrackingState)skeleton.TrackingState;
 }
Esempio n. 5
0
 public void Read(BinaryReader reader)
 {
     ClippedEdges = (TFrameEdges)reader.ReadInt32();
     int jointCount = reader.ReadInt32();
     Joints = new TJoint[jointCount];
     for (int jx = 0; jx < jointCount; jx++)
     {
         Joints[jx] = new TJoint();
         Joints[jx].Read(reader);
     }
     Position = new TSkeletonPoint();
     Position.Read(reader);
     TrackingId = reader.ReadInt32();
     TrackingState = (TSkeletonTrackingState)reader.ReadInt32();
 }
Esempio n. 6
0
        public TSkeleton(Skeleton skeleton)
        {
            ClippedEdges = (TFrameEdges)skeleton.ClippedEdges;
            Joints       = new TJoint[skeleton.Joints.Count];
            int i = 0;

            foreach (var joint in skeleton.Joints)
            {
                Joints[i] = new TJoint((Joint)joint);
                i++;
            }
            Position      = new TSkeletonPoint(skeleton.Position);
            TrackingId    = skeleton.TrackingId;
            TrackingState = (TSkeletonTrackingState)skeleton.TrackingState;
        }
Esempio n. 7
0
        public void Read(BinaryReader reader)
        {
            ClippedEdges = (TFrameEdges)reader.ReadInt32();
            int jointCount = reader.ReadInt32();

            Joints = new TJoint[jointCount];
            for (int jx = 0; jx < jointCount; jx++)
            {
                Joints[jx] = new TJoint();
                Joints[jx].Read(reader);
            }
            Position = new TSkeletonPoint();
            Position.Read(reader);
            TrackingId    = reader.ReadInt32();
            TrackingState = (TSkeletonTrackingState)reader.ReadInt32();
        }
Esempio n. 8
0
 /// <summary>
 /// Maps a SkeletonPoint to lie within our render space and converts to Point
 /// </summary>
 /// <param name="skelpoint">point to map</param>
 /// <returns>mapped point</returns>
 public static Point SkeletonPointToScreen(TSkeletonPoint skelpoint)
 {
     return new Point(((skelpoint.X + 1) * 320), (480 - (skelpoint.Y + 1) * 240));
 }
Esempio n. 9
0
 public TJoint(Joint joint)
 {
     JointType = (TJointType)joint.JointType;
     Position = new TSkeletonPoint(joint.Position);
     TrackingState = (TJointTrackingState) joint.TrackingState;
 }
Esempio n. 10
0
 public TJoint(Joint joint)
 {
     JointType     = (TJointType)joint.JointType;
     Position      = new TSkeletonPoint(joint.Position);
     TrackingState = (TJointTrackingState)joint.TrackingState;
 }
Esempio n. 11
0
        protected override void Analyze(FrameReadyEventArgs frameReadyEventArgs)
        {
            var frames = _framesCollector.GetFrames(LastFrameTimestamp).ToList();
            if (frames.Count == 0)
            {
                return;
            }

            var torsoPosHistory = frames.Select(a => a.GetNearestSkeleton().Joints.FirstOrDefault(b => b.JointType == TJointType.Spine)).ToList();
            var LeftHandPosHistory = frames.Select(a => a.GetNearestSkeleton().Joints.FirstOrDefault(b => b.JointType == TJointType.HandLeft)).ToList();
            var RightHandPosHistory = frames.Select(a => a.GetNearestSkeleton().Joints.FirstOrDefault(b => b.JointType == TJointType.HandRight)).ToList();

            var lastLeftHandFrame = LeftHandPosHistory.Last();
            var lastRightHandFrame = RightHandPosHistory.Last();
            var lastTorsoFrame = torsoPosHistory.Last();

            var diffLeft = lastTorsoFrame.Position.Z - lastLeftHandFrame.Position.Z;
            var diffRight = lastTorsoFrame.Position.Z - lastRightHandFrame.Position.Z;

            if (ignoredCalls > 0)
            {
                ignoreCallsTrigger = true;
                ignoredCalls--;
                return;
            }
            else if (ignoreCallsTrigger == true)
            {
                ignoreCallsTrigger = false;
                LeftLastPosition = lastLeftHandFrame.Position;
                RightLastPosition = lastRightHandFrame.Position;
                LastHandsDistance = CalculateDistance(lastLeftHandFrame, lastRightHandFrame);
            }

            Calibrate(diffLeft, diffRight);

            bool left = LeftHandActive(diffLeft, lastLeftHandFrame.Position);
            bool right = RightHandActive(diffRight, lastRightHandFrame.Position);

            if (left && right)
            {
                if (!bothHandsActivated)
                {
                    bothHandsActivated = true;
                    LastHandsDistance = CalculateDistance(lastLeftHandFrame, lastRightHandFrame);
                    LogString.Log("BothHands Activated");
                }

                NavigateByBothHands(lastLeftHandFrame, lastRightHandFrame, frames);
            }
            else if (left)
            {
                NavigateByLeftHand(lastLeftHandFrame, frames);
            }
            else if (right)
            {
                NavigateByRightHand(lastRightHandFrame, frames);
            }
        }
Esempio n. 12
0
        private bool RightHandActive(double diffRight, TSkeletonPoint lastRightHandFrame)
        {
            if (diffRight > Configuration.activeHandDistance)
            {
                if ( ! rightHandActivated)
                {
                    LogString.Log("RightHand Activated");
                    RightLastPosition = lastRightHandFrame;
                    rightHandActivated = true;
                    ignoredCalls = Configuration.framesSkipped;
                }

                return true;
            }
            else if (rightHandActivated)
            {
                LogString.Log("RightHand Deactivated");
                bothHandsActivated = false;
                rightHandActivated = false;
            }
            return false;
        }
Esempio n. 13
0
        private void NavigateByLeftHand(TJoint lastLeftHandFrame, List<Frame> frames)
        {
            var transitionX = lastLeftHandFrame.Position.X - LeftLastPosition.X;
            var transitionY = lastLeftHandFrame.Position.Y - LeftLastPosition.Y;

            var transitionVector = new Vector3() { X = transitionX, Y = transitionY };

            Raise(() => RaiseEvent(frames, transitionVector, 0, ControlType.LEFT_HAND));

            LeftLastPosition = lastLeftHandFrame.Position;
        }