Free Support Forum -

Wrong Recognition Result for the GS1 Code128 Barcode

We are using licensed Aspose.BarCode library on our system but found out that sometimes we get wrong data.

Attached is an example of barcode and the result we got was:
(01)08714729743071(17)200630(10)5844751622 (type: GS1Code128)

Please let us know how can we prevent it – our system relies on your package and its accuracy is mandatory.


image-croppedFrame - 0.80 MP.jpg (88.2 KB)


Your code text might be wrong in your provided barcode image. I did test your scenario/ case by using the following sample code with your desired code text using Aspose.BarCode for .NET v20.10 and it works fine and as expected. I also retrieved it back using the APIs and it works fine.
Sample code:

var barcodeContent1 = "(01)08714729743071(17)230630(10)5844756";
var generator2 = new Aspose.BarCode.Generation.BarcodeGenerator(Aspose.BarCode.Generation.EncodeTypes.GS1Code128, barcodeContent1);
            // Save the image to your system and set its image format to Jpeg
            using (var ms = new MemoryStream())
                generator2.Save(ms, BarCodeImageFormat.Jpeg);
                using (var reader1 = new Aspose.BarCode.BarCodeRecognition.BarCodeReader(ms))
                    var results = reader1.ReadBarCodes();
                    Console.WriteLine(barcodeContent1 + " :" + results[0].CodeText);

Thank you for your quick response,
the code is not wrong because if i try to recognize same barcode, but the image is in better quality (attached), it works fine.
I’m using library version 20.7.

image-source - 13.13 MP - Copy.jpg (179.6 KB)


Yes, barcode image quality matters. This better quality barcode image is read it well as I did test using your new image. For low quality barcode image, Aspose.BarCode might not read it properly. We are continuously improving the barcode reading engine with each release. A new ticket is logged for your issue with an id “BARCODENET-37691”. We will look into it soon.

Once we have an update on it, we will let you know.

1 Like

Code128 barcode is high density 1D barcode which was developed in 80-th as replacement of 2 of 5 codes. Because this barcode has more density then other barcode it requires checksum by default which must reduce recognition errors. Checksum isn’t to strong but in main cases it is enough to make recognition errors rate low. Main disadvantage of Code128 that it doesn’t have information for restoration as 2D barcodes do. This leads to situation when in low quality image we cannot recognize barcode segment correctly because on low quality images some barcode segments can have multiple recognition results.

The barcode is a row of letters which are represented by the group of barcodes and some of these lettesr on low quality images are recognized but recognized with multiple variants. In normal recognition mode this row is checked by checksum and drop out if checksum is wrong.

In increase the recognition quality we create decision algorithm which recognize low quality barcodes by creating decision tree from these variants and checks variants sequences by checksum. In most of cases (more then 95-98%) it allows to recognize barcodes correctly which mustn’t be recognized. But in 2-5% cases it recognizes with error.

I started project to make recognition process more customizable and give user ability to tune these engine modes manually. So, the decision tree algorithm could be disabled and hard modes also could be disabled. This will allow to increase performance on high quality images and decrease false positive recognition. Currently this improvement isn’t implemented, but I think it will be implemented in 2021Q2.

1 Like

Thanks for the detailed explanation, we will wait for the update.