A long day, an empty road and too much Classic FM: the perfect recipe for a late-night car crash.

But what if your car could tell when you were getting sleepy and ask you to take a break (or at least switch over to Planet Rock)?

Scientists at the Vanderbilt University in Nashville have come up with a webcam that can tell when you are yawning and catch you before you drift off.

Yawn for the camera

The new system is based around an in-car camera hooked up to image-processing software that captures a sequence of images of the driver's face. It analyses changes in the face and accurately identifies yawning as distinct from other facial movements such as smiling, talking, and singing.

The yawn frequency is then correlated with fatigue behavior and could be hooked up to a warning system to alert drivers to the need to take a break.

The algorithm is effective at yawn detection regardless of image intensity and contrast, small head movements, viewing angle, spectacle wearing, and skin colour.

The US National Highway Traffic Safety Administration estimates that at least 100,000 American road crashes are caused by driver fatigue each year.