Sinks¶
Sinks abstract the concept of receiving data to produce new data or perform a specifc action such as publishing or storing it in a database.
Design guidelines for sinks¶
It is recommeded that sinks perform a single specific task and complex actions are achieved by interaction of several sinks specified at configuration time rather than a monolithic approach.
API reference¶
This module contains the Built-in sinks.
- class videoanalytics.pipeline.sinks.ImageWriter(name, context, output_path)¶
Writes the current frame to a image using OpenCV image write.
This component READS the following entries in the global context:
Variable name
Description
IMG_FILENAME
Filename for the output image file. Note: this name is generated by ImageSequenceReader.
INPUT_WIDTH
Input video width in pixels.
INPUT_HEIGHT
Input video height in pixels.
FRAME
Numpy array representing the frame.
- Parameters
name (str) – the component unique name.
context (dict) – The global context.
output_path (str) – path to store images.
- process()¶
This method is called for each active component in the pipeline.
- setup()¶
This method is called after all components from the pipeline are instanced.
- shutdown()¶
This method is called after the process finished.
- class videoanalytics.pipeline.sinks.VariableCSVWriter(name, context, filename, variables_to_write)¶
Stores variables in a CSV.
This component READS the entries matching the variable names specified in configurations, example “VARIABLE_1”, etc.:
Variable name
Description
VARIABLE_1
Variable updated by some component.
VARIABLE_2
Variable updated by some component.
…
…
VARIABLE_N
Variable updated by some component.
- Parameters
name (str) – the component unique name.
context (dict) – The global context.
filename (str) – CSV filename.
variables_to_write (list) – List of variables to write.
- process()¶
This method is called for each active component in the pipeline.
- setup()¶
This method is called after all components from the pipeline are instanced.
- shutdown()¶
This method is called after the process finished.
- class videoanalytics.pipeline.sinks.VideoWriter(name, context, filename, output_format='XVID', fps=None, width=None, height=None)¶
Writes video to a file using OpenCV writer.
This component READS the following entries in the global context:
Variable name
Description
INPUT_FPS
Input video FPS.
INPUT_WIDTH
Input video width in pixels.
INPUT_HEIGHT
Input video height in pixels.
FRAME
Numpy array representing the frame.
- Parameters
name (str) – the component unique name.
context (dict) – The global context.
filename (str) – output video filename.
output_format (str) – output format (default to XVID). Any format supported by OpenCV VideoWriter_fourcc.
- process()¶
This method is called for each active component in the pipeline.
- setup()¶
This method is called after all components from the pipeline are instanced.
- shutdown()¶
This method is called after the process finished.