Table of Contents

Class CVTemplateMatchBlock

Namespace
VisioForge.Core.MediaBlocks.OpenCV
Assembly
VisioForge.Core.dll

OpenCV template matching block for object detection and pattern recognition. This block searches for specific template images within the video stream using various correlation algorithms including normalized cross-correlation, squared difference, and correlation coefficient methods. Essential for automated inspection, object tracking, quality control, and computer vision applications where specific patterns or objects need to be located. Provides configurable matching algorithms, threshold settings, and multiple match detection capabilities. Implements the VisioForge.Core.MediaBlocks.MediaBlock. Implements the VisioForge.Core.MediaBlocks.IMediaBlockInternals. Implements the IDisposable.

public class CVTemplateMatchBlock : MediaBlock, IMediaBlock, IDisposable, IMediaBlockInternals

Inheritance

Implements

Inherited Members

Extension Methods

Constructors

CVTemplateMatchBlock(CVTemplateMatchSettings)

Initializes a new instance of the VisioForge.Core.MediaBlocks.OpenCV.CVTemplateMatchBlock class with the specified template matching settings.

public CVTemplateMatchBlock(CVTemplateMatchSettings settings)

Parameters

settings CVTemplateMatchSettings

The template matching configuration settings containing algorithm parameters.

Properties

Input

Gets the input pad for connecting video sources to be processed.

public override MediaBlockPad Input { get; }

Property Value

MediaBlockPad

Inputs

Gets all input pads for this template matching block.

public override MediaBlockPad[] Inputs { get; }

Property Value

MediaBlockPad[]

Output

Gets the output pad for connecting to downstream processing blocks.

public override MediaBlockPad Output { get; }

Property Value

MediaBlockPad

Outputs

Gets all output pads for this template matching block.

public override MediaBlockPad[] Outputs { get; }

Property Value

MediaBlockPad[]

Settings

Gets or sets the template matching configuration settings. Defines template image path, matching algorithms, and detection thresholds.

public CVTemplateMatchSettings Settings { get; set; }

Property Value

CVTemplateMatchSettings

Type

Gets the media block type identifier.

public override MediaBlockType Type { get; }

Property Value

MediaBlockType

Methods

Build()

Constructs and initializes the OpenCV template matching element within the pipeline. This method validates the template image file, creates the matching filter with the specified settings, establishes input and output pads, and prepares the block for pattern recognition processing.

public override bool Build()

Returns

bool

true if the template matching element was successfully built and configured; false if initialization failed.

CleanUp()

Releases all resources and performs cleanup operations for this OpenCV template matching block. This method disposes of the template matching element, unsubscribes from events, and resets the build state.

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 BaseElement wrapper that provides additional functionality around the OpenCV template matching element.

public BaseElement GetCore()

Returns

BaseElement

The BaseElement wrapper instance that encapsulates the template matching functionality.

GetElement()

Gets the underlying GStreamer element that performs the template matching operation.

public Element GetElement()

Returns

Element

The GStreamer Element instance representing the OpenCV template matching filter.

IsAvailable()

Determines whether this media block is available. Correct NuGet SDK redist should be included into your project. Checks for OpenCV library availability and template matching algorithm support.

public static bool IsAvailable()

Returns

bool

true if OpenCV template matching functionality is available; otherwise, false.

ProcessBusMessage(Structure)

Processes GStreamer bus messages for template matching events and notifications. This method handles internal communication and triggers template matching events.

public void ProcessBusMessage(Structure data)

Parameters

data Structure

The GStreamer message data containing detection information.

IMediaBlockInternals.SetContext(MediaBlocksPipeline)

Associates this OpenCV template matching block with a pipeline and initializes its internal context. This method is called internally when the block is added to a pipeline.

void IMediaBlockInternals.SetContext(MediaBlocksPipeline pipeline)

Parameters

pipeline MediaBlocksPipeline

The MediaBlocksPipeline instance that will manage this block.

TemplateMatch

Event raised when template matches are found in the video stream. Provides match coordinates, confidence scores, and detection metadata.

public event EventHandler<CVTemplateMatchEventArgs> TemplateMatch

Event Type

EventHandler<CVTemplateMatchEventArgs>

See Also