Table of Contents

Class BarcodeEventArgs

Namespace
VisioForge.Core.Types.Events
Assembly
VisioForge.Core.dll

Provides data for barcode detection events, containing information about the detected barcode.

public class BarcodeEventArgs : EventArgs

Inheritance

Inherited Members

Examples

// Assume an event handler is registered for a barcode detection event.
public void OnBarcodeDetected(object sender, BarcodeEventArgs e)
{
    Console.WriteLine($"Barcode Detected! Type: {e.BarcodeType}, Value: {e.Value}");

    if (e.RawBytes != null)
    {
        Console.WriteLine($"  Raw Bytes: {BitConverter.ToString(e.RawBytes)}");
    }

    if (e.Points != null && e.Points.Length > 0)
    {
        Console.WriteLine($"  Points: ");
        foreach (var point in e.Points)
        {
            Console.WriteLine($"    ({point.X}, {point.Y})");
        }
    }

    // Optionally disable the detector after a barcode is found.
    // e.DetectorEnabled = false;
}

Remarks

This class is used to pass details about a barcode that has been successfully detected and decoded from a video frame or image. It includes the barcode type, its decoded value, raw bytes, and optional metadata and corner points. The VisioForge.Core.Types.Events.BarcodeEventArgs.DetectorEnabled property allows for temporary disabling of the barcode detector from within the event handler. The BarcodeType property identifies the symbology (QR Code, Code 128, EAN-13, UPC-A, Data Matrix, PDF417, etc.). Value contains the decoded human-readable text extracted from the barcode. RawBytes provides access to the binary-encoded data, which may differ from the text representation for some barcode types. Points array contains the detected corner or control points of the barcode, useful for overlaying visual feedback or cropping. Metadata dictionary provides additional detection information like orientation, character encoding, or error correction level. Timestamp indicates the exact frame time when the barcode was detected, useful for synchronization and logging. DetectorEnabled can be set to false within the event handler to stop further detection after successfully reading a barcode. Multiple barcodes in the same frame will generate separate event invocations. Detection accuracy depends on image quality, resolution, lighting, barcode size, and camera focus. Applications should validate decoded data format and implement checksums or error correction for critical scenarios. These events are typically raised on background processing threads, requiring thread-safe handling and UI marshaling. Consider implementing timeouts or maximum read limits to prevent excessive processing on continuous streams.

Constructors

BarcodeEventArgs(BarcodeType, string, IDictionary<BarcodeResultMetadataType, object>, TimeSpan, byte[], BarcodeResultPoint[], ref bool)

Initializes a new instance of the VisioForge.Core.Types.Events.BarcodeEventArgs class.

public BarcodeEventArgs(BarcodeType barcodeType, string value, IDictionary<BarcodeResultMetadataType, object> metadata, TimeSpan timeStamp, byte[] rawBytes, BarcodeResultPoint[] points, ref bool detectorEnabled)

Parameters

barcodeType BarcodeType

The type of the detected barcode.

value string

The decoded string value of the barcode.

metadata IDictionary<BarcodeResultMetadataType, object>

Optional metadata about the barcode detection.

timeStamp TimeSpan

The timestamp of the frame where the barcode was detected.

rawBytes byte[]

The raw bytes encoded by the barcode.

points BarcodeResultPoint[]

Key points related to the barcode in the image.

detectorEnabled bool

A reference to a boolean flag indicating if the detector is enabled. Can be set to false to disable the detector.

Properties

BarcodeType

Gets the type of the detected barcode (e.g., QR Code, EAN-13, Code 39).

public BarcodeType BarcodeType { get; }

Property Value

BarcodeType

DetectorEnabled

Gets or sets a value indicating whether the barcode detector should remain enabled after this event. Setting this to false will temporarily disable the detector.

public bool DetectorEnabled { get; set; }

Property Value

bool

Metadata

Gets optional metadata about what was detected about the barcode, such as orientation or character set. The keys are of type VisioForge.Libs.Types.BarcodeResultMetadataType.

public IDictionary<BarcodeResultMetadataType, object> Metadata { get; }

Property Value

IDictionary<BarcodeResultMetadataType, object>

Points

Gets an array of VisioForge.Libs.Types.BarcodeResultPoint objects representing key points related to the barcode in the image. These are typically points identifying finder patterns or the corners of the barcode, and their exact meaning is specific to the type of barcode that was decoded.

public BarcodeResultPoint[] Points { get; }

Property Value

BarcodeResultPoint[]

RawBytes

Gets the raw bytes encoded by the barcode, if applicable and available; otherwise, null.

public byte[] RawBytes { get; }

Property Value

byte[]

Timestamp

Gets the timestamp of the video frame or image from which the barcode was detected.

public TimeSpan Timestamp { get; }

Property Value

TimeSpan

Value

Gets the decoded string value of the barcode.

public string Value { get; }

Property Value

string