A real-time drowsiness detection system using Python, OpenCV, and an Arduino to trigger physical alerts. This project monitors a driver's eyes and activates a buzzer if signs of sleepiness are detected and makes the motor stop.
- Detection (Python): A Python(Opencv script) uses a webcam to capture video. It employs the MediaPipe library to detect facial landmarks and calculates the Eye Aspect Ratio (EAR) to determine if the eyes are closed.
- Logic: If the eyes remain closed for more than 1.5 seconds, the system classifies the driver as "Asleep".
- Alert (Arduino): The Python script sends a signal ('0' for asleep, '1' for awake) via serial communication to an Arduino. The Arduino then activates a buzze to alert the driver and makes the motor stop.
- Arduino Uno
- Webcam
- DC Motor
- 5V Buzzer
- L298N Motor Driver
- 9V Battery
- Breadboard and Jumper Wires
(See Circuit diagram.jpg for connection details)
- **Python **
- Arduino IDE
- Python Libraries:
opencv-pythonmediapipepyserialnumpy
- Hardware Setup: Assemble the circuit according to the
Circuit diagram.jpg. - Arduino: Upload the
Arduino_code_DDDS_.inosketch to your Arduino Uno. - Python:
- Install the required libraries:
pip install opencv-python mediapipe pyserial numpy - In
Main code(DDDS).py, make sure theARDUINO_PORTis set to the correct COM port for your Arduino (e.g.,'COM4'). - Run the script from your terminal:
python "Main code(DDDS).py"
- Install the required libraries: