Check Barcode Recognition Quality
Overview
In many cases, it is important to assess whether a barcode has been accurately recognized. In Aspose.BarCode for JavaScript via C++, this can be done using the Confidence and ReadingQuality properties of the BarCodeResult class.
Verify Barcode Reading Quality
The Confidence property returns a value from the BarCodeConfidence enumeration, indicating the confidence level of the recognition. The BarCodeConfidence enumeration has three possible values: None, Moderate, and Strong. The ReadingQuality property provides an estimate of recognition quality based on the confidence level: 0 for None; values from 1 to 99; and 100 for Strong.
Confidence Level | Reading Quality Value | Description |
---|---|---|
None | 0 | A None confidence level indicates that the source barcode may be incorrect and its data may contain errors. However, the barcode type and orientation in the image can still be determined, and partial data decoding is possible. |
Moderate | 80 | Returned for 1D and postal barcodes with weak or missing checksum settings. The ReadingQuality value should be analyzed. Even with high values (close to 80), absolute recognition accuracy is not guaranteed. |
Strong | 100 | Returned for all 2D barcodes with Reed-Solomon error correction when the QualitySettings.AllowIncorrectBarcodes setting is not enabled. This indicates that the barcode text has been decoded correctly and the recognition process was successful. |
The following code snippet shows how to obtain the recognition quality estimate for a sample barcode image.
// Recognize image
console.log("ReadExtQuality:");
var reader = new BarCodeInstance.BarCodeReader("img.png", "QR");
reader.ReadBarCodes();
for (var i = 0; i < reader.FoundCount; i++) {
const result = reader.FoundBarCodes(i);
console.log(`CodeType: ${result.CodeType}`);
console.log(`CodeText: ${result.CodeText}`);
console.log(`Confidence: ${result.Confidence}`);
console.log(`ReadingQuality: ${result.ReadingQuality}`);
}
reader.delete();