設置條碼讀取器選項
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剛剛發布