Driver monitoring SDK - drowsiness, phone, seatbelt detection
Project description
SafeDrive AI — Driver Drowsiness Detection SDK
Real-time driver drowsiness and distraction detection.
Built on MediaPipe + MobileNetV3 (v0.1.0) with YOLOv8 multi-feature detection coming in v0.2.0.
Install
pip install safedrive-ai
Quick Start
from safedrive import DrowsinessDetector
detector = DrowsinessDetector(pipeline="mediapipe")
@detector.on_drowsy
def handle(event):
print(f"Level {event.level}: {event.message}")
detector.run(camera=0)
Alert Levels
| Level | State | Trigger | Action |
|---|---|---|---|
| 1 | WARNING | Eyes half-open 3s / yawn / head tilt | Soft beep |
| 2 | ALERT | Eyes closed 2s / head nod | Loud beep |
| 3 | CRITICAL | Face gone 2s / eyes closed 4s | Continuous alarm |
Separate alerts (independent of drowsiness level):
- Phone detected → instant distraction alert
- Seatbelt removed → continuous safety alert
- Smoking detected → instant distraction alert
Full API
detector = DrowsinessDetector(
pipeline = "mediapipe", # "yolo" coming in v0.2.0
eye_close_seconds = 2.0,
face_gone_seconds = 2.0,
head_tilt_degrees = 15.0,
detect_phone = True,
detect_seatbelt = True,
detect_yawn = True,
detect_smoking = True,
show_window = True,
ear_weight = 0.5,
cnn_weight = 0.5,
)
@detector.on_drowsy # DrowsyEvent
@detector.on_distraction # DistractionEvent
@detector.on_safety # SafetyEvent
@detector.on_frame # called every frame with annotated frame + FrameStats
detector.run(camera=0)
detector.stop()
detector.reset_alert() # manual reset after CRITICAL
Roadmap
| Version | Features |
|---|---|
| v0.1.0 | MediaPipe + MobileNetV3 drowsiness detection ✅ |
| v0.2.0 | YOLOv8 pipeline + full multi-feature detection |
| v1.0.0 | Ensemble mode + benchmark tool + full docs |
Pipeline Comparison
| Feature | MediaPipe (v0.1.0) | YOLO (v0.2.0) |
|---|---|---|
| Eyes open/closed | ✅ | ✅ |
| Yawn detection | ❌ | ✅ |
| Phone detection | ❌ | ✅ |
| Seatbelt | ❌ | ✅ |
| Smoking | ❌ | ✅ |
| Head pose | ✅ (both use MediaPipe landmarks) | ✅ |
| Speed | ~28 FPS | ~24 FPS |
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
safedrive_ai-0.2.0.tar.gz
(17.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file safedrive_ai-0.2.0.tar.gz.
File metadata
- Download URL: safedrive_ai-0.2.0.tar.gz
- Upload date:
- Size: 17.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60213b3196f556c56e7d64a41b8c47d40b5ce41c4231593850368d173105e6f5
|
|
| MD5 |
5c82798debc9f5163b31750e1c6b66b9
|
|
| BLAKE2b-256 |
d583fbc4e103675b4603aae537938d7133dc7eb550bb4fb37a7eb25f5129fa9d
|
File details
Details for the file safedrive_ai-0.2.0-py3-none-any.whl.
File metadata
- Download URL: safedrive_ai-0.2.0-py3-none-any.whl
- Upload date:
- Size: 20.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
659a6cf1e752ceccd754bef0b94f43acde653b40fbcf35310820fea6bd97f58a
|
|
| MD5 |
095ddd255feb27b41d1cd34f5d5599f4
|
|
| BLAKE2b-256 |
24696952852f870fe45413746826ce5d41958ffd747c1a84ca13d48edf5824d6
|