Set Target Barcode Types for Recognition
Overview
Aspose.BarCode for JavaScript via C++ supports over 60 barcode types for recognition. To reduce recognition time and avoid processing outdated barcodes still used in some legacy industrial systems, it is recommended to specify the target barcode symbologies for recognition. If the exact symbologies in a source image are unknown, the default setting DecodeType.AllSupportedTypes can be used for the DecodeType property. This will check the source image for all supported barcode types, though it may increase the recognition time.
List of Barcode Types in DecodeType
Target barcode symbologies can be defined as a list and provided to the BarCodeReader constructor or the SetBarCodeReadType method.
The following code snippet shows how to set target symbologies (Code 39, Code 128, and RM4SCC) using DecodeType.
var reader = new BarCodeInstance.BarCodeReader(`${path}multiple_codes.png`);
reader.SetBarCodeReadType("Code39Extended", "Code128,RM4SCC");
console.log("ReadDecodeTypeList:");
var barcodes = reader.ReadBarCodes();
for (var i = 0; i < barcodes.length; i++) {
const result = barcodes[i];
console.log(`${result.CodeType}: ${result.CodeText}`);
}
reader.delete();
Predefined Sets of Types
Class DecodeTypes contains various predefined sets of symbologies for recognition, including the following ones:
- AllSupportedTypes - all supported barcode types
- Types1D - all supported 1D symbologies
- Types2D - all supported 2D symbologies
- PostalTypes - all supported postal symbologies that are mainly used by postal services
- MostCommonTypes - a set of most widely used barcode standards defined according to the Aspose recommendations
The required symbology set can be defined in the BarCodeReader constructor or the SetBarCodeReadType method.
The following code snippet illustrates how to specify target barcode types using the predefined set called Types2D.
var reader = new BarCodeInstance.BarCodeReader(gen.GenerateBarCodeImage(), "Types2D");
console.log("ReadTypes2D:");
reader.ReadBarCodes();
for (var i = 0; i < reader.FoundCount; i++) {
var result = reader.FoundBarCodes(i);
console.log(`CodeType: ${result.CodeType}`);
console.log(`CodeText: ${result.CodeText}`);
}
reader.delete();