using IronBarCode;
using IronSoftware.Drawing;
using System.Linq;
// Choose which filters are to be applied (in order);
var filtersToApply = new ImageFilterCollection() {
new SharpenFilter(),
new InvertFilter(),
new ContrastFilter(),
new BrightnessFilter(),
new AdaptiveThresholdFilter(),
new BinaryThresholdFilter()
};
BarcodeReaderOptions myOptionsExample = new BarcodeReaderOptions()
{
// Set chosen filters in BarcodeReaderOptions:
ImageFilters = filtersToApply,
// Other Barcode Reader Options:
Speed = ReadingSpeed.Balanced,
ExpectMultipleBarcodes = true,
};
// And, apply with a Read:
BarcodeResults results = BarcodeReader.Read("screenshot.png", myOptionsExample);
AnyBitmap[] filteredImages = results.FilterImages();
// Export file 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
Imports System.Linq
' Choose which filters are to be applied (in order);
Private filtersToApply = New ImageFilterCollection() From {
New SharpenFilter(),
New InvertFilter(),
New ContrastFilter(),
New BrightnessFilter(),
New AdaptiveThresholdFilter(),
New BinaryThresholdFilter()
}
Private myOptionsExample As New BarcodeReaderOptions() With {
.ImageFilters = filtersToApply,
.Speed = ReadingSpeed.Balanced,
.ExpectMultipleBarcodes = True
}
' And, apply with a Read:
Private results As BarcodeResults = BarcodeReader.Read("screenshot.png", myOptionsExample)
Private filteredImages() As AnyBitmap = results.FilterImages()
' Export file 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
Codes-barres imparfaits et correction d'image
IronBarcode propose de nombreux filtres qui peuvent être facilement appliqués dans les BarcodeReaderOptions. Sélectionnez les filtres susceptibles d'améliorer la lecture de votre image, tels que Accentuation, Inversion, etc(couleurs)et Contraste. N'oubliez pas que l'ordre dans lequel vous les choisissez est l'ordre dans lequel ils sont appliqués.
Liens vers des documents connexes
Prêt à commencer ? Version : 2024.11 vient de paraître