예제 #1
0
        internal void initializeGesture()
        {
            // Initiation successful, we can signal the beginning of rotation angle reading:
            left_arm_rotation.rot_tracking_state  = ArmRotationTrackingState.Initialized;
            right_arm_rotation.rot_tracking_state = ArmRotationTrackingState.Initialized;

            // Initialing the rotation state:
            left_arm_rotation.previous_rot_state  = ArmRotationalState.NotRotating;
            right_arm_rotation.previous_rot_state = ArmRotationalState.NotRotating;

            // Passing this shoulder to elbow vector so that on the next event we can compare:
            left_arm_rotation.previous_frame_vector = GestureAuxilaryMethods.updateLimbVectors(JointType.ShoulderLeft,
                                                                                               JointType.ElbowLeft);
            right_arm_rotation.previous_frame_vector = GestureAuxilaryMethods.updateLimbVectors(JointType.ShoulderRight,
                                                                                                JointType.ElbowRight);
        }
예제 #2
0
        public void runGestureAnalysis()
        {
            stopWatch_single_event.Reset();
            stopWatch_single_event.Start();
            TextInformation.insert_main_text_block("Stopwatch: " + stopWatch.Elapsed, 3);
            TextInformation.insert_main_text_block("Running Gesture: " + running_gesture.ToString(), 1);

            // I have moved the next 4 blocks of codes out of the if statement...
            /* Searching State: CHANGED FROM WRIST TO ELBOW */
            Joint left_elbow  = body.Joints[JointType.ElbowLeft];
            Joint right_elbow = body.Joints[JointType.ElbowRight];

            // We make a call to this method to store previous positions:
            GestureAuxilaryMethods.managePrevArray(left_elbow, ref lf_elbow_prev_pos, PREV_FRAMES_ARRAY_LENGTH);
            GestureAuxilaryMethods.managePrevArray(right_elbow, ref rt_elbow_prev_pos, PREV_FRAMES_ARRAY_LENGTH);

            // We make a call to the following methods in order to update the state of elbows:
            GestureAuxilaryMethods.isJointStable(stillness_sensitivity, JointType.ElbowLeft, lf_elbow_prev_pos, PREV_FRAMES_ARRAY_LENGTH,
                                                 ref left_elbow_general_state);
            GestureAuxilaryMethods.isJointStable(stillness_sensitivity, JointType.ElbowRight, rt_elbow_prev_pos, PREV_FRAMES_ARRAY_LENGTH,
                                                 ref right_elbow_general_state);

            // The if else block below is to see if we are in the searching (for gesture) state or reading (the gesture) state:
            if (running_gesture == GestureRunningState.None || running_gesture == GestureRunningState.Unknown)
            {
                if (left_elbow_general_state == JointGeneralState.Still && right_elbow_general_state == JointGeneralState.Still)
                {
                    // Calling this method to see if a panel rotation gesture is possible:
                    if (Gesture_PanelRotation.checkPanelRotationGesture(horizontal_stretch_sensitivity, ref left_arm_position, ref right_arm_position))
                    {
                        // We can now initialize a PanelRotation class and go on further:
                        panel_rotation = new Gesture_PanelRotation(left_arm_position, right_arm_position, horizontal_stretch_sensitivity);
                        panel_rotation.initializeGesture();

                        // Update the gesture state:
                        running_gesture = GestureRunningState.PanelRotation;

                        // Start the stopwatch, we will wait .5 seconds for the gesture reading to begin:
                        stopWatch_trigger.Start();
                    }
                }
            }
            else      /* Reading State: */
            {
                if (stopWatch_trigger.ElapsedMilliseconds > 500)
                {
                    int reading_result = 0;

                    // There is a gesture that is to be read, we need to check which:
                    if (running_gesture == GestureRunningState.PanelRotation)
                    {
                        reading_result = panel_rotation.readArmRotation(left_elbow_general_state, right_elbow_general_state);
                    }

                    if (reading_result == -1)
                    {
                        // Discontinue the reading of the gesture:
                        running_gesture = GestureRunningState.None;

                        // Clear out the previous hand positions arrays:
                        lf_elbow_prev_pos = new Joint[PREV_FRAMES_ARRAY_LENGTH];
                        rt_elbow_prev_pos = new Joint[PREV_FRAMES_ARRAY_LENGTH];

                        // Clear out the statuses of Limbs:
                        left_elbow_general_state  = JointGeneralState.Unknown;
                        right_elbow_general_state = JointGeneralState.Unknown;

                        // Reset the stopwatch:
                        stopWatch_trigger.Reset();
                    }
                }
            }

            TextInformation.insert_main_text_block("Event: " + stopWatch_single_event.Elapsed, 3);
            TextInformation.update_main_text();
        }
예제 #3
0
        // This method returns 0 if everything went well, -1 if reading of the gesture is stopped:
        internal int readArmRotation(JointGeneralState left_elbow_general_state, JointGeneralState right_elbow_general_state)
        {
            // Moved these two lines out of the if statement:
            shoulder_to_elbow_left  = GestureAuxilaryMethods.updateLimbVectors(JointType.ShoulderLeft, JointType.ElbowLeft);
            shoulder_to_elbow_right = GestureAuxilaryMethods.updateLimbVectors(JointType.ShoulderRight, JointType.ElbowRight);

            // Checking the boundary conditions to see if we can actually do the reading:
            if (boundaryConditions(left_elbow_general_state, right_elbow_general_state) == true &&
                (left_arm_rotation.rot_tracking_state == ArmRotationTrackingState.Tracking ||
                 left_arm_rotation.rot_tracking_state == ArmRotationTrackingState.Initialized) &&
                (right_arm_rotation.rot_tracking_state == ArmRotationTrackingState.Tracking ||
                 right_arm_rotation.rot_tracking_state == ArmRotationTrackingState.Initialized))
            {
                left_arm_rotation.rot_tracking_state  = ArmRotationTrackingState.Tracking;
                right_arm_rotation.rot_tracking_state = ArmRotationTrackingState.Tracking;
            }
            else
            {
                left_arm_rotation.rot_tracking_state  = ArmRotationTrackingState.NotTracking;
                right_arm_rotation.rot_tracking_state = ArmRotationTrackingState.NotTracking;
            }

            if (left_arm_rotation.rot_tracking_state == ArmRotationTrackingState.Tracking &&
                right_arm_rotation.rot_tracking_state == ArmRotationTrackingState.Tracking)
            {
                updateRotationStatus();
                updateArmStatus();

                //TextInformation.insert_main_text_block("Left Arm: " + left_arm_rotation.previous_angles[0].ToString(), 2);
                //TextInformation.insert_main_text_block("Right Arm: " + right_arm_rotation.previous_angles[0].ToString(), 2);

                // Lets stabialize the angle:
                left_arm_rotation.stabializeAngle();
                right_arm_rotation.stabializeAngle();

                TextInformation.insert_main_text_block("Angle Left Arm: " + left_arm_rotation.angle.ToString("n4"), 1);
                TextInformation.insert_main_text_block("Angle Right Arm: " + right_arm_rotation.angle.ToString("n4"), 1);

                if (left_arm_rotation.enough_time_at_angle == true && right_arm_rotation.enough_time_at_angle == true)
                {
                    TextInformation.insert_main_text_block("Sending Signal", 1);

                    // Terminating the gesture reading. This might be changed later on:
                    //left_arm_rotation.rot_tracking_state = ArmRotationTrackingState.NotTracking;
                    //right_arm_rotation.rot_tracking_state = ArmRotationTrackingState.NotTracking;
                }
                else
                {
                    TextInformation.insert_main_text_block("NOT Sending Signal", 1);
                }

                left_arm_rotation.frame_counter++;
                right_arm_rotation.frame_counter++;

                // Updating previous vectors:
                left_arm_rotation.previous_frame_vector  = shoulder_to_elbow_left;
                right_arm_rotation.previous_frame_vector = shoulder_to_elbow_right;

                return(0);
            }
            else
            {
                left_arm_rotation.previous_rot_state  = ArmRotationalState.NotRotating;
                right_arm_rotation.previous_rot_state = ArmRotationalState.NotRotating;
                return(-1);
            }
        }