🚗 Drowsiness Detector Using Python with SMS Alert
A real-time drowsiness detection system designed to enhance driver safety. This project uses Python, OpenCV, and Dlib to detect drowsiness, providing both an audio alert and an SMS notification for prompt action.
📝 Features
- Real-Time Detection: Monitors the driver’s face and eye movements via a webcam.
- Eye Aspect Ratio (EAR) Calculation: Detects drowsiness by analyzing eye closure patterns.
- Audio Alerts: Plays a warning sound when drowsiness is detected.
- SMS Notifications: Sends an SMS alert to a predefined contact using the Twilio API.
- Facial Landmark Detection: Utilizes Haar cascades and Dlib’s 68-point facial landmark predictor for precise detection.
📋 Requirements
Ensure you have the following installed:
Dlib Shape Predictor Model:
⚙️ Setup and Installation
Clone the repository:
git clone https://github.com/your-username/Drowsiness-detector-using-python-with-sms-alert.git
cd Drowsiness-detector-using-python-with-sms-alert
Install dependencies:
pip install -r requirements.txt
Configure Twilio credentials:
Create a file named key.py in the project directory.
Add the following:
account_sid = "your_account_sid"
auth_token = "your_auth_token"
twilio_number = "your_twilio_phone_number"
target_number = "target_phone_number"
Ensure the audio alert file (alert.wav) is in the project directory.
🚀 Usage
Run the script:
python drowsiness_detection.py
The webcam will activate, and the system will start monitoring for drowsiness.
If drowsiness is detected:
An alert sound will play.
An SMS will be sent to the predefined number.
Press q to exit the application.
🛠️ How It Works
Eye Aspect Ratio (EAR):
EAR is calculated using the distances between specific eye landmarks.
If EAR falls below a set threshold for consecutive frames, the system detects drowsiness.