flutter-ml / google_ml_kit_flutter

A flutter plugin that implements Google's standalone ML Kit
MIT License
907 stars 709 forks source link

Barcode recognized as BarcodeType.Text instead of BarcodeType.driverLicense #639

Open basicFlutter opened 1 month ago

basicFlutter commented 1 month ago

I am using the "google_mlkit_barcode_scanning 0.12.0" Flutter package for Android to extract information from a driver's license barcode. However, when I scan my driver's license barcode, it is always recognized as BarcodeType.Text instead of BarcodeType.driverLicense. . and The barcode format is PDF-417.

google_mlkit_barcode_scanning: ^0.12.0 google_mlkit_commons: ^0.7.1 camera: ^0.11.0+1

flutter doctor Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.19.5, on macOS 14.4.1 23E224 darwin-x64, locale en-CA) [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 15.3) [✓] Chrome - develop for the web [✓] Android Studio (version 2023.2)

///##########################################

_controller = await CameraController(
        camera,
        ResolutionPreset.max,
        enableAudio: false,
        imageFormatGroup: Platform.isAndroid
            ? ImageFormatGroup.nv21
            : ImageFormatGroup.bgra8888,
      );
  final barcodeScanner = BarcodeScanner(formats: [BarcodeFormat.pdf417]);

///##########################################

Additional Information: I scanned the driver's license image using this website, and all the information was correctly returned. However, the same image scanned using google_mlkit_barcode_scanning: ^0.12.0 returns the format as text and does not provide the correct information.

fbernaly commented 1 month ago

Could you provide the test image? and the expected output?

basicFlutter commented 1 month ago

Thank you for your prompt reply. Unfortunately, I am unable to share an image of an actual driver's license due to privacy and legal restrictions. However, I have observed that barcodes generated using the Free AAMVA PDF417 Generator are recognized correctly by the google_ml_kit package. These generated barcodes are of very high quality.

The issue arises when scanning a real driver's license barcode, which is returned as BarcodeType.Text instead of BarcodeType.driverLicense. This discrepancy suggests that the quality of the barcode might be influencing the detection accuracy.

I noticed that someone else had a similar issue on Stack Overflow, and I tried the solution provided in that discussion, but unfortunately, it did not resolve the issue for me.

c-vlietstra commented 1 month ago

Good Evening I'm experiencing the same issue. When I scan the image it says its found one barcode, but there is no rawValue

I/flutter (20681): Barcodes found: 1 I/flutter (20681): BarcodeFormat.pdf417

rawBytes provide me the following: [1, 155, 9, 69, 0, 0, 19, 136, 22, 61, 204, 177, 89, 45, 222, 112, 237, 201, 106, 175, 252, 108, 236, 32, 68, 53, 167, 217, 0, 11, 246, 101, 195, 4, 43, 195, 29, 40, 43, 183, 123, 235, 244, 139, 58, 165, 236, 93, 4, 124, 234, 132, 64, 122, 32, 168, 239, 55, 239, 200, 235, 150, 165, 84, 210, 154, 121, 21, 134, 213, 105, 237, 26, 184, 3, 155, 120, 237, 177, 178, 209, 35, 30, 230, 145, 191, 11, 137, 72, 173, 181, 16, 157, 128, 55, 227, 92, 193, 126, 149, 216, 246, 50, 50, 28, 170, 166, 71, 157, 66, 210, 138, 50, 35, 115, 171, 80, 209, 249, 51, 40, 203, 130, 159, 31, 163, 198, 30, 76, 173, 248, 44, 204, 188, 158, 38, 97, 171, 247, 102, 64, 134, 18, 98, 53, 18, 209, 31, 248, 197, 132, 49, 118, 65, 246, 39, 54, 72, 16, 199, 233, 16, 117, 183, 143, 211, 131, 167, 213, 92, 232, 88, 20, 237, 252, 73, 136, 114, 242, 32, 137, 252, 73, 19, 152, 180, 49, 246, 74, 33, 75, 154, 248, 92, 57, 9, 146, 222, 40, 224, 70, 187, 62, 179, 192, 82, 102, 193, 211, 36, 38, 149, 17, 232, 228, 60, 241, 139, 197, 136, 118,

I'm trying to scan a South African driver license WhatsApp Image 2024-06-06 at 19 23 32_292eaf2a

github-actions[bot] commented 1 day ago

This issue is stale because it has been open for 30 days with no activity.