Engineering researchers at the University of Waterloo in Canada have created a system capable of determining when a driver is engaged in distracting activity such as texting. The setup uses smart cameras and artificial intelligence (AI) to monitor the driver’s hand movements and determine whether those movements deviate from safe driving behavior.

The system can also perform preventative measures based on what it detects, such as alerting the driver of the potential danger of their actions. In vehicles with self-driving capabilities, the system could also temporarily take control of the car, if it deems the situation dangerous enough.

“This is an integral part of a larger project on driver behavior recognition and driver action prediction for the design of next-generation cognitive Advanced Drivers Assisting Systems,” Fakhri Karray, Waterloo professor of electrical and computer engineering, told Digital Trends. “This should contribute to the design of next-generation systems to be implemented in level-three or level-four self-driving vehicles.”