public void processSkeleton(Skeleton skeleton) { if (skeleton != null) { Boolean rightHandLeft = this._righthandwaveindicator.rightHandLeft(skeleton); Boolean rightHandRight = this._righthandwaveindicator.rightHandRight(skeleton); Boolean leftHandLeft = this._lefthandwaveindicator.leftHandLeft(skeleton); Boolean leftHandRight = this._lefthandwaveindicator.leftHandRight(skeleton); Joint rightHand = skeleton.Joints[JointType.HandRight]; Joint leftHand = skeleton.Joints[JointType.HandLeft]; //update right hand state update_rh_state(rightHand, rightHandLeft, rightHandRight); double rh_diff = this._rh_most_right - this._rh_most_left; /*to prevent mix-ups with swiping*/ Boolean rightArmStraight = this._straightarmindicator.isRightArmStraight(skeleton, true); Boolean leftArmStraight = this._straightarmindicator.isLeftArmStraight(skeleton, true); if (rightArmStraight) { WaveState state = new WaveState(WaveState.WavePosition.HAND_BELOW, DateTime.Now, DateTime.Now); this._rightHandHistory.addState(state); reset_extremes("right"); } if (leftArmStraight) { WaveState state = new WaveState(WaveState.WavePosition.HAND_BELOW, DateTime.Now, DateTime.Now); this._leftHandHistory.addState(state); reset_extremes("left"); } /**/ if (!IsWithinBounds(rh_diff) && rh_diff > 0) { WaveState state = new WaveState(WaveState.WavePosition.HAND_BELOW, DateTime.Now, DateTime.Now); this._leftHandHistory.addState(state); reset_extremes("right"); } //update left hand state update_lh_state(leftHand, leftHandLeft, leftHandRight); double lh_diff = this._lh_most_right - this._lh_most_left; if (!IsWithinBounds(lh_diff) && rh_diff > 0) { WaveState state = new WaveState(WaveState.WavePosition.HAND_BELOW, DateTime.Now, DateTime.Now); this._leftHandHistory.addState(state); reset_extremes("left"); } } }
public override Boolean isScenarioDetected() { Boolean rightHandWaved = isWaveDetected(this._rightHandHistory); Boolean leftHandWaved = isWaveDetected(this._leftHandHistory); double rh_diff = this._rh_most_right - this._rh_most_left; double lh_diff = this._lh_most_right - this._lh_most_left; if ( (rightHandWaved && IsWithinBounds(rh_diff) ) || (leftHandWaved && IsWithinBounds(lh_diff) ) ) { WaveState state = new WaveState(WaveState.WavePosition.HAND_BELOW, DateTime.Now, DateTime.Now); this._rightHandHistory.addState(state); this._leftHandHistory.addState(state); reset_extremes("right"); reset_extremes("left"); return true; } else { return false; } }
public ScenarioState finishState(ScenarioState next) { WaveState gualState = new WaveState(this); // make sure this is same state if (!this.isSameState(next)) { if (next.GetType().Equals(this.GetType())) { WaveState nextState = (WaveState)next; // make gualState's start be the earlier of the two if (nextState._start.CompareTo(gualState._start) < 0) { gualState._start = nextState._start; } // make gualState's start be the later of the two if (nextState._end.CompareTo(gualState._end) > 0) { gualState._end = nextState._end; } } } return gualState; }
private void update_rh_state(Joint rightHand, Boolean rightHandLeft, Boolean rightHandRight) { WaveState state; if (rightHandLeft) { state = new WaveState(WaveState.WavePosition.HAND_LEFT, DateTime.Now, DateTime.Now); this._rightHandHistory.addState(state); if (rightHand.Position.X < this._rh_most_left) { this._rh_most_left = rightHand.Position.X; } } else if (rightHandRight) { state = new WaveState(WaveState.WavePosition.HAND_RIGHT, DateTime.Now, DateTime.Now); this._rightHandHistory.addState(state); if (rightHand.Position.X > this._rh_most_right) { this._rh_most_right = rightHand.Position.X; } } else { state = new WaveState(WaveState.WavePosition.HAND_BELOW, DateTime.Now, DateTime.Now); this._rightHandHistory.addState(state); reset_extremes("right"); } }
public WaveState(WaveState goalState) { this._start = goalState._start; this._end = goalState._end; this._pos = goalState._pos; }