Skip to main content

Real-time driver drowsiness detection SDK

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.1.1.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

safedrive_ai-0.1.1-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

Details for the file safedrive_ai-0.1.1.tar.gz.

File metadata

  • Download URL: safedrive_ai-0.1.1.tar.gz
  • Upload date:
  • Size: 14.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for safedrive_ai-0.1.1.tar.gz
Algorithm Hash digest
SHA256 5fff1ac850be5a35bab5276105d487a1dad609fcf0682e5bb366d4f9fcdc2d5f
MD5 7f9dfe10726019fbc5be2e829352c570
BLAKE2b-256 2891c817b623647c846e702d06bbcfd0cb84857afddf3ac3323fbfa9f5ff08c1

See more details on using hashes here.

File details

Details for the file safedrive_ai-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: safedrive_ai-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 16.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for safedrive_ai-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7ea6bf3b43a566c650f9b5f8b6a87b2d1c96d8d6ec1b251913ff23243db3d28e
MD5 ffa892d1e9a5e2caf48195c410d120e7
BLAKE2b-256 b1c1db4f4d6dcbe3301e1e60afb9a7e15ba67d17962d16decb5607a6066f5ac1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page