Recognition XDimension Mode

Overview

Aspose.BarCode for .NET provides special mode which uses knowledge about barcode minimal element: matrix cell or bar. This mode can be set with XDimension and UseMinimalXDimension properties from QualitySettings and allows to cut off noise, text and non-barcode elements to increase performance. With using UseMinimalXDimension other property MinimalXDimension is used to set minimal barcode element.

XDimension Mode

This section provides detailed information about XDimension and UseMinimalXDimension properties to enable required modes and listed in the table below.

XDimension Mode Description
Auto At this time the same mode as Normal. In the future AI based detection
Small Detects barcodes with small XDimension in 1 pixel or more of minimal barcode element
Normal Detects barcodes with base XDimension 2-5 pixels or more of minimal barcode element. The value is depends from barcode type
Large Detects barcodes with large XDimension captured with high-resolution cameras
UseMinimalXDimension Detects barcodes with XDimension set in UseMinimalXDimension property

Using XDimension with 1D Barcode Types

The following table shows difference in recognition quality, depends on XDimension settings.

XDimension Normal XDimension Small XDimension UseMinimalXDimension
Recognized barcodes: 2 Recognized barcodes: 5 Recognized barcodes: 5
Console.WriteLine("ReadXDimension1DDocument:");
//recognize image with XDimension Normal
Console.WriteLine("XDimensionMode: Normal");
using (BarCodeReader read = new BarCodeReader($"{path}many_code128.png", DecodeType.Code128))
{
    read.QualitySettings.XDimension = XDimensionMode.Normal;
    Console.WriteLine($"Barcodes read: {read.ReadBarCodes().Length}");
    foreach (BarCodeResult result in read.FoundBarCodes)
        Console.WriteLine($"{result.CodeTypeName}:{result.CodeText}");
}


//recognize image with XDimension 
Console.WriteLine("XDimensionMode: Small");
using (BarCodeReader read = new BarCodeReader($"{path}many_code128.png", DecodeType.Code128))
{
    read.QualitySettings.XDimension = XDimensionMode.Small;
    Console.WriteLine($"Barcodes read: {read.ReadBarCodes().Length}");
    foreach (BarCodeResult result in read.FoundBarCodes)
        Console.WriteLine($"{result.CodeTypeName}:{result.CodeText}");
}

//recognize image with XDimension 
Console.WriteLine("XDimensionMode: UseMinimalXDimension");
using (BarCodeReader read = new BarCodeReader($"{path}many_code128.png", DecodeType.Code128))
{
    read.QualitySettings.XDimension = XDimensionMode.UseMinimalXDimension;
    read.QualitySettings.MinimalXDimension = 1;
    Console.WriteLine($"Barcodes read: {read.ReadBarCodes().Length}");
    foreach (BarCodeResult result in read.FoundBarCodes)
        Console.WriteLine($"{result.CodeTypeName}:{result.CodeText}");
}
View the results of code execution
ReadXDimension1DDocument:
XDimensionMode: Normal
Barcodes read: 2
Code128:Aspose Code 03
Code128:Aspose Code 04
XDimensionMode: Small
Barcodes read: 5
Code128:Aspose Diag 01
Code128:Aspose Code 02
Code128:Aspose Code 03
Code128:Aspose Code 01
Code128:Aspose Code 04
XDimensionMode: UseMinimalXDimension
Barcodes read: 5
Code128:Aspose Diag 01
Code128:Aspose Code 02
Code128:Aspose Code 03
Code128:Aspose Code 01
Code128:Aspose Code 04

XDimension Normal XDimension Small
Recognized barcodes: 2 Recognized barcodes: 3
Console.WriteLine("ReadXDimension1DThreeCode128:");
//recognize image with XDimension Normal
Console.WriteLine("XDimensionMode: Normal");
using (BarCodeReader read = new BarCodeReader($"{path}code128_big_and_small.png ", DecodeType.Code128))
{
    read.QualitySettings.XDimension = XDimensionMode.Normal;
    Console.WriteLine($"Barcodes read: {read.ReadBarCodes().Length}");
    foreach (BarCodeResult result in read.FoundBarCodes)
        Console.WriteLine($"{result.CodeTypeName}:{result.CodeText}");
}


//recognize image with XDimension Small
Console.WriteLine("XDimensionMode: Small");
using (BarCodeReader read = new BarCodeReader($"{path}code128_big_and_small.png ", DecodeType.Code128))
{
    read.QualitySettings.XDimension = XDimensionMode.Small;
    Console.WriteLine($"Barcodes read: {read.ReadBarCodes().Length}");
    foreach (BarCodeResult result in read.FoundBarCodes)
        Console.WriteLine($"{result.CodeTypeName}:{result.CodeText}");
}
View the results of code execution
ReadXDimension1DThreeCode128:
XDimensionMode: Normal
Barcodes read: 2
Code128:Aspose BIG1
Code128:Aspose BIG2
XDimensionMode: Small
Barcodes read: 3
Code128:Aspose BIG1
Code128:Aspose SML1
Code128:Aspose BIG2