Imperfect Barcodes and Image Correction

C# + VB.Net: Imperfect Barcodes and Image Correction Imperfect Barcodes and Image Correction
using IronBarCode;


/*** READING BARCODES FROM IMPERFECT IMAGES, PHOTOS AND SCANS ***/

// Shorthand:: BarcodeReader.QuicklyReadOneBarcode will automatically try to clean and deskew barcodes from images if you add 'true' as the last TryHarder parameter
BarcodeResult Result = BarcodeReader.QuicklyReadOneBarcode("QuickStart.jpg", BarcodeEncoding.All, true);


// All BarcodeResult 'Read' methods provide the developer with control to correct image and photograph correction and straightening rotation and perspective from skewed images
// * RotationCorrection -  un-skews and removes perspective from barcode images.
// * ImageCorrection - separates Barcodes from background imagery and digital noise.
// * BarcodeEncoding  - BarcodeEncoding.Code128  Setting a specific Barcode format improves speed and reduces the risk of false positive results

// Example with a photo image
BarcodeResult PhotoResults = BarcodeReader.ReadASingleBarcode("Photo.png", BarcodeEncoding.Code128, BarcodeReader.BarcodeRotationCorrection.Medium, BarcodeReader.BarcodeImageCorrection.DeepCleanPixels);

// Example with a scanned document as a PDF
PagedBarcodeResult[] ScanResults = BarcodeReader.ReadBarcodesFromPdf("Scan.pdf", BarcodeEncoding.QRCode | BarcodeEncoding.PDF417, BarcodeReader.BarcodeRotationCorrection.Low, BarcodeReader.BarcodeImageCorrection.LighlyCleanPixels);

// Small or 'Thumbnail' barcode images are automatically detected by IronBarCode and corrected for wherever possible even if they have much digital noise.
BarcodeResult SmallResult = BarcodeReader.QuicklyReadOneBarcode("ThumbnailOfBarcode.gif", BarcodeEncoding.Code128);
Imports IronBarCode


'''* READING BARCODES FROM IMPERFECT IMAGES, PHOTOS AND SCANS **

' Shorthand:: BarcodeReader.QuicklyReadOneBarcode will automatically try to clean and deskew barcodes from images if you add 'true' as the last TryHarder parameter
Private Result As BarcodeResult = BarcodeReader.QuicklyReadOneBarcode("QuickStart.jpg", BarcodeEncoding.All, True)


' All BarcodeResult 'Read' methods provide the developer with control to correct image and photograph correction and straightening rotation and perspective from skewed images
' * RotationCorrection -  un-skews and removes perspective from barcode images.
' * ImageCorrection - separates Barcodes from background imagery and digital noise.
' * BarcodeEncoding  - BarcodeEncoding.Code128  Setting a specific Barcode format improves speed and reduces the risk of false positive results

' Example with a photo image
Private PhotoResults As BarcodeResult = BarcodeReader.ReadASingleBarcode("Photo.png", BarcodeEncoding.Code128, BarcodeReader.BarcodeRotationCorrection.Medium, BarcodeReader.BarcodeImageCorrection.DeepCleanPixels)

' Example with a scanned document as a PDF
Private ScanResults() As PagedBarcodeResult = BarcodeReader.ReadBarcodesFromPdf("Scan.pdf", BarcodeEncoding.QRCode Or BarcodeEncoding.PDF417, BarcodeReader.BarcodeRotationCorrection.Low, BarcodeReader.BarcodeImageCorrection.LighlyCleanPixels)

' Small or 'Thumbnail' barcode images are automatically detected by IronBarCode and corrected for wherever possible even if they have much digital noise.
Private SmallResult As BarcodeResult = BarcodeReader.QuicklyReadOneBarcode("ThumbnailOfBarcode.gif", BarcodeEncoding.Code128)

The shorthand for reading imperfect images, de-skewing them, and cleaning them to make otherwise unreadable barcodes readable is simply to use the QuicklyReadOneBarcode method with the TryHarder flag set to true.

By setting RotationCorrection, ImageCorrection, and BarcodeEncoding settings of any of the BarcodeReader methods, we see that we can increase the accuracy and tailor-make our barcode reading solution to our situation. Too much image preprocessing may cause our barcode reading to take a long time, whereas too little may make barcodes unreadable.

Iron Barcode makes it very easy for developers to find and strike that fine balance without wasting days of their own time working with image manipulation frameworks.