This repository contains a Python script for detecting drowsiness using computer vision and facial landmarks. The system monitors the eyes' aspect ratio to identify signs of drowsiness and issues alerts when necessary.
- Python 3.x
- OpenCV
- imutils
- dlib
- pygame
-
Install the required packages using:
pip install opencv-python imutils dlib pygame
-
Download the pre-trained shape predictor model from here and place it in the "models" folder.
-
Run the script by executing the following command in the terminal:
python drowsiness_detection.py
-
The webcam will activate, and the system will start monitoring your eyes.
-
If drowsiness is detected, an alert message will be displayed on the video feed, and an alarm will be triggered.
-
To exit the application, press 'q'.
- Adjust the
thresh
variable to set the threshold for drowsiness detection. - Modify the
frame_check
variable to determine the number of consecutive frames for triggering an alert.
- The facial landmark detection is performed using the dlib library.
- The
FACIAL_LANDMARKS_68_IDXS
indices are used from the imutils library.
Feel free to contribute, report issues, or suggest improvements!