mintware-de / flutter_barcode_reader

A flutter plugin for reading 2D barcodes and QR codes.
MIT License
628 stars 464 forks source link

[Bug] Barcode detected as EAN13 not UPC #255

Closed steve28100 closed 4 years ago

steve28100 commented 4 years ago

BUG REPORTS WITHOUT PROVIDING THESE INFORMATIONS WILL BE CLOSED DIRECTLY. DON'T REMOVE THE SECTIONS!

Describe the bug Hello, I am trying this plugin to scan the barcode, it works fine in Android when using without options. The result is like this:

I/flutter ( 7122): Barcode
I/flutter ( 7122): 028190009849
I/flutter ( 7122): unknown
I/flutter ( 7122): UPC_A

However I need to restrict the barcode type so I give the options like this:

 var options = ScanOptions(restrictFormat: [
      BarcodeFormat.unknown,
      BarcodeFormat.ean13
    ]);
    var result = await BarcodeScanner.scan(options: options);

    print(result.type); // The result type (barcode, cancelled, failed)
    print(result.rawContent); // The barcode content
    print(result.format); // The barcode format (as enum)
    print(result
        .formatNote); // If a unknown format was scanned this field contains a note

However the result now is changed into EAN-13, it should be detected as UPC_A same like with no options.

flutter: Barcode
flutter: 0028190009849
flutter: ean13
flutter:

Also in IOS the barcode is always detected as EAN13 not UPC.

To Reproduce Steps to reproduce the behavior:

  1. Add the options code in barcode scan
  2. Scan the barcode image
  3. Check the result

Expected behavior It should be show as UPC_A Format

Screenshots This is the image of barcode: WhatsApp Image 2020-05-19 at 3 29 20 PM (1)

Logs Second Result after restricted:

flutter: Barcode
flutter: 0028190009849
flutter: ean13
flutter:

Environment (please complete the following information):

Additional context This is the result using online site barcode reader,it shows correct value and format:

barcode_result
devtronic commented 4 years ago

EAN13 is compatible to UPC. On iOS the default AVFoundation barcode detection is used. I think we don't have a chance to fix this "problem". You can restrict the barcode formats in the scan options and exclude ean13 if you need to scan this type of codes as UPC.

samo92 commented 3 years ago

If i exclude ean13 the app dont scan anything.