We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Recognition of EAN barcodes while barcode read type is set to UPC

Hi there!

I want to only recognize UPC barcodes, but ReadBarCodes() also returns EAN barcodes.

To demonstrate this, I’ve included the following simple test app for .NET Framework (using Aspose.Barcode 22.9.0). Use it in combination with the attached BarcodeExamples_p2.jpg (400.3 KB) and make sure to change the path in the code to the image location.

using Aspose.BarCode.BarCodeRecognition;
using System;
using System.Collections.Generic;
using System.Drawing;

namespace TestBarcodeUpcEan
{
    class Program
    {
        static void Main(string[] args)
        {
            List<SingleDecodeType> BarcodeTypes = new List<SingleDecodeType> {
                DecodeType.UPCA, 
                DecodeType.UPCE
            };

            var bmp1 = new Bitmap("BarcodeExamples\\BarcodeExamples_p2.jpg");

            BarCodeReader reader = new BarCodeReader();
            using (reader)
            {
                reader.SetBarCodeImage(bmp1);

                reader.SetBarCodeReadType(BarcodeTypes.ToArray());
                reader.QualitySettings = QualitySettings.NormalQuality;

                var result = reader.ReadBarCodes();
                Console.WriteLine("Found {0} barcode(s)", result.Length);
                Console.WriteLine("");

                foreach (BarCodeResult barcode in result)
                {
                    Console.WriteLine("CodeType: " + barcode.CodeType);
                    Console.WriteLine("CodeText: " + barcode.CodeText);
                    Console.WriteLine("");
                }
            }
            Console.WriteLine("That's all!");
            Console.ReadKey();
        }
    }
}
Found 7 barcode(s)

CodeType: EAN13
CodeText: 451234567***Recognized by Aspose Barcode Reader evaluation version. Only Code39Standard can be recognized without restrictions. Please buy license to use Aspose Barcode Reader without watermarks.

CodeType: EAN13
CodeText: 993456789***Recognized by Aspose Barcode Reader evaluation version. Only Code39Standard can be recognized without restrictions. Please buy license to use Aspose Barcode Reader without watermarks.

CodeType: EAN13
CodeText: 979123456***Recognized by Aspose Barcode Reader evaluation version. Only Code39Standard can be recognized without restrictions. Please buy license to use Aspose Barcode Reader without watermarks.

CodeType: EAN13
CodeText: 978123456***Recognized by Aspose Barcode Reader evaluation version. Only Code39Standard can be recognized without restrictions. Please buy license to use Aspose Barcode Reader without watermarks.

CodeType: EAN13
CodeText: 978123456***Recognized by Aspose Barcode Reader evaluation version. Only Code39Standard can be recognized without restrictions. Please buy license to use Aspose Barcode Reader without watermarks.

CodeType: EAN13
CodeText: 977114487***Recognized by Aspose Barcode Reader evaluation version. Only Code39Standard can be recognized without restrictions. Please buy license to use Aspose Barcode Reader without watermarks.

CodeType: EAN13
CodeText: 979034524***Recognized by Aspose Barcode Reader evaluation version. Only Code39Standard can be recognized without restrictions. Please buy license to use Aspose Barcode Reader without watermarks.

That's all!

Why the EAN13s? I’ve set SetBarCodeReadType to UPCA and UPCE only, right?

Is this a regression of https://forum.aspose.com/t/incorrect-recognition-of-upc-vs-ean-barcodes/8528?

@docyard,

Thanks for the barcode image.

Please notice, after an initial test, I reproduced the issue as you mentioned using your barcode image. I have logged a ticket with an id “BARCODENET-38384” for your issue. We will look into your issue soon.

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

EAN13 is a superset of UPCA and it included all of UPC-A barcodes which starts from “0” (in UPCA 0 is cut and 12 digits are provided). In this way for most user requirement if we fail to recognize any of EAN-13 subsets (UPCA, ISMN, ISBN, ISSN) we try to decode it as EAN13. This behavior is required by most of users.

However, we could add to BarCodeReader.BarcodeSettings some option like StrictBarcodeType which does not allow to fail to superset barcode type if we cannot recognize the strict type of barcode.