设置条形码读取器选项
using IronBarCode;

BarcodeReaderOptions myOptionsExample = new BarcodeReaderOptions()
{
    // Choose a reading speed from: Faster, Balanced, Detailed, ExtremeDetail
    // There is a tradeoff in performance as more detail is set
    Speed = ReadingSpeed.Balanced,

    // Reader will stop scanning once a single barcode is found (if set to true)
    ExpectMultipleBarcodes = true,

    // By default, all barcode formats are scanned for
    // Specifying a subset of barcode types to search for would improve performance
    ExpectBarcodeTypes = BarcodeEncoding.AllOneDimensional,

    // Utilize multiple threads to read barcodes from multiple images in parallel
    Multithreaded = true,

    // Maximum threads for parallelized barcode reading
    // Default is 4
    MaxParallelThreads = 2,

    // The area of each image frame in which to scan for barcodes
    // Specifying a crop area will significantly improve performance and avoid noisy parts of the image
    CropArea = new System.Drawing.Rectangle(),

    // Special setting for Code39 barcodes
    // If a Code39 barcode is detected, try to read with both the base and extended ASCII character sets
    UseCode39ExtendedMode = true,

    // Minimum scan lines that must agree on a result for it to be valid
    // Default is 2. Set to 1 for thin or low-quality barcodes
    MinScanLines = 1
};
NuGet下载
PM > Install-Package BarCode
设置条形码读取器选项

设置条形码读取器选项

IronBarcode在BarcodeReaderOptions类中提供了一系列设置,以启用定制化和优化的条形码读取。 这些选项允许您在资源和准确性之间进行权衡,控制阅读范围,并优化阅读策略。

可用的BarcodeReaderOptions类型

  • BarcodeReaderOptions: 此类提供了定制条形码读取的选项,根据特定需求使过程更高效和准确。
  • ExpectMultipleBarcodes: 将此设置为false,读取器将在找到第一个条形码后停止,提升在仅需要一个条形码时的性能。
  • ExpectBarcodeTypes: 指定要扫描的BarcodeEncoding类型,在有多种条形码格式时简化过程。
  • CropArea: 允许专注于图像的特定区域,当大致已知条形码位置时,这可以显著提高读取时间和准确性。
  • MaxParallelThreads: 指定要并行使用的最大线程数,提高多CPU核心系统上的性能。
  • MinScanLines: 设置必须同意条形码结果的最小扫描线数,以使其被视为有效。 默认值为 2。将其调低至 1 可提高对细小或质量较差 BarCode 的识别灵敏度,而调高则可减少误报。

此配置可在资源利用、速度和准确性之间取得平衡,以满足您特定的条形码读取需求。

使用 IronBarcode 学习如何从图像中读取条形码
在GitHub上查看

准备开始了吗?

NuGet 下载量 2,575,633版本:2026.11刚刚发布