Class BarcodeReaderOptions
An Options class of BarcodeReader for reading many popular barcode formats from Images and PDFs.
Namespace: IronBarCode
Assembly: IronBarCode.dll
Syntax
public class BarcodeReaderOptions : Object
When a read needs tuning for accuracy or speed, BarcodeReaderOptions carries the settings that steer it. Every BarcodeReader.Read and ReadAsync overload accepts one, so the same options object decides which symbologies to scan for, how hard to look, and how to handle awkward source images. Reaching for it is the answer to "barcode reading too slow in C#" or "IronBarcode not detecting barcode", since the defaults favor accuracy and most tuning happens here.
A reader receives the options as an argument; construct one with new BarcodeReaderOptions(), set the properties a job needs, and pass it to a read call. PdfBarcodeReaderOptions derives from this class and adds the PDF-specific page, DPI, and password settings, so a PDF read configures the same base properties plus those extras. Leaving the argument out applies the defaults, which scan for all supported types at balanced speed.
The properties group by purpose. Symbology selection is ExpectBarcodeTypes, a BarcodeEncoding value that limits the scan to the formats a job expects, and ExpectMultipleBarcodes, which keeps scanning after the first code is found instead of stopping early. Detection strategy is ScanMode, a BarcodeScanMode that chooses a basic pass or a machine-learning model, Speed, a ReadingSpeed that runs from Faster to ExtremeDetail and defaults to Balanced, and ConfidenceThreshold, the minimum machine-learning confidence in the range zero to one with a default of 0.7. Image handling is AutoRotate, ImageFilters, CropArea, and MinScanLines, which correct, filter, and bound the region scanned. Throughput is Multithreaded, MaxParallelThreads, and RemoveFalsePositive. The Code 39 specific UseCode39ExtendedMode enables the extended character set. Set only the properties a job needs and leave the rest at their defaults.
using IronBarCode;
var options = new BarcodeReaderOptions
{
ExpectBarcodeTypes = BarcodeEncoding.QRCode,
Speed = ReadingSpeed.Faster,
ExpectMultipleBarcodes = true
};
BarcodeResults results = BarcodeReader.Read("barcode.png", options);The reading speed options how-to tunes accuracy against throughput, the barcode reader settings example shows a configured read, and the read multiple barcodes how-to sets the multi-code option.
Constructors
BarcodeReaderOptions()
Initializes a new instance of the BarcodeReader class.
Declaration
public BarcodeReaderOptions()
Properties
AutoRotate
Toggle whether to automatically rotate barcodes or not in an ML detection. Default = true.
Declaration
public bool AutoRotate { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
ConfidenceThreshold
Minimum confidence level for ML model detection to be considered valid. The value is between (0.0, 1.0). Default value is 0.7
Declaration
public double ConfidenceThreshold { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
CropArea
The area of each image frame in which to scan for barcodes. A IronSoftware.Drawing.Rectangle measured in pixels.
Declaration
public Rectangle CropArea { get; set; }
Property Value
| Type | Description |
|---|---|
| IronSoftware.Drawing.Rectangle |
ExpectBarcodeTypes
The barcode encoding types to read from the InputImage. By default all supported barcodes types are scanned for.
Declaration
public BarcodeEncoding ExpectBarcodeTypes { get; set; }
Property Value
| Type | Description |
|---|---|
| BarcodeEncoding |
ExpectMultipleBarcodes
If set to false the barcode reader will stop scanning a given image once a barcode has been found to increase performance. Default = true.
Declaration
public bool ExpectMultipleBarcodes { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
ImageFilters
A collection of image filters for image pre-processing.
Declaration
public ImageFilterCollection ImageFilters { get; set; }
Property Value
| Type | Description |
|---|---|
| ImageFilterCollection |
MaxParallelThreads
Max Threads for parallel. Default 4
Declaration
public int MaxParallelThreads { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
MinScanLines
The minimum number of scan-lines that must agree on a barcode result for it to be considered valid.
Increasing this reduces false positives (misreads) but may prevent detection of thin or low-quality barcodes.
Decreasing this (e.g. to 1) increases sensitivity for difficult barcodes but may introduce noise.
Default is 2.
Declaration
public int MinScanLines { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Int32 | A value greater than or equal to 1. |
Multithreaded
Reads barcodes from multiple images in parallel. Multiple threads will automatically be started and managed to improve performance for batch barcode reading tasks.
Declaration
public bool Multithreaded { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
RemoveFalsePositive
Attempt to remove false positive barcode reads. This can be disabled to improve performance at the cost of accuracy. Default = true.
Declaration
public bool RemoveFalsePositive { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
ScanMode
Define how IronBarcode scans and detects barcodes in an image to read.
Declaration
public BarcodeScanMode ScanMode { get; set; }
Property Value
| Type | Description |
|---|---|
| BarcodeScanMode |
Speed
Barcode reading speed. Default = Balanced.
Declaration
public ReadingSpeed Speed { get; set; }
Property Value
| Type | Description |
|---|---|
| ReadingSpeed |
UseCode39ExtendedMode
If a Code39 barcode is detected, use the extended mode for the full ASCII character set.
Declaration
public bool UseCode39ExtendedMode { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |