Confidence Threshold - ML

Starting from December 2023, IronBarcode has incorporated machine learning to enhance its barcode detection capability. Set the ConfidenceThreshold property of the BarcodeReaderOptions to establish the minimum confidence level for ML model detection to be considered valid. The confidence threshold value is between 0.0 and 1.0, with the default set to 0.7.

Here is how to configure the ConfidenceThreshold for barcode detection using IronBarcode:

// Import the IronBarcode library
using IronBarCode;

class BarcodeDetection
{
    static void Main(string[] args)
    {
        // Instantiate the Barcode Reader Options
        BarcodeReaderOptions options = new BarcodeReaderOptions();

        // Set the confidence threshold level to 0.8
        // This value can range from 0.0 (least confident) to 1.0 (most confident)
        options.ConfidenceThreshold = 0.8;

        // Placeholder: Assume barcodeImagePath is the path to your barcode image
        string barcodeImagePath = "path/to/your/barcode/image.png";

        // Read barcodes from a file using the specified options
        var result = BarcodeReader.ReadBarcodesFromFile(barcodeImagePath, options);

        // Display results
        Console.WriteLine("Detected Barcodes:");
        foreach (var barcode in result)
        {
            Console.WriteLine($"Type: {barcode.BarcodeType} Value: {barcode.Text}");
        }
    }
}
// Import the IronBarcode library
using IronBarCode;

class BarcodeDetection
{
    static void Main(string[] args)
    {
        // Instantiate the Barcode Reader Options
        BarcodeReaderOptions options = new BarcodeReaderOptions();

        // Set the confidence threshold level to 0.8
        // This value can range from 0.0 (least confident) to 1.0 (most confident)
        options.ConfidenceThreshold = 0.8;

        // Placeholder: Assume barcodeImagePath is the path to your barcode image
        string barcodeImagePath = "path/to/your/barcode/image.png";

        // Read barcodes from a file using the specified options
        var result = BarcodeReader.ReadBarcodesFromFile(barcodeImagePath, options);

        // Display results
        Console.WriteLine("Detected Barcodes:");
        foreach (var barcode in result)
        {
            Console.WriteLine($"Type: {barcode.BarcodeType} Value: {barcode.Text}");
        }
    }
}
' Import the IronBarcode library
Imports IronBarCode

Friend Class BarcodeDetection
	Shared Sub Main(ByVal args() As String)
		' Instantiate the Barcode Reader Options
		Dim options As New BarcodeReaderOptions()

		' Set the confidence threshold level to 0.8
		' This value can range from 0.0 (least confident) to 1.0 (most confident)
		options.ConfidenceThreshold = 0.8

		' Placeholder: Assume barcodeImagePath is the path to your barcode image
		Dim barcodeImagePath As String = "path/to/your/barcode/image.png"

		' Read barcodes from a file using the specified options
		Dim result = BarcodeReader.ReadBarcodesFromFile(barcodeImagePath, options)

		' Display results
		Console.WriteLine("Detected Barcodes:")
		For Each barcode In result
			Console.WriteLine($"Type: {barcode.BarcodeType} Value: {barcode.Text}")
		Next barcode
	End Sub
End Class
$vbLabelText   $csharpLabel

For barcode detection without using machine learning, consider using the Barcode.Slim package.