不完美條碼與圖像校正
using IronBarCode;
using IronSoftware.Drawing;

// Choose which filters are to be applied (in order)
// Set cacheAtEachIteration = true to save the intermediate image data after each filter is applied
var filtersToApply = new ImageFilterCollection(cacheAtEachIteration: true) {
    new SharpenFilter(),
    new InvertFilter(),
    new ContrastFilter(),
    new BrightnessFilter(),
    new AdaptiveThresholdFilter(),
    new BinaryThresholdFilter(),
    new GaussianBlurFilter(),
    new MedianBlurFilter(),
    new BilateralFilter()
};

BarcodeReaderOptions myOptionsExample = new BarcodeReaderOptions()
{
    // Set chosen filters in BarcodeReaderOptions
    ImageFilters = filtersToApply,

    Speed = ReadingSpeed.Balanced,
    ExpectMultipleBarcodes = true,
};

// Read with the options applied
BarcodeResults results = BarcodeReader.Read("screenshot.png", myOptionsExample);

AnyBitmap[] filteredImages = results.FilterImages();

// Export intermediate image files to disk
for (int i = 0 ; i < filteredImages.Length ; i++)
    filteredImages[i].SaveAs($"{i}_barcode.png");

// Or
results.ExportFilterImagesToDisk("filter-result.jpg");
NuGet 下載
PM > Install-Package BarCode
不完美條碼與圖像校正

不完美條碼與圖像校正

IronBarcode 提供許多影像預處理過濾器可供您選擇,這些過濾器可以輕鬆地應用於 BarcodeReaderOptions 中。 選擇可能改善您影像讀取的過濾器,如 Sharpen、二元閾值 和 Contrast。 請記住,您選擇它們的順序是它們實際應用的順序。

可以選擇保存應用每個濾波器後的中間影像的影像資料。 這可以通過 CacheAtEachIteration 的 ImageFilterCollection 屬性來切換。

重點來自特色程式碼範例:

  • 我們建立BarcodeReaderOptions的實例,並使用各種影像過濾器進行設定:Sharpen、Binary Threshold 和 Contrast。
  • 過濾器按特定順序添加,指示其應用順序。
  • 通過將 cacheAtEachIteration 設置為 true,程式庫在每次應用過濾器後保存中間影像,這對於除錯和分析非常有用。
  • 最後,我們從影像中讀取條碼,並將條碼類型和值打印到控制台中。
了解更多關於IronBarcode的影像校正信息
在 GitHub 查看

準備好開始了嗎?

NuGet 下載次數 2,575,633版本:2026.11剛剛發布