Real-time distracted driving detection using on-device computer vision. Privacy-first: all processing is local, no cloud, no video upload.
Working directory: All commands below must be run from the
Attentia-Drive-Software/directory, not the parent repo root.
pip install -r requirements.txtmacOS — phone detection (optional): Phone detection requires TensorFlow (~500 MB). If you want it enabled, install the macOS requirements instead:
pip install -r requirements-macos.txtWithout this, phone detection is disabled with a warning log on startup and all other features work normally.
python src/main.pypython src/main.py --source path/to/video.mp4python src/main.py --no-displaypytest tests/ FrameSource (webcam/video)
|
v
+-----+------+----------+
| | |
Classifier ObjectDet FaceDet
(P(dist)) (phone, (MediaPipe
cup, etc) landmarks)
| | |
v v v
EMA N-of-M Drowsiness
Smoother Confirmer (PERCLOS,
| | blinks,
v v yawns)
Hysteresis +-----+------+
State |
Machine v
| DistractionReasoner
+-----> (fuse signals, triggers)
|
v
AlertManager
(sustained check, cooldown)
|
+------+------+
| | |
v v v
Display Audio Telemetry
(OpenCV) (beep) (CSV log)
All parameters are in config.yaml. No code changes needed to tune behavior.
| Section | Description |
|---|---|
frame_source |
Webcam index, video path, resolution, target FPS |
classifier |
Model path, input size, confidence threshold |
object_detector |
Model path, target classes, frame skip |
temporal_smoothing |
EMA alpha (responsiveness vs. noise) |
hysteresis |
Enter/leave thresholds for state transitions |
object_confirmation |
N-of-M frames for object presence confirmation |
alert_manager |
Sustained frames, ratio, cooldown between alerts |
display |
Toggle overlays: bboxes, EMA plot, FPS, state |
telemetry |
Log file path and logging interval |
face_detector |
MediaPipe thresholds: yaw, pitch, EAR |
drowsiness |
PERCLOS window, EAR/MAR thresholds, yawn detection |
speed_monitor |
Enable/disable, speed threshold (Phase 4 stub) |
Models are not included. Place files in the models/ directory:
models/classifier.tflite— Binary distraction classifiermodels/efficientdet_lite0.tflite— EfficientDet-Lite0 object detectormodels/face_landmarker.task— MediaPipe FaceLandmarker (download)
The system runs without models (all detectors return neutral results).
pytest tests/ -v101 tests run without a camera, model files, or display. They test the logic pipeline using synthetic data.
| Phase | Status | Features |
|---|---|---|
| Phase 1 | Complete | Classifier, EMA smoothing, hysteresis state machine |
| Phase 2 | Complete | Object detection, N-of-M confirmation, signal fusion |
| Phase 3 | Complete | MediaPipe face mesh, gaze tracking, drowsiness (PERCLOS) |
| Phase 4 | Stubbed | GPS/OBD-II speed gating, graduated severity levels |
| Phase 5 | Planned | Audio alerts, hardware integration, field testing |