{"id":28762276,"url":"https://github.com/sametgundz/drivesafe","last_synced_at":"2026-05-09T06:35:42.174Z","repository":{"id":294309171,"uuid":"977572551","full_name":"SametGundz/DriveSafe","owner":"SametGundz","description":"Real-time driver drowsiness and distraction detection system. EU regulation C(2023)4523 compliant gaze zone detection.","archived":false,"fork":false,"pushed_at":"2025-05-24T22:56:31.000Z","size":10518,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"development","last_synced_at":"2025-06-17T08:07:40.101Z","etag":null,"topics":["automotive","computer-vision","driver-drowsiness-detection","eth-xgaze","eye-aspect-ratio","fatigue-detection","gaze-tracking","head-pose-estimation","mediapipe","opencv","perclos","pyqt6","python","real-time-detection","safety-systems"],"latest_commit_sha":null,"homepage":"https://eur-lex.europa.eu/legal-content/EN/TXT/HTML/?uri=PI_COM:C(2023)4523","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SametGundz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-04T14:13:47.000Z","updated_at":"2025-05-24T22:56:34.000Z","dependencies_parsed_at":"2025-05-25T00:32:45.046Z","dependency_job_id":null,"html_url":"https://github.com/SametGundz/DriveSafe","commit_stats":null,"previous_names":["sametgundz/driver-drowsiness-detection","sametgundz/drivesafe"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/SametGundz/DriveSafe","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SametGundz%2FDriveSafe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SametGundz%2FDriveSafe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SametGundz%2FDriveSafe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SametGundz%2FDriveSafe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SametGundz","download_url":"https://codeload.github.com/SametGundz/DriveSafe/tar.gz/refs/heads/development","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SametGundz%2FDriveSafe/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260318697,"owners_count":22991120,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automotive","computer-vision","driver-drowsiness-detection","eth-xgaze","eye-aspect-ratio","fatigue-detection","gaze-tracking","head-pose-estimation","mediapipe","opencv","perclos","pyqt6","python","real-time-detection","safety-systems"],"created_at":"2025-06-17T08:07:40.059Z","updated_at":"2026-05-09T06:35:42.157Z","avatar_url":"https://github.com/SametGundz.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Real Time Driver Drowsiness and Distraction Detection System\n\n[![Python](https://img.shields.io/badge/Python-3.8+-blue.svg)](https://python.org)\n[![PyQt6](https://img.shields.io/badge/PyQt6-GUI-green.svg)](https://riverbankcomputing.com/software/pyqt/)\n[![MediaPipe](https://img.shields.io/badge/MediaPipe-Face%20Detection-orange.svg)](https://mediapipe.dev/)\n[![License](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)\n\n\n![GUI](src/images/gui.png)\n![Gaze Zones](src/images/gaze_zones.png)\n\n\n---\n\n## Installation\n\n### 1. Installing Required Packages\n\n```bash\n# Clone the repository\ngit clone https://github.com/username/driver-drowsiness.git\ncd driver-drowsiness\n\n# Create a virtual environment (recommended)\npython -m venv venv\n\n# Activate the virtual environment\n# Windows:\nvenv\\Scripts\\activate\n# macOS/Linux:\nsource venv/bin/activate\n\n# Install required packages\npip install -r requirements.txt\n```\n\n### 2. Downloading the ETH-XGaze Model\n\nThe ETH-XGaze model is not included in the repository due to its large size. Follow these steps:\n\n#### **Option A: Official Model (Recommended)**\n1. Visit the [ETH-XGaze official page](https://ait.ethz.ch/projects/2020/ETH-XGaze/)\n2. Download the model file (`epoch_24_ckpt.pth.tar`)\n3. Place it in the `models/` directory:\n   ```bash\n   mkdir -p models\n   # Copy the downloaded file to the models directory\n   cp /download/path/epoch_24_ckpt.pth.tar models/eth_xgaze_model.pth\n   ```\n\n#### **Option B: ONNX Format (Fast Inference)**\n```bash\n# Run the model conversion script\npython scripts/convert_ethxgaze_model.py models/eth_xgaze_model.pth models/eth_xgaze_model.onnx --export_onnx\n```\n\n---\n\n## Usage\n\n### 1. Basic Usage\n\n```bash\n# Start the main application\npython run.py\n```\n\n**Usage Steps:**\n1. Make sure your camera is connected\n2. Click the **\"Start\"** button\n3. Keep your face in the camera's field of view\n4. Monitor real-time metrics\n5. End the analysis with **\"Stop\"**\n\n\n### 2. Video Analysis\n\n```bash\n# Video file analysis\npython examples/analyze_video.py --input video.mp4 --output results/\n\n# Batch video analysis\npython scripts/batch_analyze.py --input_dir videos/ --output_dir results/\n```\n\nYou can use the feature either command line or application.\n\n![Video Upload](src/images/video_upload.png)\n### 3. Gaze Zone Detection\n\n```bash\n# Gaze zone test\npython tests/test_gaze_zone_detector.py --camera 0 --show_zones\n\n# Gaze zone calibration\npython scripts/calibrate_gaze_zones.py\n```\n\nEU regulation C(2023)4523 compliant zones:\n\n| Zone ID | Zone Name | Area | Criticality |\n|---------|-----------|------|-----------|\n| 0 | Road Center | Area 2 | 🔴 Critical |\n| 1 | Driving Instruments | Area 2 | 🟡 Driving Related |\n| 2 | Infotainment | Area 1 | 🟠 Non-Driving |\n| 3 | Left Side | Area 2 | 🟡 Driving Related |\n| 4 | Right Side | Area 2 | 🟡 Driving Related |\n| 5 | Rear Mirror | Area 2 | 🔴 Critical |\n\n![Classification Performance Metrics](src/images/performance_radar.png)\n\n#### Classification Performance Metrics\n- Overall Accuracy: 93.23%\n- Balanced Accuracy: 83.70%\n- Macro-averaged Precision: 91.96%\n- Macro-averaged Recall: 83.70%\n- Macro-averaged F1-Score: 85.84%\n\n#### Statistical Reliability Measures\n- Cohen's Kappa: 0.9110 (Almost Perfect)\n- Matthews Correlation Coefficient: 0.8549\n- Krippendorff's Alpha: 0.9110\n\n---\n\n## Metrics\n\n### **EAR (Eye Aspect Ratio)**\n- **Formula**: `EAR = (|p2-p6| + |p3-p5|) / (2 * |p1-p4|)`\n- **Threshold Value**: 0.21 (eyes considered closed below this)\n- **Usage**: Instant eye blink and closure detection\n\n### **MAR (Mouth Aspect Ratio)**\n- **Formula**: `MAR = |p14-p18| / |p12-p16|`\n- **Threshold Value**: 0.65 (mouth considered open above this)\n- **Usage**: Yawning detection\n\n### **PERCLOS**\n- **Definition**: Percentage of eye closure over a 60-second period\n- **Warning Threshold**: 15%\n- **Critical Threshold**: 20%\n\n### **KSS (Karolinska Sleepiness Scale)**\n| Score | Status | Description |\n|------|-------|----------|\n| 1-3 | 🟢 Normal | Fully awake state |\n| 4-5 | 🟡 Mild | Mild signs of fatigue |\n| 6-7 | 🟠 Warning | Beginning of attention deficit |\n| 8-9 | 🔴 Critical | Immediate intervention required |\n\n---\n\n## **Scientific References**\n- **ETH-XGaze**: Gaze estimation model ([Paper](https://arxiv.org/abs/2007.15837))\n- **MediaPipe**: Face mesh detection ([Documentation](https://google.github.io/mediapipe/))\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsametgundz%2Fdrivesafe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsametgundz%2Fdrivesafe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsametgundz%2Fdrivesafe/lists"}