| faceController | index /home/bedrock/Desktop/project/AlertWatch/Production/detector/util/faceController.py |
Drowsiness Detection and Blink Monitoring Utilities
This module provides utilities for processing face bounding boxes, running landmark inference,
detecting blinks, and identifying signs of drowsiness. It also includes functionality for sending
alerts over WebSocket and saving video when drowsiness is detected.
Constants:
- WS_URL (str): WebSocket URL for sending alerts.
- RECONNECT_INTERVAL (int): Interval in seconds for reconnect attempts to the WebSocket server.
Functions:
- process_bounding_box: Processes a bounding box to fit within frame boundaries.
- run_landmark_inference: Runs inference for facial landmarks and reshapes the output.
- handle_blink_detection: Detects blinks based on Eye Aspect Ratio (EAR) and updates state.
- handle_drowsiness_detection: Detects drowsiness based on EAR and triggers alerts or video saving.
- send_drowsiness_alert: Sends drowsiness alerts as JSON messages over a WebSocket.
Dependencies:
- asyncio: For asynchronous WebSocket communication.
- datetime: For timestamping video files and alerts.
- json: For creating JSON messages.
- threading: For running alert and video saving tasks in separate threads.
- time: For measuring durations and handling debouncing.
- cv2: For OpenCV operations like drawing text on frames.
Usage:
Use the functions to process video frames, monitor blinks, and handle drowsiness alerts in
real-time applications.
Author:
Lior Jigalo
License:
MIT
| Modules | ||||||
| ||||||
| Functions | ||
| ||
| Data | ||
| RECONNECT_INTERVAL = 2 WS_URL = 'ws://192.168.0.63:5000' __annotations__ = {'RECONNECT_INTERVAL': <class 'int'>, 'WS_URL': <class 'str'>} | ||