Inspiration

In the United States, roughly 6400 people die annually from drowsy driving crashes. Drowsiness and distraction can cause crashes in seconds, and most vehicles still lack active driver monitoring systems. This is why I built Guardian, to provide higher safety to drivers.

What it does

  • Tracks eyes and yawns: Uses a webcam feed to measure how long your eyes stay shut and how often you yawn.
    • Flags distraction: Keeps track of your head position and warns you if you look away from the road for more than 2 seconds.
    • Plays loud warnings: If it catches you sleeping or getting distracted, it plays an audio alarm.
    • Sends an emergency alert: If you start sleeping and don't respond for 10 straight seconds, it automatically sends a Discord ping tagging @everyone in whatever server the webhook is setup so someone knows to help.
    • Runs in headless mode: Works on low power devices like a Raspberry Pi without needing a monitor attached, which saves a ton of processing power. ## How we built it
  • Language: Python 3.14
  • Computer Vision: OpenCV, MediaPipe
  • Audio & TTS: pyttsx3, ALSA (aplay - Linux) / winsound (Windows)
  • Networking: urllib / requests (Discord Webhooks) ## Challenges we ran into
    • Raspberry Pi audio issues: Getting aplay and audio working on the Pi took way longer than expected. I kept running into missing driver issues, wrong card indexes (hw:0,0), and device errors whenever an alert tried to play.
    • FPS drops breaking the timers: Counting frames to track sleep duration failed as soon as the FPS dropped on the rPi. I had to stop using frame counts and switch to actual time.time() differences so the timers stay accurate.
    • Flickering eye tracking: Mediapipe's eye landmarks would flicker or lose tracking for a fraction of a second. Fast normal flickers kept resetting our sleep counter, so we had to add a buffer to smooth out the flickers. ## Accomplishments that we're proud of
    • Ran it on a Pi: Moved everything off a laptop and got it running smoothly on a Raspberry Pi 5 without lagging.
    • Low latency: Kept frame processing under 30ms while running eye tracking, yawn detection, and head monitoring all at once.
    • Fixed the audio delay: Figured out non-blocking audio and TTS so alert sounds play right away without freezing the camera feed.
    • Emergency alerts work: Built a webhook setup that escalates from local audio alerts to sending a Discord ping. ## What we learned
    • Edge optimization: How to shorten down heavy CV code to have good framerate on low-power hardware like a Raspberry Pi 5.
    • Filtering bad data: How to use buffers and threshold checks to handle noisy eye tracking data instead of relying on raw landmark outputs.
    • Linux audio management: How ALSA, audio card indexing, and subprocesses work when trying to play non-blocking sound in Python. ## What's next for Guardian
    • Lane departure warning: Mount a second forward facing camera and use OpenCV to track lane lines and alert drivers if they start drifting out of the lane without signaling.
    • External car & obstacle detection: Add lightweight object detection models to spot cars braking sharply ahead or pedestrians entering the road.
    • Infrared camera support: Swap the internal camera for an IR camera module so face and eye tracking work cleanly and at night.
    • 3d printed dash mount: Design a custom mount to house the Pi 5, camera modules, and speakers.

Built With

Share this project:

Updates

Submission history