void Plot(JointID centerID, JointID baseID, List<Joint> joints)
        {
            float centerX;
            float centerY;

            GetCoordinates(centerID, joints, out centerX, out centerY);

            float baseX;
            float baseY;

            GetCoordinates(baseID, joints, out baseX, out baseY);

            double diameter = Math.Abs(baseY - centerY);

            Ellipse ellipse = new Ellipse
            {
                Width = diameter,
                Height = diameter,
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment = VerticalAlignment.Top,
                StrokeThickness = 4.0,
                Stroke = new SolidColorBrush(Colors.Green),
                StrokeLineJoin = PenLineJoin.Round
            };

            Canvas.SetLeft(ellipse, centerX - ellipse.Width / 2);
            Canvas.SetTop(ellipse, centerY - ellipse.Height / 2);

            rootCanvas.Children.Add(ellipse);
        }
 public HorizontalPunchLikeGesture(float treshold, JointID joint)
 {
     _treshold = treshold;
     _joint = joint;
     _positions = new LinkedList<PosInfo>();
     Duration = 150;
 }
Example #3
0
 internal static void SetPoint(this User user, JointID joint, Point3D newPoint)
 {
     switch (joint)
     {
         case JointID.Head:
             user.Head = newPoint;
             break;
         case JointID.AnkleLeft:
             user.AnkleLeft = newPoint;
             break;
         case JointID.ElbowLeft:
             user.ElbowLeft = newPoint;
             break;
         case JointID.FootLeft:
             user.FootLeft = newPoint;
             break;
         case JointID.HandLeft:
             user.HandLeft = newPoint;
             break;
         case JointID.KneeLeft:
             user.KneeLeft = newPoint;
             break;
         case JointID.ShoulderLeft:
             user.ShoulderLeft = newPoint;
             break;
         case JointID.HipLeft:
             user.HipLeft = newPoint;
             break;
         case JointID.ShoulderCenter:
             user.ShoulderCenter = newPoint;
             break;
         case JointID.AnkleRight:
             user.AnkleRight = newPoint;
             break;
         case JointID.ElbowRight:
             user.ElbowRight = newPoint;
             break;
         case JointID.FootRight:
             user.FootRight = newPoint;
             break;
         case JointID.HandRight:
             user.HandRight = newPoint;
             break;
         case JointID.KneeRight:
             user.KneeRight = newPoint;
             break;
         case JointID.HipRight:
             user.HipRight = newPoint;
             break;
         case JointID.ShoulderRight:
             user.ShoulderRight = newPoint;
             break;
         case JointID.Spine:
             user.Spine = newPoint;
             break;
         case JointID.HipCenter:
             user.HipCenter = newPoint;
             break;
     }
 }
        public KinectMouse(Game game, MovementTracker tracker, JointID mouseJoint)
            : base(game)
        {
            _tracker = tracker;

            _tracker.AddMovementHandler(MovementType.Any, 0f, HandleMouseEvent, mouseJoint);
        }
Example #5
0
 protected virtual void OnSelfTouchDetected(int userid, JointID[] joints)
 {
     EventHandler<SelfTouchEventArgs> handler = SelfTouchDetected;
     if (handler != null)
     {
         handler(this, new SelfTouchEventArgs(userid, joints));
     }
 }
Example #6
0
 public static Vector3D vectorFromJoint(JointID id, JointsCollection kinectJoints)
 {
     Vector3D v = new Vector3D();
     v.X = kinectJoints[id].Position.X;
     v.Y = kinectJoints[id].Position.Y;
     v.Z = kinectJoints[id].Position.Z;
     return v;
 }
Example #7
0
 public void UpdateBonePosition(Microsoft.Research.Kinect.Nui.JointsCollection joints, JointID j1, JointID j2)
 {
     var seg = new Segment(joints[j1].Position.X * playerScale + playerCenter.X,
                           playerCenter.Y - joints[j1].Position.Y * playerScale,
                           joints[j2].Position.X * playerScale + playerCenter.X,
                           playerCenter.Y - joints[j2].Position.Y * playerScale);
     seg.radius = Math.Max(3.0, playerBounds.Height * BONE_SIZE) / 2;
     UpdateSegmentPosition(j1, j2, seg);
 }
        void GetCoordinates(JointID jointID, IEnumerable<Joint> joints, out float x, out float y)
        {
            var joint = joints.Where(j => j.ID == jointID).First();

            skeletonEngine.SkeletonToDepthImage(joint.Position, out x, out y);

            x = (float)(x * rootCanvas.ActualWidth);
            y = (float)(y * rootCanvas.ActualHeight);
        }
Example #9
0
 void UpdateSegmentPosition(JointID j1, JointID j2, Segment seg)
 {
     var bone = new Bone(j1, j2);
     if (segments.ContainsKey(bone))
     {
         BoneData data = segments[bone];
         data.UpdateSegment(seg);
         segments[bone] = data;
     }
     else
         segments.Add(bone, new BoneData(seg));
 }
Example #10
0
 public Vector this[JointID id]
 {
     get
     {
         switch (id)
         {
             case JointID.Head:
                 return Head;
             case JointID.HandLeft:
                 return LeftHand;
             case JointID.HandRight:
                 return RightHand;
         }
         return new Vector();
     }
 }
Example #11
0
 public bool IsJointHidden(JointID id)
 {
     if (!IsInWheelchair)
         return true;
     switch (id)
     {
         case JointID.AnkleLeft:
         case JointID.AnkleRight:
         case JointID.KneeLeft:
         case JointID.KneeRight:
         case JointID.FootLeft:
         case JointID.FootRight:
             return true;
         default:
             return false;
     }
 }
Example #12
0
        public static Point3D GetPoint(this IUserChangedEvent evt, JointID joint)
        {
            switch (joint)
            {
                case JointID.Head:
                    return evt.Head;
                case JointID.AnkleLeft:
                    return evt.AnkleLeft;
                case JointID.ElbowLeft:
                    return evt.ElbowLeft;
                case JointID.FootLeft:
                    return evt.FootLeft;
                case JointID.HandLeft:
                    return evt.HandLeft;
                case JointID.KneeLeft:
                    return evt.KneeLeft;
                case JointID.ShoulderLeft:
                    return evt.ShoulderLeft;
                case JointID.HipLeft:
                    return evt.HipLeft;
                case JointID.ShoulderCenter:
                    return evt.ShoulderCenter;
                case JointID.AnkleRight:
                    return evt.AnkleRight;
                case JointID.ElbowRight:
                    return evt.ElbowRight;
                case JointID.FootRight:
                    return evt.FootRight;
                case JointID.HandRight:
                    return evt.HandRight;
                case JointID.KneeRight:
                    return evt.KneeRight;
                case JointID.HipRight:
                    return evt.HipRight;
                case JointID.ShoulderRight:
                    return evt.ShoulderRight;
                case JointID.Spine:
                    return evt.Spine;
                case JointID.HipCenter:
                    return evt.HipCenter;
            }

            return default(Point3D);
        }
Example #13
0
 public void UpdateJointPosition(JointsCollection joints, JointID j)
 {
     var seg = new PlayerUtils.Segment(joints[j].Position.X * playerScale + playerCenter.X,
                           playerCenter.Y - joints[j].Position.Y * playerScale);
     seg.radius = playerBounds.Height * ((j == JointID.Head) ? HEAD_SIZE : HAND_SIZE) / 2;
     UpdateSegmentPosition(j, j, seg);
 }
Example #14
0
        void DrawJointSkeleton(JointID start_joint, JointID end_joint, Color color)
        {
            //int startid=(int)start_joint, endid=(int)end_joint;

            if (!tracker.isJointTracked(start_joint) || !tracker.isJointTracked(end_joint)) return;

            debugMsg.WriteLine("DrawJointSkeleton(" + start_joint + ", " + end_joint + ", " + color + ")--("
                + tracker.GetJointPosition2(start_joint) + ", " + tracker.GetJointPosition2(end_joint) + ")"
                , DebugMsg.DrawJointSkeleton);

            DrawLine(tracker.GetJointPosition2(start_joint), tracker.GetJointPosition2(end_joint), color);

        }
Example #15
0
 private Joint? SelectHand(SkeletonData firstSq, JointID id)
 {
     return (from Joint j in firstSq.Joints
             where (j.ID == id)
             select new Nullable<Joint>(j)).FirstOrDefault();
 }
Example #16
0
        private void drawJoint(SkeletonData sd, JointID i)
        {
            Joint j;
            dot a;
            j = sd.Joints[i];
            j = j.ScaleTo(310, 244, 1.6f,1.6f);
            Point p = new Point(j.Position.X, j.Position.Y);
            Point off = new Point(0, 5);

            if (i == JointID.Head)
            {
                a = new dot(7,7,2,Brushes.Blue, off);
            }

            else
            {
                a = new dot(7, 7, 2, Brushes.Red, off);
            }
            a.moveDot(canvas, p);
        }
Example #17
0
        private double[] getPos(SkeletonData s)
        {
            //pFeature pf = new pFeature();
            double[] pf = new double [21];
            int i = 0;
            x = s.Joints[JointID.Spine].Position.X;
            y = s.Joints[JointID.Spine].Position.Y;
            z = s.Joints[JointID.Spine].Position.Z;

            //pf.lh.x = s.Joints[JointID.HandLeft].Position.X - x;
            //pf.lh.y = s.Joints[JointID.HandLeft].Position.Y - y;
            //pf.lh.z = s.Joints[JointID.HandLeft].Position.Z - z;
            JointID[] jid = new JointID[7]{JointID.ElbowLeft, JointID.ElbowRight, JointID.WristLeft, JointID.WristRight,
                                JointID.Head, JointID.ShoulderLeft, JointID.ShoulderRight};
            //Console.WriteLine(" \n");
            foreach (JointID id in jid)
            {
                /*for calcultion efficiency, we're adding 10 to the posiiton coord and dividing by 20*/
                pf[i] = (s.Joints[id].Position.X - x + 10) / 20;
                pf[i + 1] = (s.Joints[id].Position.Y - y + 10) / 20;
                pf[i + 2] = (s.Joints[id].Position.Z - z + 10) / 20;
                //Console.WriteLine(pf[i] + " " + pf[i + 1] + " " + pf[i + 2] + " ");
                i += 3;
            }

            return pf;
        }
 private static Vector3D To3DVector(this SkeletonData data, JointID joint)
 {
     var v = data.Joints[joint].Position;
     return new Vector3D(v.X, v.Y, v.Z);
 }
Example #19
0
 public Joint getJoint(JointID id)
 {
     return this.joints[id];
 }
Example #20
0
        void DrawJoint(JointID joint, Color color)
        {
            Point jointPos;

            if (!tracker.isJointTracked(joint)) return;

            debugMsg.WriteLine("DrawJoint(" + joint + ", " + color + ")--(" + tracker.GetJointPosition2(joint) + ")"
                , DebugMsg.DrawJoint);

            jointPos = tracker.GetJointPosition2(joint);
            DrawBox(new Point(jointPos.X - 5, jointPos.Y - 5), new Point(jointPos.X + 5, jointPos.Y + 5), color);

        }
Example #21
0
        private Joint getAndDrawJoint(SkeletonData skel, JointID jointID, Ellipse ellipse)
        {
            Joint jt = skel.Joints[jointID].ScaleTo((int)canvas1.Height, (int)(canvas1.Width), .8f, .8f);

            Canvas.SetLeft(ellipse, jt.Position.X + ellipse.Width / 2);
            Canvas.SetTop(ellipse, jt.Position.Y + ellipse.Height / 2);

            ellipse.Visibility = System.Windows.Visibility.Visible;
            return jt;
        }
        void Trace(JointID sourceID, JointID destinationID, List<Joint> joints)
        {
            float sourceX;
            float sourceY;

            GetCoordinates(sourceID, joints, out sourceX, out sourceY);

            float destinationX;
            float destinationY;

            GetCoordinates(destinationID, joints, out destinationX, out destinationY);

            Line line = new Line
                            {
                                X1 = sourceX,
                                Y1 = sourceY,
                                X2 = destinationX,
                                Y2 = destinationY,
                                HorizontalAlignment = HorizontalAlignment.Left,
                                VerticalAlignment = VerticalAlignment.Top,
                                StrokeThickness = 4.0,
                                Stroke = new SolidColorBrush(Colors.Green),
                                StrokeLineJoin = PenLineJoin.Round
                            };

            rootCanvas.Children.Add(line);
        }
Example #23
0
 private void SwitchHandsButton_Click(object sender, RoutedEventArgs e)
 {
     JointID temporary = MotionHand;
     MotionHand = SelectionHand;
     SelectionHand = temporary;
     ReturnedToCenter = false;
     BlueFlash = DateTime.Now;
     if (MotionHand == JointID.HandRight)
     {
         SwitchHandsButton.Content = "Switch Hand to Left";
     }
     else
     {
         SwitchHandsButton.Content = "Switch Hand to Right";
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CorrectionFilterEventArgs"/> class.
 /// </summary>
 /// <param name="jointToCorrect">The joint to correct.</param>
 /// <param name="point">The point.</param>
 /// <param name="correction">The correction.</param>
 public CorrectionFilterEventArgs(JointID jointToCorrect, Point3D point, Point3D correction)
 {
     JointToCorrect = jointToCorrect;
     Point = point;
     Correction = correction;
 }
Example #25
0
 public Vector GetJointPosition(JointID joint)
 {
     return skeleton.Joints[joint].Position;
 }
 public Bone(JointID j1, JointID j2)
 {
     joint1 = j1;
     joint2 = j2;
 }
 public TranslationGesture(Game game, MovementTracker tracker, JointID cursor = JointID.HandRight)
     : base(game)
 {
     _cursor = cursor;
     _tracker = tracker;
 }
 public void Move(JointID jointid, int negative)
 {
     var angle = negative != 0 ? 10 : -10;
     _robotArm.turnByOffset(jointid, angle);
 }
Example #29
0
 public void UpdateJointPosition(Microsoft.Research.Kinect.Nui.JointsCollection joints, JointID j)
 {
     var seg = new Segment(joints[j].Position.X * playerScale + playerCenter.X,
                           playerCenter.Y - joints[j].Position.Y * playerScale);
     seg.radius = playerBounds.Height * ((j == JointID.Head) ? HEAD_SIZE : HAND_SIZE) / 2;
     UpdateSegmentPosition(j, j, seg);
 }
Example #30
0
 private void SwitchHandsButton_Click(object sender, RoutedEventArgs e)
 {
     JointID temporary = MotionHand;
     MotionHand = SelectionHand;
     SelectionHand = temporary;
     if (MotionHand == JointID.HandRight)
     {
         SwitchHandsButton.Content = "Switch Hand to Left";
     }
     else
     {
         SwitchHandsButton.Content = "Switch Hand to Right";
     }
 }