Source reader classes
The VideoStreamer
class streams video from a source (file or camera) and retrieves frames in real-time, ensuring that the current frame is always processed without delay. Unlike cv2.VideoCapture
, which might introduce a delay while waiting for the next frame in the stream, VideoStreamer
fetches the frame at the current time, making it ideal for real-time processing.
kano.lab.source_reader.VideoStreamer
A class to stream video from a source (file or camera), continuously read frames, and store them in a queue.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source |
str
|
Path to the video source or camera index. |
required |
reconnect |
bool
|
Whether to reconnect to the video source if the connection is lost. Default is True. |
True
|
Source code in kano\lab\source_reader.py
__init__(source, reconnect=True, reconnect_time=2)
Initializes the VideoStreamer class to stream video from the specified source.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source |
str
|
The path to the video source or camera index. |
required |
reconnect |
bool
|
Whether to reconnect to the video source if the connection is lost. |
True
|
reconnect_time |
float
|
Time to play the source after out of frames or connection lost |
2
|
Source code in kano\lab\source_reader.py
get_latest_frame()
Retrieves the latest frame from the queue.
Returns:
Name | Type | Description |
---|---|---|
frame |
ndarray
|
The most recent frame from the video source. |