public void SetWaitForStart() { // Initial state state = ResultStateT.WAIT_FOR_START; // No minimum found yet minimum = double.PositiveInfinity; score = minimum; // Gesture Boundaries startFrameNo = -1; endFrameNo = -1; }
/** * Called when a gesture is recognized. */ public void SetWaitForEnd(ContinuousResult result) { boundary = result.endFrameNo; state = ResultStateT.WAIT_FOR_END; }
/** * Update internal FSM based on current score. */ public void Update( double score, double threshold, int start_frame_no, int end_frame_no, int current_frame_no) { // Set up current frame if necessary if (current_frame_no == -2) { current_frame_no = end_frame_no; } // Wait for the score to pass below the // rejection threshold if (state == ResultStateT.WAIT_FOR_START) { // If waiting, make sure the minimum matches // the actual score. minimum = score; if (score < threshold) { state = ResultStateT.LOOKING_FOR_MINIMUM; } } // Although the gesture is in the accept zone, we // may have not reached the best score yet. if (state == ResultStateT.LOOKING_FOR_MINIMUM) { // save data on new minimum if (score <= minimum) { minimum = score; this.score = minimum; this.startFrameNo = start_frame_no; this.endFrameNo = end_frame_no; } // // Timeout // int frame_cnt = current_frame_no - this.endFrameNo; bool timeout = (frame_cnt >= options.latencyFrameCount); if (timeout == true) { state = ResultStateT.TRIGGER; return; } } // Trigger operation is complete, so advance. if (state == ResultStateT.TRIGGER) { state = ResultStateT.WAIT_FOR_END; } // Wait until we leave the accept zone // to avoid triggering again. if (state == ResultStateT.WAIT_FOR_END) { bool advance = true; //advance &= start_frame_no > boundary; advance &= score > rejection_threshold; if (advance) { // this.Reset(); state = ResultStateT.WAIT_FOR_START; } } }