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");
Imports IronBarCode
Imports 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
Private filtersToApply = New ImageFilterCollection(cacheAtEachIteration:= True) From {
New SharpenFilter(),
New InvertFilter(),
New ContrastFilter(),
New BrightnessFilter(),
New AdaptiveThresholdFilter(),
New BinaryThresholdFilter(),
New GaussianBlurFilter(),
New MedianBlurFilter(),
New BilateralFilter()
}
Private myOptionsExample As New BarcodeReaderOptions() With {
.ImageFilters = filtersToApply,
.Speed = ReadingSpeed.Balanced,
.ExpectMultipleBarcodes = True
}
' Read with the options applied
Private results As BarcodeResults = BarcodeReader.Read("screenshot.png", myOptionsExample)
Private filteredImages() As AnyBitmap = results.FilterImages()
' Export intermediate image files to disk
For i As Integer = 0 To filteredImages.Length - 1
filteredImages(i).SaveAs($"{i}_barcode.png")
Next i
' Or
results.ExportFilterImagesToDisk("filter-result.jpg")
Install-Package BarCode
Hatalı Barkodlar ve Görüntü Düzeltme
IronBarcode, BarcodeReaderOptions içinde kolayca uygulanabilen birçok görüntü ön işleme filtresi sunar. Sharpen, İkili Eşik ve Contrast gibi görüntü okumanızı iyileştirebilecek filtreleri seçin. Seçtiğiniz sıranın uygulandığı sırası olduğunu unutmayın.
Her filtre uygulandıktan sonra, ara görüntülerin resim verisini kaydetme seçeneği vardır. Bu, ImageFilterCollection 'nin SaveAtEachIteration özelliği ile açılıp kapatılabilir.
Özellikli Kod Örneğinden Anahtar Noktalar:
BarcodeReaderOptions bir örneği oluşturuyoruz ve farklı görüntü filtreleri ile yapılandırıyoruz: Sharpen, Binary Threshold ve Contrast.
Filtreler belirli bir sırayla eklenir ve uygulanacağı sıralamayı belirtir.
cacheAtEachIteration 'yi true olarak ayarlayarak, kütüphane, her filtre uygulamasından sonra ara görüntüleri kaydeder ki bu hata ayıklama ve analiz için faydalıdır.
Son olarak, görüntüden barkodu okuyup konsolda barkod türünü ve değerini basarız.