This project designs and develops a modular Driver Behavior Scoring System that processes driving telemetry data, performs real-time face and eye detection (for drowsiness/distraction) using OpenCV and MediaPipe, and uses machine learning to score driver safety and risk levels. All results are presented in an interactive Streamlit web application.
- Telemetry Data Processing: Load, preprocess, and engineer features from driving data (speed, braking, acceleration).
- Real-time Face & Eye Detection: Utilize MediaPipe for live webcam feed to detect facial landmarks, calculate Eye Aspect Ratio (EAR), and identify signs of drowsiness.
- Machine Learning Models: Employ regression, classification, and clustering models (scikit-learn) to predict driver safety scores and classify risk levels.
- Interactive Streamlit App: A user-friendly web interface displaying live video, real-time scores, drowsiness alerts, and historical trend dashboards.
- Audio Alerts: Implements distinct audio alerts. A continuous high-risk alert sounds specifically when drowsiness (prolonged eye closure) is detected.
- Object-Oriented Design: Core functionality implemented using OOP principles for clarity and extensibility.
- Python 3.x
- Streamlit (interactive web UI)
- OpenCV (cv2) & MediaPipe (facial landmark detection)
- scikit-learn, Pandas, NumPy (ML & data handling)
- Plotly (charts/graphs)
Follow these steps to get the project up and running on your local machine:
-
Clone the Repository: ```bash git clone <repository_url> cd <project_directory> ``` (Replace
<repository_url>and<project_directory>with your actual repository URL and the name of the cloned directory.) -
Create a Virtual Environment (Recommended): ```bash python -m venv venv ```
-
Activate the Virtual Environment:
- Windows: ```bash .\venv\Scripts\activate ```
- macOS/Linux: ```bash source venv/bin/activate ```
-
Install Dependencies: ```bash pip install -r requirements.txt ```
Troubleshooting MediaPipe: If you encounter a
RuntimeErrorrelated to MediaPipe, try reinstalling: ```bash pip uninstall mediapipe opencv-python -y pip install --upgrade mediapipe opencv-python protobuf ``` -
Run the Streamlit Application: ```bash streamlit run app.py ``` This command will open the application in your default web browser.
- Upload Telemetry Data: Use the sidebar to upload a CSV file containing driving telemetry data (e.g.,
data/dataset.csv). - Start Camera: Click "Start Camera" in the sidebar to activate your webcam for real-time face and eye detection.
- Monitor Dashboards: Observe live safety scores, risk classifications, drowsiness alerts, and historical trends on the main dashboard.
For any questions or feedback, feel free to reach out:
- Email: makmodol1173@gmail.com
- GitHub: github.com/makmodol1173