micjahn / ZXing.Net

.Net port of the original java-based barcode reader and generator library zxing
Apache License 2.0
2.65k stars 661 forks source link

Recognizes the UPC_E format on the Qr_CODE #576

Open kkkaktusss opened 2 weeks ago

kkkaktusss commented 2 weeks ago

Hi. I use Zxing.Net together with OpenCV.V4. Convert from pdf file to Bitmap, and then from Bitmap to Mat and submit Mat to reader. I'm trying to decode the QR_CODE, but the reader only finds UPC_E. I tried to recognize it by the picture on the website zxing.org , but it doesn't find any barcode at all. Is there any way to fix it? The code and QR_CODE are attached below. 2024-06-18_19-14-51 2024-06-18_19-16-08 crop 2024-06-18_19-17-48

SanKumSan commented 2 weeks ago

Hello, Zxing tries to detect and decode barcode/qrcode/any other formats of the codes in your given Rectangle section.

Zxing detects something which is not barcode or qrcode but resembles or looks like barcodes or qrcodes. Can be text which resembles like barcode or b/w logo which might look like barcode for ZXing and others, and due to this it decodes something from this False Positive detection.

Try to draw what it has found and you will get more info on what it detected and decoded. NOTE : these are my observations found from using ZXing for Net.

Also, you could also use and try to decode again with MultiFormatReader, and not just Simple BarcodeReader.

var source = new BitmapLuminanceSource(bitmap);     
var binaryBitmap = new BinaryBitmap(new HybridBinarizer(source));
            var reader = new MultiFormatReader();
            var hints = new Dictionary<DecodeHintType, object>();
            hints.Add(DecodeHintType.TRY_HARDER, true);
            reader.Hints = hints;

            var scan = reader.decode(binaryBitmap, hints);
kkkaktusss commented 2 weeks ago

I tried this code, but it didn't help. Now reader has started to define the qar code as PHARMA_CODE. 2024-06-19_16-31-48

SanKumSan commented 1 week ago

Hello, If possible please share the image file and not just the rectangular section and I would try to decode and get back to you.

Also, post what exactly you want to decode from this, if you know what it contains and if not confidential.

kkkaktusss commented 1 week ago

There should be 5 fields in the QR_CODE. I am attaching the file below. forIssue.pdf

SanKumSan commented 1 week ago

Hello, I have tried to decode and decoded UPE_E value, and i think which is not correct.

  1. Check on how your pdf is generated.
  2. Check what kind of error correction is encoded with the QRcode .
  3. If it is converted from jpg/tiff to pdf then the compression in the image may cause decoding failure.