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.0.tar.gz (12.7 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.0-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: safedrive_ai-0.1.0.tar.gz
  • Upload date:
  • Size: 12.7 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.0.tar.gz
Algorithm Hash digest
SHA256 73acdf795d3b4bb398242a20e82652fddcadafebfb3332ab3e980c0033d7be40
MD5 0fbc030bd981b47ed145e425ad87790a
BLAKE2b-256 9afab8677485a3ce35e94939a44a32773f3dcb4b93761c16924dca7c1ed687da

See more details on using hashes here.

File details

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

File metadata

  • Download URL: safedrive_ai-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.9 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c178e3b5ae202f0e7e2646ec2cdbb1b45adc2d5b14fad6a0937c20ca6a5509f6
MD5 f0929b17c6781c9ae1ea6c587851419f
BLAKE2b-256 f876adb157ced812bf97d131c72ab71eefc0928ba515a6aabba339cc34220fa1

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