The Alert Mechanism

The goal of the alert mechanism is simple: Wake the user up immediately. Because humans can ignore a single type of stimulus (like a small beep), the system uses a “multi-modal” approach, hitting multiple senses simultaneously.

🚨 Alert Trigger Logic

The alert system doesn’t just fire randomly; it follows a strict logical flow to ensure it is effective but not annoying.

Logic Flowchart

graph TD
    Start[Detection Engine Signals Drowsy] --> Cooldown{Cooldown Elapsed?}
    Cooldown -->|No| Stop[Ignore Alert]
    Cooldown -->|Yes| Trigger[Activate Multi-Modal Alert]
    
    Trigger --> Visual[Visual Alert: Red Overlay]
    Trigger --> Audio[Audio Alert: System Sounds]
    Trigger --> System[OS Alert: Desktop Notification]
    
    Visual --> Reset[Wait for Eyes to Open]
    Audio --> Reset
    System --> Reset
    
    Reset --> Ratio{Ratio < 30%?}
    Ratio -->|No| Trigger
    Ratio -->|Yes| Clear[Clear Alert State]
    Clear --> Stop

🔊 Detailed Modality Breakdown

1. Visual Alert (The “Sighting”)

Using OpenCV, the system draws bright red text directly onto the video stream.

  • Message: “⚠️ DROWSINESS DETECTED! WAKE UP!”
  • Purpose: Immediate visual feedback for the user looking at the screen.

2. Auditory Alert (The “Sound”)

The system uses the Windows winsound library to create a jarring noise.

  • The Sound: A combination of the SystemHand alias (a critical error sound) followed by three high-frequency beeps.
  • Purpose: Auditory alarms are harder to ignore than visual ones and can wake a user from a light sleep.

3. OS Notification (The “Ping”)

Using the plyer library, the system sends a native Windows notification.

  • Message: “User appears drowsy!”
  • Purpose: This ensures that even if the application window is minimized or in the background, the user receives a system-level warning.

⏳ Managing the “Alert State”

The system tracks whether an alert is currently active.

  1. Entering Alert State: Triggered when thresholds are hit.
  2. Sustaining Alert State: The system continues to warn the user as long as the eyes remain mostly closed.
  3. Exiting Alert State: The alert only clears when the closed_ratio drops below . This ensures the user is fully awake before the system goes back to “Silent” mode.

Last Updated: 2026-05-03