False Positives
How to remove false positives?
False Positives are an issue with text documents containing 1D barcodes:
- Tell IronBarCode to read only the barcode formats you expect. A complete list of options is shown here: BarcodeEncoding.
- Enable the RemoveFalsePositive property. When enabled, IronBarcode will scale the input image up or down slightly, creating two images for barcode scanning. It then discards any barcodes not found in both images. Note: This process is slower but reduces false positive results.
using IronBarCode;
BarcodeReaderOptions myOptionsExample = new BarcodeReaderOptions()
{
// By default, all barcode formats are scanned for.
ExpectBarcodeTypes = IronBarCode.BarcodeEncoding.Code39,
// Turn on remove false positive
RemoveFalsePositive = true
};
var results = BarcodeReader.Read("barcode.png", myOptionsExample);
using IronBarCode;
BarcodeReaderOptions myOptionsExample = new BarcodeReaderOptions()
{
// By default, all barcode formats are scanned for.
ExpectBarcodeTypes = IronBarCode.BarcodeEncoding.Code39,
// Turn on remove false positive
RemoveFalsePositive = true
};
var results = BarcodeReader.Read("barcode.png", myOptionsExample);
Imports IronBarCode
Private myOptionsExample As New BarcodeReaderOptions() With {
.ExpectBarcodeTypes = IronBarCode.BarcodeEncoding.Code39,
.RemoveFalsePositive = True
}
Private results = BarcodeReader.Read("barcode.png", myOptionsExample)
Reason
False positives in barcode reading can happen when complex background patterns look like barcodes, or when noise and artifacts create unintended marks that the reader mistakenly sees as valid barcodes.