private bool isIntermediaryFrameValidGestureFrame(GESTURE gesture, GestureDatabase gestureDatabase) { Skeleton currentSkeleton; AppropriateJointInfo currentAptJointInfo; gestureDatabase.getLastRecord(out currentSkeleton, out currentAptJointInfo); Vector2D currentElbowShoulder = new Vector2D((currentAptJointInfo.shoulderRightPos.X - currentAptJointInfo.elbowRightPos.X), (currentAptJointInfo.shoulderRightPos.Y - currentAptJointInfo.elbowRightPos.Y)); Vector2D currentElbowHand = new Vector2D((currentAptJointInfo.handRightPos.X - currentAptJointInfo.elbowRightPos.X), (currentAptJointInfo.handRightPos.Y - currentAptJointInfo.elbowRightPos.Y)); double angle = currentElbowShoulder.angleTo(currentElbowHand); switch (gesture) { case GESTURE.CONST_LEFT: { if (currentAptJointInfo.shoulderCenterPos.Y > currentAptJointInfo.handRightPos.Y && currentAptJointInfo.shoulderCenterPos.Y > currentAptJointInfo.elbowRightPos.Y && currentAptJointInfo.handRightPos.X < currentAptJointInfo.elbowRightPos.X && currentElbowShoulder.cpsign(currentElbowHand) > 0 && angle >= CONST_LEFT_GESTURE_MIN_THETA - THRESHOLD_ANGLE_DEFLECTION && angle <= CONST_LEFT_GESTURE_MAX_THETA + THRESHOLD_ANGLE_DEFLECTION) { return true; } } break; case GESTURE.CONST_RIGHT: { if ( currentAptJointInfo.shoulderCenterPos.Y > currentAptJointInfo.elbowRightPos.Y && currentAptJointInfo.elbowRightPos.Y > currentAptJointInfo.handRightPos.Y && currentAptJointInfo.handRightPos.X > currentAptJointInfo.elbowRightPos.X && currentElbowShoulder.cpsign(currentElbowHand) < 0 && angle >= CONST_RIGHT_GESTURE_MIN_THETA - THRESHOLD_ANGLE_DEFLECTION && angle <= CONST_RIGHT_GESTURE_MAX_THETA + THRESHOLD_ANGLE_DEFLECTION) { return true; } } break; } return false; }
private bool isHandAngleDeflectionWithInBounds(GESTURE gesture, GestureDatabase gestureDatabase) { Skeleton skeleton; AppropriateJointInfo aptJoint; switch (gesture) { case GESTURE.CONST_LEFT: { gestureDatabase.getLastRecord(out skeleton, out aptJoint); Vector2D elbowShoulder = new Vector2D(aptJoint.shoulderRightPos.X - aptJoint.elbowRightPos.X, aptJoint.shoulderRightPos.Y - aptJoint.elbowRightPos.Y); Vector2D elbowHand = new Vector2D(aptJoint.handRightPos.X - aptJoint.elbowRightPos.X, aptJoint.handRightPos.Y - aptJoint.elbowRightPos.Y); if (elbowShoulder.cpsign(elbowHand) > 0 && elbowShoulder.angleTo(elbowHand) >= CONST_LEFT_GESTURE_MIN_THETA - THRESHOLD_ANGLE_DEFLECTION && elbowShoulder.angleTo(elbowHand) <= CONST_LEFT_GESTURE_MAX_THETA + THRESHOLD_ANGLE_DEFLECTION) { return true; } break; } case GESTURE.CONST_RIGHT: { gestureDatabase.getLastRecord(out skeleton, out aptJoint); Vector2D elbowShoulder = new Vector2D(aptJoint.shoulderRightPos.X - aptJoint.elbowRightPos.X, aptJoint.shoulderRightPos.Y - aptJoint.elbowRightPos.Y); Vector2D elbowHand = new Vector2D(aptJoint.handRightPos.X - aptJoint.elbowRightPos.X, aptJoint.handRightPos.Y - aptJoint.elbowRightPos.Y); if (elbowShoulder.cpsign(elbowHand) < 0 && elbowShoulder.angleTo(elbowHand) >= CONST_RIGHT_GESTURE_MIN_THETA - THRESHOLD_ANGLE_DEFLECTION && elbowShoulder.angleTo(elbowHand) <= CONST_RIGHT_GESTURE_MAX_THETA + THRESHOLD_ANGLE_DEFLECTION) { return true; } break; } } return false; }