Пример #1
0
        /// <summary>
        /// Measure the user to give a more personalizated positions
        /// </summary>
        /// <param name="skel">Skeleton tracked to determine user measures</param>
        /// <param name="actual_frame">Number of the actual frame to determine the waiting time</param>
        private void measureUser(Skeleton skel, int actual_frame)
        {
            this.statusBarText.Text = "Ponte en esta posición. \n Vamos a medirte.";
            this.measure_imagen.Visibility = Visibility.Visible;
            // Show the guide image
            this.measure_imagen.Source = new BitmapImage(new Uri(System.IO.Path.GetFullPath("../../images/img.png")));

            SkeletonPoint right_shoulder = skel.Joints[JointType.ShoulderRight].Position;
            SkeletonPoint right_elbow = skel.Joints[JointType.ElbowRight].Position;
            SkeletonPoint right_wrist = skel.Joints[JointType.WristRight].Position;
            arm = (float)Math.Sqrt((double)(Math.Pow((right_shoulder.X - right_elbow.X), 2) +
                Math.Pow((right_shoulder.Y - right_elbow.Y), 2) +
                Math.Pow((right_shoulder.Z - right_elbow.Z), 2)));
            forearm = (float)Math.Sqrt((double)(Math.Pow((right_wrist.X - right_elbow.X), 2) +
                Math.Pow((right_wrist.Y - right_elbow.Y), 2) +
                Math.Pow((right_wrist.Z - right_elbow.Z), 2)));

            SkeletonPoint[] measuring_points = new SkeletonPoint[4];
            measuring_points[0] = sum(skel.Joints[JointType.ShoulderRight].Position, arm+0.05, -0.05, 0);
            measuring_points[1] = sum(skel.Joints[JointType.ShoulderRight].Position, (arm + forearm) + 0.05, -0.05, 0);
            measuring_points[2] = sum(skel.Joints[JointType.ShoulderLeft].Position, -arm-0.05, -0.05, 0);
            measuring_points[3] = sum(skel.Joints[JointType.ShoulderLeft].Position, -(arm + forearm) - 0.05, -0.05, 0);

            if (first_frame_measure == -1) {
                //Defines the measuring gesture
                JointType[] measuring_joints = new JointType[4];
                measuring_joints[0] = JointType.ElbowRight;
                measuring_joints[1] = JointType.HandRight;
                measuring_joints[2] = JointType.ElbowLeft;
                measuring_joints[3] = JointType.HandLeft;
                measuring = new Gesture(measuring_points, measuring_joints, my_KinectSensor, 3);

                // Begin the count
                first_frame_measure = actual_frame;
            }
            measuring.adjustLocations(measuring_points);
            measuring.adjustColor(skel, actual_frame);

            if (measuring.isCompleted()) {
                measured = true;
                first_frame_measure = -1;   // To ensure that the next time that an user need to be measured, he is
                state = States.CHECKING_GESTURE;
            }
        }
Пример #2
0
        /// <summary>
        /// Determine gestures and guides positions
        /// </summary>
        /// <param name="skel">Skeleton tracked to determine guides positions</param>
        private void initializeElements(Skeleton skel)
        {
            SkeletonPoint[] gesture_points = new SkeletonPoint[2];
            gesture_points[0] = sum(skel.Joints[JointType.ShoulderRight].Position, 0.9*arm, 0.9*forearm, -0.1);
            gesture_points[1] = sum(skel.Joints[JointType.ShoulderRight].Position, 0.9*arm, -0.1, -0.1);
            JointType[] gesture_joints = new JointType[2];
            gesture_joints[0] = JointType.HandRight;
            gesture_joints[1] = JointType.ElbowRight;
            gesture = new Gesture(gesture_points, gesture_joints, my_KinectSensor, 2);

            movement_1 = new Gesture(sum(skel.Joints[JointType.HipRight].Position, 0.1, -0.1, 0), JointType.HandRight, my_KinectSensor, 2);
            movement_2 = new Gesture(sum(skel.Joints[JointType.ShoulderLeft].Position, -0.05, 0, -(arm+ forearm)), JointType.HandRight, my_KinectSensor, 2);
            movement_3 = new Gesture(sum(skel.Joints[JointType.ShoulderRight].Position, -0.05, 0, -1.05*(arm+ forearm)), JointType.HandRight, my_KinectSensor, 2);

            exit = new Gesture(sum(skel.Joints[JointType.Head].Position, -2*(arm+ forearm), -0.05, 0), JointType.HandLeft, my_KinectSensor, 3);
            exit.setDistanceColor(0, Brushes.Purple);
            exit.setDistanceColor(1, Brushes.Blue);
            exit.setDistanceColor(2, Brushes.Gray);
            exit.setTimeColor(Brushes.Red);
        }