Gesture recognition algorithms