videoController
index
/home/bedrock/Desktop/project/AlertWatch/Production/detector/util/videoController.py

Video Saving Utilities for Blink Detection and Drowsiness Monitoring
 
This module provides functions for saving video frames to a file, ensuring directory existence,
and handling video saves.
 
Functions:
    - save_video_sync: Saves a video synchronously from a buffer of frames.
    - save_video: Asynchronously saves a video using an executor.
 
Dependencies:
    - cv2: For OpenCV video handling.
    - asyncio: For asynchronous tasks.
 
Usage:
    Use these functions to handle video saving during drowsiness detection in real-time applications.
 
Author:
    Lior Jigalo
 
License:
    MIT

 
Modules
       
asyncio
cv2

 
Functions
       
async save_video(buffer, fps, output_path='output_blink_detected.avi') -> None
Saves video frames from a buffer asynchronously to a file.
 
Args:
    buffer (deque): A buffer of video frames (each frame is a NumPy array).
    fps (float): Frames per second for the saved video.
    output_path (str): Path to save the video file (default: 'output_blink_detected.avi').
 
Returns:
    None
 
Side Effects:
    - Creates a video file at the specified output path asynchronously.
save_video_sync(buffer, fps, output_path='output_blink_detected.avi') -> None
Saves video frames from a buffer synchronously to a file.
 
Args:
    buffer (deque): A buffer of video frames (each frame is a NumPy array).
    fps (float): Frames per second for the saved video.
    output_path (str): Path to save the video file (default: 'output_blink_detected.avi').
 
Returns:
    None
 
Side Effects:
    - Creates a video file at the specified output path.
 
Example:
    >>> save_video_sync(buffer, 30, "output.avi")