Table of Contents

Class OnnxInferenceBlock

Namespace
VisioForge.Core.MediaBlocks.AI
Assembly
VisioForge.Core.ONNX.dll

A generic ONNX inference media block. Implements the VisioForge.Core.MediaBlocks.MediaBlock. Implements the VisioForge.Core.MediaBlocks.IMediaBlockInternals.

public class OnnxInferenceBlock : MediaBlock, IMediaBlock, IDisposable, IMediaBlockInternals

Inheritance

MediaBlock

Implements

IMediaBlock
IMediaBlockInternals

Inherited Members

MediaBlock._isBuilt
MediaBlock._pipeline
MediaBlock._pipelineCtx
MediaBlock.GetPipelineContext()
MediaBlock.SetPipelineContext(BlockPipelineContext)
MediaBlock.SetPipeline(MediaBlocksPipeline)
MediaBlock.Context
MediaBlock.Name
MediaBlock.IsBuilt
MediaBlock.Owner
MediaBlock.Type
MediaBlock.ID
MediaBlock.Input
MediaBlock.Inputs
MediaBlock.Output
MediaBlock.Outputs
MediaBlock.HasInputs
MediaBlock.HasOutputs
MediaBlock.Build()
MediaBlock.CreateElements()
MediaBlock.AddElementsToPipeline()
MediaBlock.RemoveElementsFromPipeline()
MediaBlock.DeepCopy(string)
MediaBlock.Reset()
MediaBlock.ToYAMLBlock()
MediaBlock.ClearPads()
MediaBlock.Dispose(bool)
MediaBlock.Dispose()

Remarks

Taps RGBA frames from the video stream via an internal sample grabber, runs the configured ONNX model on each processed frame, and raises VisioForge.Core.MediaBlocks.AI.OnnxInferenceBlock.OnInference with the raw model outputs. The frame passes through unmodified (the block does not draw). Inference runs synchronously on the pipeline's streaming thread, so a slow model throttles the pipeline; use VisioForge.Core.Types.X.AI.OnnxInferenceSettings.FramesToSkip to reduce the inference rate.

Constructors

OnnxInferenceBlock(OnnxInferenceSettings)

Initializes a new instance of the VisioForge.Core.MediaBlocks.AI.OnnxInferenceBlock class.

public OnnxInferenceBlock(OnnxInferenceSettings settings)

Parameters

settings OnnxInferenceSettings

The inference settings. Must specify a valid model path.

Exceptions

ArgumentNullException

Thrown when settings is null.

Properties

ActiveProvider

Gets the execution provider that the inference session actually engaged. Valid after the block has been built; reports VisioForge.Core.Types.X.AI.OnnxExecutionProvider.CPU otherwise.

public OnnxExecutionProvider ActiveProvider { get; }

Property Value

OnnxExecutionProvider

Input

Gets the primary input pad.

public override MediaBlockPad Input { get; }

Property Value

MediaBlockPad

Inputs

Gets the array of all input pads.

public override MediaBlockPad[] Inputs { get; }

Property Value

MediaBlockPad[]

Output

Gets the primary output pad.

public override MediaBlockPad Output { get; }

Property Value

MediaBlockPad

Outputs

Gets the array of all output pads.

public override MediaBlockPad[] Outputs { get; }

Property Value

MediaBlockPad[]

Type

Gets the type of the media block.

public override MediaBlockType Type { get; }

Property Value

MediaBlockType

Methods

Build()

Constructs the internal GStreamer elements and pads for this block.

public override bool Build()

Returns

bool

true if successful, false otherwise.

CleanUp()

Cleans up internal resources, specifically the GStreamer element.

public void CleanUp()

Dispose(bool)

Releases unmanaged and - optionally - managed resources.

protected override void Dispose(bool disposing)

Parameters

disposing bool

true to release both managed and unmanaged resources; false to release only unmanaged resources.

GetCore()

Gets the core GStreamer element wrapped by this block.

public BaseElement GetCore()

Returns

BaseElement

The VisioForge.Core.GStreamer.Base.BaseElement wrapper, or null if not built yet.

GetElement()

Gets the GStreamer element instance.

public Element GetElement()

Returns

Element

The Gst.Element, or null if not built yet.

IMediaBlockInternals.SetContext(MediaBlocksPipeline)

Sets the pipeline context for this block.

void IMediaBlockInternals.SetContext(MediaBlocksPipeline pipeline)

Parameters

pipeline MediaBlocksPipeline

The pipeline.

OnInference

Event raised after the ONNX model has been run on a video frame, carrying the raw outputs.

public event EventHandler<OnnxInferenceEventArgs> OnInference

Event Type

EventHandler<OnnxInferenceEventArgs>

See Also

MediaBlock
IMediaBlockInternals