Module src.streaming.io.video_reader

Module for reading video files or webcam streams

Classes

class VideoReader (interface: Union[int, str], res: Union[tuple, NoneType] = None)

An instance can be created for either a videofile with interface being path or for a webcam stream with interface being the video interface number.

Contains methods for beginning and ending stream, and a generator of frames

Args

interface
Either path to videofile or webcam interface number
res
Resolution provided a tuple on the form (width, height).

Methods

def begin(self) ‑> NoneType

Starts videocapture and sets caputure resolution equal to the videofile or webcam resolution if no resolution is specified.

def end(self) ‑> NoneType

Safely ends videocapture

def frame_generator(self) ‑> Iterable[Union[numpy.ndarray, NoneType]]

Creates iterable frame generator

Creates a generator for frames that works for both finite (videofile) and infinite (webcam) input frames. A frame is read, if retrieved apply selfie-mirror, and convert it to rgb before yielding it. If it is not retrieved end the generator by yielding None

Returns

Iterable generator for instances of either an image buffer or None.