Recognition XDimension Mode

Overview

Aspose.BarCode for JavaScript via C++ provides a specialized mode that leverages the minimal element of a barcode (such as a matrix cell or bar). This mode, configured using the XDimension and UseMinimalXDimension properties from the QualitySettings class, enhances performance by filtering out noise, text, and non-barcode elements. Additionally, the MinimalXDimension property can be used to set the minimum barcode element size.


XDimension Mode

Below are the details of the XDimension and UseMinimalXDimension properties, along with the supported modes:

XDimension Mode Description
Auto Currently equivalent to Normal. Future updates may include AI-based detection.
Small Detects barcodes with a minimal XDimension of 1 pixel or more.
Normal Detects barcodes with a base XDimension of 2-5 pixels or more. The exact value depends on the barcode type.
Large Detects barcodes with large XDimension, typically captured by high-resolution cameras.
UseMinimalXDimension Detects barcodes using the XDimension specified in the UseMinimalXDimension property.

Using XDimension with 1D Barcode Types

The table below illustrates the impact of different XDimension settings on recognition quality.

XDimension Normal XDimension Small XDimension UseMinimalXDimension
Recognized barcodes: 2 Recognized barcodes: 5 Recognized barcodes: 5

How to get BarCodeInstance

// Recognize image with XDimension Normal
console.log("XDimensionMode: Normal");
var readerNormal = new BarCodeInstance.BarCodeReader(`${path}many_code128.png`, "Code128");
readerNormal.QualitySettings.XDimension = BarCodeInstance.XDimensionMode.Normal;
readerNormal.ReadBarCodes();
console.log(`Barcodes read: ${readerNormal.FoundCount}`);
for (var i = 0; i < readerNormal.FoundCount; i++) {
    const result = readerNormal.FoundBarCodes(i);
    console.log(`${result.CodeType}: ${result.CodeText}`);
}
readerNormal.delete();

// Recognize image with XDimension Small
console.log("XDimensionMode: Small");
var readerSmall = new BarCodeInstance.BarCodeReader(`${path}many_code128.png`, "Code128");
readerSmall.QualitySettings.XDimension = BarCodeInstance.XDimensionMode.Small;
readerSmall.ReadBarCodes();
console.log(`Barcodes read: ${readerSmall.FoundCount}`);
for (var i = 0; i < readerSmall.FoundCount; i++) {
    const result = readerSmall.FoundBarCodes(i);
    console.log(`${result.CodeType}: ${result.CodeText}`);
}
readerSmall.delete();

// Recognize image with XDimension UseMinimalXDimension
console.log("XDimensionMode: UseMinimalXDimension");
var readerMinimal = new BarCodeInstance.BarCodeReader(`${path}many_code128.png`, "Code128");
readerMinimal.QualitySettings.XDimension = BarCodeInstance.XDimensionMode.UseMinimalXDimension;
readerMinimal.QualitySettings.MinimalXDimension = 1;
readerMinimal.ReadBarCodes();
console.log(`Barcodes read: ${readerMinimal.FoundCount}`);
for (var i = 0; i < readerMinimal.FoundCount; i++) {
    const result = readerMinimal.FoundBarCodes(i);
    console.log(`${result.CodeType}: ${result.CodeText}`);
}
readerMinimal.delete();

XDimension Normal XDimension Small
Recognized barcodes: 2 Recognized barcodes: 3

How to get BarCodeInstance


// Recognize image with XDimension Normal
console.log("XDimensionMode: Normal");
var readerNormal = new BarCodeInstance.BarCodeReader(`${path}code128_big_and_small.png`, "Code128");
readerNormal.QualitySettings.XDimension = BarCodeInstance.XDimensionMode.Normal;
readerNormal.ReadBarCodes();
console.log(`Barcodes read: ${readerNormal.FoundCount}`);
for (var i = 0; i < readerNormal.FoundCount; i++) {
    const result = readerNormal.FoundBarCodes(i);
    console.log(`${result.CodeType}: ${result.CodeText}`);
}
readerNormal.delete();

// Recognize image with XDimension Small
console.log("XDimensionMode: Small");
var readerSmall = new BarCodeInstance.BarCodeReader(`${path}code128_big_and_small.png`, "Code128");
readerSmall.QualitySettings.XDimension = BarCodeInstance.XDimensionMode.Small;
readerSmall.ReadBarCodes();
console.log(`Barcodes read: ${readerSmall.FoundCount}`);
for (var i = 0; i < readerSmall.FoundCount; i++) {
    const result = readerSmall.FoundBarCodes(i);
    console.log(`${result.CodeType}: ${result.CodeText}`);
}
readerSmall.delete();