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 : IDisposableInheritance
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
EnableDebugLogging
Gets or sets a value indicating whether to enable debug logging.
public bool EnableDebugLogging { get; set; }Property Value
ExpectedSize
Gets or sets the expected DataMatrix size for optimization. Default is SymbolShapeAuto for automatic detection.
public CodeSize ExpectedSize { get; set; }Property Value
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
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
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
disposingbool-
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
frameVideoFrameX-
The video frame to process.
timestampTimeSpan-
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