Skip to content

Commit 41dc64d

Browse files
committed
first commit
1 parent 6a52da4 commit 41dc64d

File tree

2 files changed

+114
-1
lines changed

2 files changed

+114
-1
lines changed

README.md

Lines changed: 114 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,114 @@
1-
# DrowsiGuard
1+
# DrowsiGaurd (Drowsiness Detection System)
2+
3+
This project implements a **Drowsiness Detection System** using **Computer Vision** and **Deep Learning** techniques to monitor and detect signs of drowsiness in drivers. The system tracks the driver's eye state and gaze direction using the webcam, and it raises an alert if drowsiness is detected, ensuring safer driving conditions.
4+
5+
## Features
6+
7+
- **Real-time Drowsiness Detection:** Tracks the eye state to detect when the driver is drowsy or blinking excessively.
8+
- **Gaze Direction Tracking:** Monitors the direction of the gaze to determine if the driver is distracted.
9+
- **Head Pose Estimation:** Analyzes the orientation of the driver's head to detect abnormal head movements or drowsiness.
10+
- **Alert System:** Plays an alarm sound when drowsiness or distraction is detected.
11+
- **Face and Eye Detection:** Utilizes Haar cascades for detecting faces and eyes.
12+
13+
## Prerequisites
14+
15+
Before you begin, ensure that you have met the following requirements:
16+
- Python 3.x (preferably 3.7 or higher)
17+
- Webcam for real-time monitoring
18+
- The following dependencies, listed in `requirements.txt` file
19+
20+
## Setup and Installation
21+
22+
### 1. Create a Virtual Environment
23+
It is recommended to use a virtual environment for dependency management. You can create one using the following command:
24+
25+
```bash
26+
python -m venv drowsiness_env
27+
```
28+
29+
### 2. Activate the Virtual Environment
30+
For Windows:
31+
```bash
32+
drowsiness_env\Scripts\activate
33+
```
34+
35+
For macOS/Linux:
36+
```bash
37+
source drowsiness_env/bin/activate
38+
```
39+
40+
### 3. Install Dependencies
41+
Install the required dependencies from the requirements.txt file:
42+
```bash
43+
pip install -r requirements.txt
44+
```
45+
46+
Required libraries include:
47+
```text
48+
opencv-python
49+
mediapipe
50+
numpy
51+
keras
52+
pygame
53+
```
54+
55+
### 4. Model and Haar Cascade Files
56+
Ensure the following files are available in the project directory:
57+
58+
Pre-trained model for eye state classification:
59+
- `cnnfinal.h5`
60+
61+
Haar cascade files for face and eye detection:
62+
- `haarcascade_frontalface_alt.xml`
63+
- `haarcascade_lefteye_2splits.xml`
64+
- `haarcascade_righteye_2splits.xml`
65+
66+
These files can be downloaded from the official OpenCV repository or extracted from your local OpenCV installation.
67+
68+
### 5. Alarm Sound
69+
Place an `alarm.wav` file in the project directory. This sound will be played when the system detects drowsiness or distraction.
70+
71+
## Usage
72+
73+
### 1. Running the Script
74+
To start the drowsiness detection system, run:
75+
```bash
76+
python drowsgaurd.py
77+
```
78+
This will open the webcam feed and start tracking the driver's eye state, gaze direction, and head pose in real-time.
79+
80+
### 2. How It Works
81+
- **Eye State Detection**: The system uses a Convolutional Neural Network (CNN) to classify whether the driver's eyes are open or closed.
82+
- **Face and Eye Detection**: Haar cascades are used to detect the driver's face and eyes. The system tracks the eye region to monitor blinking and drowsiness.
83+
- **Gaze Direction Tracking**: Using MediaPipe, the system estimates the gaze direction to detect whether the driver is distracted or looking away from the road.
84+
- **Head Pose Estimation**: The system tracks the head's orientation to determine if the driver is nodding or tilting their head abnormally.
85+
- **Alert System**: If drowsiness is detected (closed eyes for a certain duration or excessive blinking), an alarm sound is played.
86+
87+
### 3. Exiting the Program
88+
To exit the program, press `q` in the terminal or stop the script execution.
89+
90+
91+
92+
## Troubleshooting
93+
94+
- **Webcam not detected**: Ensure that your webcam is properly connected and accessible by other applications. Try restarting your machine if the issue persists.
95+
- **Model loading errors**: If you get an error related to loading the model (`cnnfinal.h5`), make sure the file is placed in the correct directory and the path is specified correctly in the script.
96+
97+
## Contributing
98+
99+
We welcome contributions to this project! If you'd like to contribute, please follow these steps:
100+
101+
1. Fork the repository.
102+
2. Create a new branch for your changes.
103+
3. Commit your changes.
104+
4. Push your changes and create a pull request.
105+
106+
## License
107+
108+
This project is licensed under the MIT License - see the LICENSE file for details.
109+
110+
## Acknowledgments
111+
112+
- **OpenCV**: For providing the face and eye detection algorithms.
113+
- **MediaPipe**: For real-time gaze and head pose tracking.
114+
- **Keras**: For providing the deep learning framework used to train the eye state classification model.

__pycache__/test.cpython-312.pyc

6 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)