Table of Contents

Class MotionDetectionBlock

Namespace
VisioForge.Core.MediaBlocks.VideoProcessing
Assembly
VisioForge.Core.dll

Motion detection block using frame differencing. No OpenCV dependency required. Compares consecutive video frames to detect motion and fires events with the motion level and a grid matrix of per-cell motion intensity.

public class MotionDetectionBlock : MediaBlock, IMediaBlock, IDisposable, IMediaBlockInternals

Inheritance

Implements

Inherited Members

Extension Methods

Constructors

MotionDetectionBlock(MotionDetectionBlockSettings)

Initializes a new instance of the VisioForge.Core.MediaBlocks.VideoProcessing.MotionDetectionBlock class.

public MotionDetectionBlock(MotionDetectionBlockSettings settings = null)

Parameters

settings MotionDetectionBlockSettings

Motion detection settings. If null, defaults are used.

Properties

Input

Gets the primary input pad for this media block.

public override MediaBlockPad Input { get; }

Property Value

MediaBlockPad

Inputs

Gets the collection of input pads for this media block.

public override MediaBlockPad[] Inputs { get; }

Property Value

MediaBlockPad[]

Output

Gets the primary output pad for this media block.

public override MediaBlockPad Output { get; }

Property Value

MediaBlockPad

Outputs

Gets the collection of output pads for this media block.

public override MediaBlockPad[] Outputs { get; }

Property Value

MediaBlockPad[]

Settings

Gets or sets the settings.

public MotionDetectionBlockSettings Settings { get; set; }

Property Value

MotionDetectionBlockSettings

Type

Gets or sets the functional type of this media block (source, sink, effect, encoder, etc.). This property must be overridden in derived classes to specify the block's role in the pipeline.

public override MediaBlockType Type { get; }

Property Value

MediaBlockType

Exceptions

NotImplementedException

Thrown when the derived class has not implemented this property.

NotImplementedException

Thrown when the derived class has not implemented the setter.

Methods

Build()

Builds and initializes this media block, creating any necessary GStreamer elements and configuring them. This method must be overridden in derived classes to implement block-specific initialization logic.

public override bool Build()

Returns

bool

true if the block was successfully built; otherwise, false.

CleanUp()

Releases all resources used by this block.

public void CleanUp()

Dispose(bool)

Releases unmanaged and - optionally - managed resources. Override this method in derived classes to implement block-specific cleanup logic.

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 element wrapper. Returns null as this block manages elements directly.

public BaseElement GetCore()

Returns

BaseElement

GetElement()

Gets the primary GStreamer element (capsfilter).

public Element GetElement()

Returns

Element

IsAvailable()

Determines whether this block is available on the current system. Requires videoconvert and capsfilter GStreamer elements.

public static bool IsAvailable()

Returns

bool

IMediaBlockInternals.SetContext(MediaBlocksPipeline)

Associates this MediaBlock with a pipeline and initializes its internal context. This method is called automatically when the block is added to a pipeline, providing access to shared resources and pipeline-wide configuration.

void IMediaBlockInternals.SetContext(MediaBlocksPipeline pipeline)

Parameters

pipeline MediaBlocksPipeline

The MediaBlocksPipeline instance that will manage this block.

OnMotionDetected

Occurs when motion is detected or measured on a video frame. The VisioForge.Core.Types.Events.MotionDetectionEventArgs.Level indicates the motion intensity (0 = no motion, higher = more motion).

public event EventHandler<MotionDetectionEventArgs> OnMotionDetected

Event Type

EventHandler<MotionDetectionEventArgs>