/* 1. Select a person most likely for gesture * 2. Wait until triggering conditions are met * 3. Wait for 0.5 seconds when triggered before starting the reading * 4. Read while checking the boundaries * 5. When a rotation is made, and the hands are still again, send a bluetooth signal * a. at each correct angle reading, measure the time spent at that angle * b. if the time exceeds some threshhold (1 second), send a signal * c. if the person wants to continue rotating, he needs to wait a particular amount of time (based on motor rotation speed) * d. reading to commence again for a new rotation * 6. Wait until another rotation is made */ /* Constructor: */ public GesturesMasterControl() { stopWatch = new Stopwatch(); stopWatch_single_event = new Stopwatch(); stopWatch_trigger = new Stopwatch(); running_gesture = GestureRunningState.Unknown; right_elbow_general_state = JointGeneralState.Unknown; left_elbow_general_state = JointGeneralState.Unknown; right_arm_position = ArmPosition.Unknown; left_arm_position = ArmPosition.Unknown; lf_elbow_prev_pos = new Joint[PREV_FRAMES_ARRAY_LENGTH]; rt_elbow_prev_pos = new Joint[PREV_FRAMES_ARRAY_LENGTH]; shoulder_to_elbow_left = new Vector3D(); shoulder_to_elbow_right = new Vector3D(); elbow_to_hand_left = new Vector3D(); elbow_to_hand_right = new Vector3D(); }
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(); }