False Positives

How to Remove False Positives?

False positives in barcode reading can occur when complex background patterns resemble barcodes or when noise and artifacts create unintended marks that the reader mistakenly identifies as valid barcodes. The following steps can be taken to remove false positives from IronBarcode's reading output:

  1. Specify Expected Barcode Formats: Configure IronBarcode to read only the barcode formats you expect. A complete list of options is available here: BarcodeEncoding.

  2. Enable the RemoveFalsePositive Property: When scanning for barcodes, IronBarcode searches for "candidate" regions in an image that most likely resemble a barcode, then attempts to decode those regions. By setting this property to true, IronBarcode will only decode regions that have no errors in their encoding. By default, RemoveFalsePositive is already set to true.
using IronBarCode;

class BarcodeExample
{
    static void Main()
    {
        // Create a BarcodeReaderOptions object with specific parameters.
        BarcodeReaderOptions myOptionsExample = new BarcodeReaderOptions()
        {
            // Expect and return barcode results for only the Code 39 type.
            ExpectBarcodeTypes = IronBarCode.BarcodeEncoding.Code39,

            // Enable removal of false positives by setting to true.
            RemoveFalsePositive = true
        };

        // Read the barcode from the specified image file using the given options.
        var results = BarcodeReader.Read("barcode.png", myOptionsExample);

        // Process the results here, e.g., display them, log them, etc.
    }
}
using IronBarCode;

class BarcodeExample
{
    static void Main()
    {
        // Create a BarcodeReaderOptions object with specific parameters.
        BarcodeReaderOptions myOptionsExample = new BarcodeReaderOptions()
        {
            // Expect and return barcode results for only the Code 39 type.
            ExpectBarcodeTypes = IronBarCode.BarcodeEncoding.Code39,

            // Enable removal of false positives by setting to true.
            RemoveFalsePositive = true
        };

        // Read the barcode from the specified image file using the given options.
        var results = BarcodeReader.Read("barcode.png", myOptionsExample);

        // Process the results here, e.g., display them, log them, etc.
    }
}
Imports IronBarCode

Friend Class BarcodeExample
	Shared Sub Main()
		' Create a BarcodeReaderOptions object with specific parameters.
		Dim myOptionsExample As New BarcodeReaderOptions() With {
			.ExpectBarcodeTypes = IronBarCode.BarcodeEncoding.Code39,
			.RemoveFalsePositive = True
		}

		' Read the barcode from the specified image file using the given options.
		Dim results = BarcodeReader.Read("barcode.png", myOptionsExample)

		' Process the results here, e.g., display them, log them, etc.
	End Sub
End Class
$vbLabelText   $csharpLabel