Be Kind To New Users
Be Kind To New Users

Reputation: 10073

ZXing.BarcodeReader code not decode barcode

This barcode:

Sample Barcode

Will not decode. What is wrong with that image that it will not decode.

string barcodePng = "tmp.png";
reader = new BarcodeReader();
reader.Options.PossibleFormats = new List<BarcodeFormat>();
reader.Options.PossibleFormats.Add(BarcodeFormat.CODE_39);
reader.Options.TryHarder = true;
using (var barcodeBitmap = new Bitmap(barcodePng))
{
    var result = reader.Decode(barcodeBitmap);
    if (result != null)
    {
        Console.WriteLine("barcode did not decode");
    }
}

This one is different from other thousands of other images that did decode in that I had to repair the original .tif file that it was cut from because it was damaged. I repaired it by converting it to .pdf and back to .tif.

Upvotes: 0

Views: 941

Answers (1)

GSerg
GSerg

Reputation: 78210

What is wrong with that image that it will not decode.

It will not decode because some bars have merged and/or changed their widths due to low resolution and blurring.

Assuming the symbology is Code 39, the valid barcode looks like this:

Upvotes: 1

Related Questions