Supporting head nodding and shaking

I’m currently developing a simple Cardboard-oriented game and wanted to implement some head movement into my gameplay so that I could hook up some actions to head nods (both up and down) and head shake (the “no” movement). Is there any easy way of handling these? The only way I thought of would be to manually catch the direction at which the head turned at each frame and if for a given number of consecutive frames the movement happened in the given direction (for example, only up on the Y axis with minimal change in X for the up nod), then interpret this as a given gesture.

Is there any less cumbersome way of doing this?

I don’t think so. Pretty much all gesture recognition systems work in this way. Then they may be more or less complicated when it comes to continuous recognition, sensitivity to deviations, and aborting a recognition mid-way and starting a new one. In general they are all based on capturing a sequence of positions and recognizing when they match a given pattern.