Skip to main content

Drowsiness detection using facial landmarks or CNN.

Project description

Drowsiness Validator

A Python package for detecting drowsiness using facial landmarks or a Convolutional Neural Network (CNN).

Installation

Install the package using pip:

pip install drowsiness-validator

Usage

Here's a basic example of how to use the package:

from drowsiness_validator import DrowsinessDetector
import cv2

# Initialize the detector (choose 'landmarks' or 'cnn')
detector = DrowsinessDetector(method='landmarks')
# Or: detector = DrowsinessDetector(method='cnn')

# Load an image (replace with your image path or video frame)
image_path = 'path/to/your/image.jpg'
frame = cv2.imread(image_path)

if frame is not None:
    # Detect drowsiness
    is_drowsy, details = detector.detect_drowsiness(frame)

    if is_drowsy:
        print("Drowsiness detected!")
        # You can access more details if needed, e.g., eye aspect ratio for landmarks
        if 'ear' in details:
            print(f"Eye Aspect Ratio (EAR): {details['ear']:.2f}")
    else:
        print("Not drowsy.")
else:
    print(f"Error loading image: {image_path}")

# Example with video stream (using OpenCV)
# cap = cv2.VideoCapture(0) # Use 0 for default webcam
# while True:
#     ret, frame = cap.read()
#     if not ret:
#         break
#
#     is_drowsy, _ = detector.detect_drowsiness(frame)
#
#     status = "Drowsy" if is_drowsy else "Awake"
#     cv2.putText(frame, f"Status: {status}", (10, 30), cv2.FONT_HERSHEY_SIMPLEX, 0.7, (0, 0, 255) if is_drowsy else (0, 255, 0), 2)
#
#     cv2.imshow("Drowsiness Detection", frame)
#
#     if cv2.waitKey(1) & 0xFF == ord('q'):
#         break
#
# cap.release()
# cv2.destroyAllWindows()

Author

Sharjeel Baig

License

This project is licensed under the MIT License.

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

drowsiness_validator-0.1.3.tar.gz (74.4 MB view details)

Uploaded Source

Built Distribution

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

drowsiness_validator-0.1.3-py3-none-any.whl (74.8 MB view details)

Uploaded Python 3

File details

Details for the file drowsiness_validator-0.1.3.tar.gz.

File metadata

  • Download URL: drowsiness_validator-0.1.3.tar.gz
  • Upload date:
  • Size: 74.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.6

File hashes

Hashes for drowsiness_validator-0.1.3.tar.gz
Algorithm Hash digest
SHA256 e34c78d859612e656ddf7b07d11ccffd8abf7d63341f25f25df2322c39b84744
MD5 214f2e91b4a8da87f253facb16cbb705
BLAKE2b-256 1f201b211b90ebee28c82c4e59872c00dd72c9aee0b1f512ea8852ac346e3d4d

See more details on using hashes here.

File details

Details for the file drowsiness_validator-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for drowsiness_validator-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4464796c93e30ab24b1d2bc8d9efb4014a0a98a31019ae37b3a7b68640e5c385
MD5 db13e3a3e218e6824804358825ca9624
BLAKE2b-256 6a8785112ca6b59c618a2c51c948dbc583d725fc9560ec746610769080697fad

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