Inspiration

Last Thanksgiving, I stayed up the whole night trying to finish my homework before the holiday begins. At 5 am the next morning, I begin my 3-hour drive towards Charlotte Airport. The first 2 hours went smoothly, but when I almost arrived at the airport, I feel this irresistible temptation to fall asleep. I can barely keep my eyes open even when I was fully aware that I must do so. I simply can't concentrate physically despite knowing what's happening. That was probably the time I was closest to death, and after that incident, I never consider driving without any sleep again.

In 2017 alone, drowsy driving was responsible for 91,000 crashes—resulting in 50,000 injuries and nearly 800 deaths according to the CDC. Moreover, these numbers might be underestimated. Up to 6,000 fatal crashes each year may be caused by drowsy drivers. Knowing the severity of the problem, we decide to provide a safeguard to the population that is most prone to fatigue driving - truck drivers, Uber drivers, delivery drivers, or simply ordinary long-distance drivers - when they have to drive for an extended period of time. We developed a smartphone application that utilized Opencv to monitor the eyes and mouths of users to make sure they are not asleep and notify the user when they are falling asleep.

What it does

Our project is divided into a few parts.

Before the user starts their trip, they will be filling out a brief survey about their body condition with short questions like "Enough sleep?" and "Drive > 4 hours?" To make sure users are willing to take the survey, not only do we prepare extremely short questions. We also implemented a Tinder-like swipe feature that users simply swipe left or right to answer "Yes" or "No". The data collected during this phase will be used to determine the necessary breaks that the driver must take to complete the drive safely. When the driver selects their destination, our software, working with other mapping APIs such as Google Maps, will gather data and mark out locations with high rates of accidents.

When the driver is ready to start the trip, the application will enter SafeDriving Mode which is the main feature of our app. The app will first measure the Eye Aspect Ratio (EAR) and Mouth Aspect Ratio (MAR) of the user. These two numbers help the app determine if the user's eyes are open, their blink rate, and their yawn rate. The data combined will determine if the driver is fatigue driving. The driver's condition will be separated into 3 levels - Red, Yellow and Green. Red indicates that the driver has closed their eyes for more than 2 seconds. This cause the app to immediately emit an alarm to wake the user. Yellow means that the driver is potentially drowsy, it will suggest the user rest as soon as possible. Green indicates that the driver is in good condition.

How we built it

We use SWIFT to build the question questionnaire before every trip and implement the swipe function. We Python, specifically dlib and opencv to implement blink and yawn detection.

Challenges we ran into

There are a few challenges that we ran into along the way.

First, most software with eye detection uses a fixed value to measure EAR without accounting for the fact that people have different eye sizes. For instance, some of the existing software we tested determines that I am drowsy even when I am opening my eyes regularly. (Yes, my eyes are small) We manage to solve this by implementing a function that customizes the determining EAR and MAR data for every user. This allows a more accurate drowsiness detection.

We also found that most existing software that tries to tackle similar problems is oversimplified in its logic when determining drowsiness. For instance, some simply measure the blink of an eye. To improve their accuracy, we use multiple factors such as blink per minute and yawn per minute to improve the accuracy of the detector.

Lastly, the challenge is definitely the unfamiliarity with new languages and tools. Both my partner and I are completely new to Python and Swift and we basically learn as we write. This is definitely a unique experience and I really learn a lot along the way.

Accomplishments that we're proud of

For this project, the thing that we are most proud of is that two guys with zero background in Python can develop a drowsiness detector that works so accurately. Moreover, we added a ton of new features to our project to make sure it supports all the functionalities we planned. We are more proud when the program work with an accuracy none of us imagined.

What we learned

One important lesson we learned along the way is that while planning is important, it is never a bad idea to start building something. We can hardly get anywhere if we simply sit there and try to come out with something great. Instead, new ideas just keep popping in and out when we have a prototype built, then we discover all the possibilities with our project.

We also become more confident and more willing to experience unfamiliar programming languages along the way and we are delighted to learn that so much more can be achieved with a computer language like Python.

What's next for Drive S.A.F.E.

Unfortunately due to the time constraints of this event, we can only build a rough prototype while we have so much planned for our project. First, we aim to develop our app on both Android and IOS so most smartphone users can use our application to protect themselves while driving, We also planned to further refine our drowsiness detector by adding a "nodding detection" as it is also a strong indication if someone is falling asleep according to the CDC. One ambitious plan of ours is to work with mapping apps such as Google Maps or Waze to implement our idea as a form of an add-on to reach more drivers and ensure their safety. The overall goal of this app might not only be limited to preventing fatigue driving but other issues that relate to safe driving

Built With

Share this project:

Updates