Table of Contents

Class DataMatrixDecoder

Namespace
VisioForge.Core.MediaBlocks.Special
Assembly
VisioForge.Core.dll

Provides asynchronous DataMatrix decoding capabilities for video frames using the LibDMTX library. This class processes video frames to detect and decode DataMatrix 2D barcodes with configurable frame skipping and processing synchronization to optimize CPU usage.

public class DataMatrixDecoder : IDisposable

Inheritance

Implements

Inherited Members

Remarks

The decoder supports:

  • Asynchronous frame processing to avoid blocking the video pipeline
  • Frame skipping to reduce CPU load (analyze every Nth frame)
  • Automatic frame dropping if processing is still in progress
  • Multiple DataMatrix detection in a single frame
  • Configurable timeout for decode operations

Constructors

DataMatrixDecoder()

Initializes a new instance of the VisioForge.Core.MediaBlocks.Special.DataMatrixDecoder class.

public DataMatrixDecoder()

Properties

DecodeTimeoutMs

Gets or sets the timeout in milliseconds for each decode operation. Default is 500ms. Set to -1 for no timeout.

public int DecodeTimeoutMs { get; set; }

Property Value

int

EnableDebugLogging

Gets or sets a value indicating whether to enable debug logging.

public bool EnableDebugLogging { get; set; }

Property Value

bool

ExpectedSize

Gets or sets the expected DataMatrix size for optimization. Default is SymbolShapeAuto for automatic detection.

public CodeSize ExpectedSize { get; set; }

Property Value

CodeSize

FrameSkip

Gets or sets the number of frames to skip between processing. Default is 0 (process every frame). Set to higher values to reduce CPU usage. For example, setting to 2 will process every 3rd frame.

public int FrameSkip { get; set; }

Property Value

int

MaxCodes

Gets or sets the maximum number of DataMatrix codes to detect per frame. Default is 1. Set to -1 for unlimited.

public int MaxCodes { get; set; }

Property Value

int

Methods

Dispose()

Releases all resources used by the DataMatrixDecoder.

public void Dispose()

Dispose(bool)

Releases the unmanaged resources used by the DataMatrixDecoder and optionally releases the managed resources.

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

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

ProcessFrameAsync(VideoFrameX, TimeSpan)

Processes a video frame to detect and decode DataMatrix codes. This method runs asynchronously and will skip frames if processing is already in progress.

public Task ProcessFrameAsync(VideoFrameX frame, TimeSpan timestamp)

Parameters

frame VideoFrameX

The video frame to process.

timestamp TimeSpan

The timestamp of the frame in the video stream.

Returns

Task

A task representing the asynchronous decode operation.

OnDataMatrixDetected

Occurs when one or more DataMatrix codes are detected in a frame.

public event EventHandler<DataMatrixDecoderEventArgs> OnDataMatrixDetected

Event Type

EventHandler<DataMatrixDecoderEventArgs>