Docs /Templates/ sinapsis-data-readers

VideoReaderCV2

sinapsis-data-readerscommunityreadersvideoopencvffmpeg

Python template · sinapsis_data_readers.templates.video_readers.video_reader_cv2

Overview

This template provides functionality to read video files using the OpenCV library. It supports reading video frames in specified color spaces and manages video capture resources appropriately.

Capabilities

Capabilities: not set

Installation

Install the published package using pip or uv.

Terminalbash
pip install sinapsis-data-readers==1.0.0
uv pip install sinapsis-data-readers==1.0.0
uv add sinapsis-data-readers==1.0.0

Configuration

Effective fields from the inspector schema, including nested Pydantic model fields.

device

Device to be used for loading the video. Default is "cpu".

typing.Literal['cpu', 'gpu']
Optional
Default: "cpu"
metadata
sinapsis_core.template_base.base_models.TemplateMetadata | None
Optional
Default: null
root_dir
str | None
Optional
Default: null
batch_size

Number of frames in the batch. Default is 1.

int
Optional
Default: 1
loop_forever

Whether to loop the video indefinitely. Default is False.

bool
Optional
Default: false
video_source

Source of the video. Default is a UUID string.

int | str | None
Optional
Default: "836c104a-f9c8-4ee5-865c-e96f413a0b21"
video_file_pathRequired

Path or list of paths to the video(s).

str | list[str]
Required
Default: null

Configuration example

Example from the Python docstring:

yaml
agent:
      name: my_test_agent
    templates:
    - template_name: InputTemplate
      class_name: InputTemplate
      attributes: {}
    - template_name: VideoReaderCV2
      class_name: VideoReaderCV2
      template_input: InputTemplate
      attributes:
        video_file_path: '/path/to/video/file'
        batch_size: 1
        video_source: 4d2a355f-cda4-4742-9042-8e6ee842d1cf
        device: cpu
        loop_forever: false
Show schema-based configuration skeleton
yaml
templates:
  - template_name: "VideoReaderCV2"
    class_name: "VideoReaderCV2"
    attributes:
      device: "cpu"
      root_dir: null
      batch_size: 1
      loop_forever: false
      video_source: "836c104a-f9c8-4ee5-865c-e96f413a0b21"
      video_file_path: "<required>"

Inheritance

Immediate parent: sinapsis_data_readers.templates.video_readers.base_video_reader.BaseVideoReader

Environment variables

Environment definitions belong to their canonical Python modules.

No directly related environment variables listed.