API Reference

MONAIStream Sources

class monaistream.sources.URISource(uri: str, name: str = '')[source]

Creates a source which reads data from a URI. Source may be live (e.g. rtsp://) or playback (e.g. file:///, http://)

Parameters
  • uri – the URI to the data source

  • name – the name to assign to this component

__init__(uri: str, name: str = '') None[source]
Parameters
  • uri – the URI to the data source

  • name – the name to assign to this component

get_gst_element()[source]

Return the raw Gst.Element

Returns

the uridecodebin Gst.Element

get_name()[source]

Get the assigned name of the component

Returns

the name of the component as a str

initialize()[source]

Initialize the uridecodebin GStreamer component.

is_live()[source]

Determine whether the URI source is live.

Returns

True is source is rtsp://, and False otherwise

class monaistream.sources.NVAggregatedSourcesBin(sources: Union[monaistream.interface.StreamSourceComponent, List[monaistream.interface.StreamSourceComponent]], output_width: int, output_height: int, batched_push_timeout: Optional[int] = None, name: str = '')[source]

An aggregating source bin which, when provided with multiple sources, will batch the inputs from all sources provided and send the batched data to downstream components

Parameters
  • sources – One source or a list of sources that are “aggregated” by concatenating the output of all sources in the batch dimension

  • output_width – The width of the batched output

  • output_height – The height of the batched output

  • batched_push_timeout – The timeout in milliseconds to wait for the batch to be formed

  • name – the desired name of the aggregator component

__init__(sources: Union[monaistream.interface.StreamSourceComponent, List[monaistream.interface.StreamSourceComponent]], output_width: int, output_height: int, batched_push_timeout: Optional[int] = None, name: str = '') None[source]
Parameters
  • sources – One source or a list of sources that are “aggregated” by concatenating the output of all sources in the batch dimension

  • output_width – The width of the batched output

  • output_height – The height of the batched output

  • batched_push_timeout – The timeout in milliseconds to wait for the batch to be formed

  • name – the desired name of the aggregator component

get_gst_element()[source]

Return a tuple of GStreamer elements initialized in the components

Returns

a tuple of Gst.Element`s of types `(gst-bin, nvstreammux)

get_name()[source]

Get the name of the component

Returns

the name as a str

get_num_sources()[source]

Return the number sources added to this component

Returns

the number of sources assigned to the aggregated component

initialize()[source]

Initializer method for all provided source components and the nvstreammux component which is used to batch the output data from all provided sources

is_live()[source]

Returns whether any of the aggregated sources is “live” (e.g. capture card, rtsp://, etc.)

Returns

true if any of the sources is live

class monaistream.sources.AJAVideoSource(mode: str, input_mode: str, is_nvmm: bool, output_width: int, output_height: int, name: str = '')[source]

AJA video capture component

Parameters
  • mode – depicts the color format and framerate of input sensor

  • input_mode – whether the capture is via HDMI or SDI

  • is_nvmm – should be True for RDMA capture

  • output_width – the desired output width from the capture card

  • output_height – the desired output heigh from the capture card

  • name – the name to assign to the component

__init__(mode: str, input_mode: str, is_nvmm: bool, output_width: int, output_height: int, name: str = '') None[source]
Parameters
  • mode – depicts the color format and framerate of input sensor

  • input_mode – whether the capture is via HDMI or SDI

  • is_nvmm – should be True for RDMA capture

  • output_width – the desired output width from the capture card

  • output_height – the desired output heigh from the capture card

  • name – the name to assign to the component

get_gst_element()[source]

Return the GStreamer elements wrapped in this component

Returns

get a tuple Gst.Element`s of type `(ajavideosrc, nvstreammux)

get_name()[source]

Return the name of the component

Returns

component anem as str

initialize()[source]

Initialize the GStreamer elements that are part of this component, namely ajavideosrc and nvstreammux

is_live()[source]

Determine if the capture is live

Returns

True

MONAIStream filters

class monaistream.filters.TransformChainComponent(transform_chain: Callable, output_label: str, name: str = '')[source]

The TransformChainComponent allows users to plugin a MONAI transformation pipeline into the MONAI StreamCompose component

Parameters
  • transform_chain – a Callable object such as monai.transforms.compose.Compose

  • input_labels – the label keys we want to assign to the inputs to this component

  • output_labels – the label key to select the output from this component

__init__(transform_chain: Callable, output_label: str, name: str = '') None[source]
Parameters
  • transform_chain – a Callable object such as monai.transforms.compose.Compose

  • input_labels – the label keys we want to assign to the inputs to this component

  • output_labels – the label key to select the output from this component

get_gst_element()[source]

Return the GStreamer element

Returns

the raw queue Gst.Element

get_name()[source]

Get the name assigned to the component

Returns

the name as a str

initialize()[source]

Initializes the GStreamer element wrapped by this component, which is a queue element

probe_callback(pad: Gst.Pad, info: Gst.PadProbeInfo, user_data: object)[source]

A wrapper function for the transform_chain callable set in the constructor. Performs conversion of GStreamer data to a torch.Tensor before the user-specified transform_chain is called; the result of transform_chain is expected to be a torch.Tensor which is converted back to a Gst.Buffer and written into the original input buffer. NOTE: The size of the output must be the same as or smaller than the input buffer.

class monaistream.filters.TransformChainComponentCupy(transform_chain: Callable, output_label: str, name: str = '')[source]

The TransformChainComponentCupy allows users to plugin a Callable into the MONAI Stream pipeline. The user-specified callable must receive a Cupy array or list of Cupy arrays, and return one single Cupy array as the result.

Parameters

transform_chain – a Callable object such as monai.transforms.compose.Compose

__init__(transform_chain: Callable, output_label: str, name: str = '') None[source]
Parameters

transform_chain – a Callable object such as monai.transforms.compose.Compose

get_gst_element()[source]

Return the GStreamer element

Returns

the raw queue Gst.Element

get_name()[source]

Get the name assigned to the component

Returns

the name as a str

initialize()[source]

Initializes the GStreamer element wrapped by this component, which is a queue element

probe_callback(pad: Gst.Pad, info: Gst.PadProbeInfo, user_data: object)[source]

A wrapper function for the transform_chain callable set in the constructor. Performs conversion of GStreamer data (a Gst.Buffer in the GPU) to a Cupy array before the user-specified transform_chain is called; the result of transform_chain is converted back to a Gst.Buffer and written to the original input buffer. NOTE: The size of the output must be the same as or smaller than the input buffer.

class monaistream.filters.NVInferServer(name: str = '', config: Optional[monaistream.filters.infer.InferServerConfiguration] = None, config_path: str = '/tmp')[source]

Triton Inference server component

Constructor for Triton Inference server component

Parameters
  • config – the configuration (InferServerConfiguration) for the Triton Inference Server streaming component (if none is provided a default configuration is used)

  • name – the name of the component

__init__(name: str = '', config: Optional[monaistream.filters.infer.InferServerConfiguration] = None, config_path: str = '/tmp') None[source]

Constructor for Triton Inference server component

Parameters
  • config – the configuration (InferServerConfiguration) for the Triton Inference Server streaming component (if none is provided a default configuration is used)

  • name – the name of the component

static generate_default_config()[source]

Get the default configuration for the Triton Inference server for customization purposes

Returns

the default inference server component of type InferServerConfiguration

get_config() Any[source]

Get the configuration of the component

Returns

the configuration of the Triton Inference server component

get_gst_element()[source]

Get the nvinferserver GStreamer element being wrapped by this component

Returns

the nvinferserver GStreamer element

get_name() Any[source]

Get the name of the component

Returns

the name of the component as str

initialize()[source]

Initialize the nvinferserver GStreamer element and configure based on the provided configuration

set_batch_size(batch_size: int)[source]

Configure the batch size of the inference server

Parameters

batch_size – a positive integer determining the maximum batch size for the inference server

class monaistream.filters.NVVideoConvert(format_description: Optional[monaistream.filters.convert.FilterProperties] = None, name: str = '')[source]

Video converter component for NVIDIA GPU-based video stream

Create an NVVIdeoConvert object based on the FilterProperties

Parameters
  • filter – the filter property for the video converter component

  • name – the name of the component

__init__(format_description: Optional[monaistream.filters.convert.FilterProperties] = None, name: str = '') None[source]

Create an NVVIdeoConvert object based on the FilterProperties

Parameters
  • filter – the filter property for the video converter component

  • name – the name of the component

get_gst_element()[source]

Get the GStreamer elements initialized with this component

Returns

get a tuple of GStreamer elements of types (nvvideoconvert, capsfilter)

get_name()[source]

Get the name of the component

Returns

the name of the component

initialize()[source]

Initialize the nvvideoconvert GStreamer component

MONAIStream Sink

class monaistream.sinks.FakeSink(name: str = '')[source]

Fake sink component used to terminate a MONAI Stream pipeline.

Parameters

name – the name to assign to this component

__init__(name: str = '') None[source]
Parameters

name – the name to assign to this component

get_gst_element()[source]

Return the raw GStreamer fakesink element

Returns

fakesink Gst.Element

get_name()[source]

Get the assigned name of the component

Returns

the name of the component as str

initialize()[source]

Initialize the fakesink GStreamer element wrapped by this component

class monaistream.sinks.NVEglGlesSink(name: str = '', sync: bool = False)[source]

NVIDIA video viewport sink to visualize results of MONAI Stream pipeline.

Parameters
  • syncTrue is the frames should synchronize with the source, and False otherwise

  • name – the name to assign to this component

__init__(name: str = '', sync: bool = False) None[source]
Parameters
  • syncTrue is the frames should synchronize with the source, and False otherwise

  • name – the name to assign to this component

get_gst_element()[source]

Return the raw GStreamer nveglglessink element

Returns

nveglglessink Gst.Element

get_name()[source]

Get the name assigned to this component

Returns

the name of the component as str

initialize()[source]

Initialize the GStreamer nveglglessink element wrapped by this component

MONAI Stream Compose

class monaistream.compose.StreamCompose(components: Sequence[monaistream.interface.StreamComponent])[source]

MONAI Stream pipeline composer is the core function that allows MONAI Stream and MONAI core elements to integrate.

At initialization all components in the pipeline are initilized thought the initialize method, and are then linked by retrieving their underlying GStreamer elements through get_gst_element.

Parameters

components – is a sequence of StreamComponent from which all components in MONAI Stream SDK are inherited

__init__(components: Sequence[monaistream.interface.StreamComponent])[source]

At initialization all components in the pipeline are initilized thought the initialize method, and are then linked by retrieving their underlying GStreamer elements through get_gst_element.

Parameters

components – is a sequence of StreamComponent from which all components in MONAI Stream SDK are inherited