The National Highway Traffic Safety Administration estimates there to be about 72,000 crashes, 44,000 injuries and 6,000 fatalities occurring a year as a result of drowsy driving. While smart vehicles are becoming increasingly commonplace on roads today, the high price tag limits the potential of smart safety systems.
What it does
DriveAlert is a way to extend smart-car safety to everyone. For about $40 anyone can place a DriveAlert box on their dashboard and add active drowsiness detection to their car while they drive. As you drive, it takes note of how frequently you close your eyes and alerts you when you've surpassed the threshold, which is a likely indicator you've begun to fall asleep. DriveAlert will then play music to wake you back up and also send a text message to your designated emergency contacts notifying them that you've fallen asleep at the wheel and telling them to come pick you up.
How we built it
We used OpenCV to determine whether the user's eyes were present and if they were, whether they were open or not. We used Tensorflow and Keras to process the eyes through a model trained by a CNN. Then, we used Flask to build an API in which we exposed this data for consumption by our frontend, which displays the current stats. For music, we used aplay to play music through a connected bluetooth device. And for text notifications, we used the Twilio SMS API.
Challenges we ran into
Initially, we had issues interfacing with the Raspberry Pi externally because of dynamic IP addressing. We did not have access to the main router so it was difficult to assign the Pi a static IP address. We eventually addressed this issue by using Twilio which sent an email out to our team with the dynamic IP address of the Raspberry Pi. We also needed to introduce multithreading and sockets in our program to separate our processes because multiple readings needed to be accessed simultaneously. This was technically challenging because we had zero prior knowledge on the technology beforehand and thus the implementation was perplexing and cumbersome. Lots of issues occurred when interfacing both the hardware and software. We may have encountered these issues due to hardware limitations since we needed to run a machine learning algorithm with close to 3,000 images, interface and compare these images with a live recording from the camera module, and run the Pi as a server module that received and sent requests from our website.
Accomplishments that we're proud of
We were proud of making something that could potentially impact millions of drivers.
What we learned
- Setting up IoT devices
- How to use OpenCV
- Connecting to devices via bluetooth
- You shouldn't use React.js for everything
- Adding multithreading in Python
- Flask websockets is a pain
- There's a lot to learn
What's next for DriveAlert
We want to gather more training data to improve detection of eyes. Although the Raspberry Pi doesn't have built-in GPS functionalities, we would still want to utilize location data to determine the user's current speed and also send users' location to emergency contacts. Additionally, we would like to design a better enclosure for the device. In the future, we would like to make every DriveAlert box have its own wi-fi network so it can operate independently of any network. We would also like to integrate DriveAlert with more sensors so we can make users' driving experiences even safer by detecting things like lane departure and collision avoidance.