mintware-de / flutter_barcode_reader

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

Issues with camera resolution on HUAWAI Mate 8 #53

Closed Plateria closed 4 years ago

Plateria commented 6 years ago

When using the BarcodeScanner.scan() method on the Huawai Mate 8, the automatic resolution detection sets the resolution too low, so no barcodes are found. Is there a way to set the resolution manually?

Plateria commented 6 years ago

I now figured out, that it is possible to read barcodes in landscape mode on the Huawei Mate 8. Though i need it to read barcodes on either portrait, or landscape.

vuchl commented 6 years ago

Here is a link to the underlying explanation: https://github.com/dm77/barcodescanner#advanced-usage

vuchl commented 6 years ago

@matthewtsmith is there a way to pass arguemnts to the underlying implementation?

matthewtsmith commented 6 years ago

@vuchl We would need to add that support to the Dart API and pass it through the plugin channel. I don't currently have the time to add this but it should be a relatively easy feature to add if anyone is willing to take a crack at doing a PR.

vuchl commented 6 years ago

Is there some resource for what you are talking about? @matthewtsmith

matthewtsmith commented 6 years ago

There is a write up of how to use channels here: https://flutter.io/platform-channels/

My suggestion would be to add a ScanOptions class that gets passed into the scan method.

https://github.com/apptreesoftware/flutter_barcode_reader/blob/master/lib/barcode_scan.dart

Something like

class ScanOptions {
  bool flash;
  bool autoFocus;
  double aspectTolerance;
}

Then you would modify the scan method to accept those arguments.

BarcodeScanner.scan(ScanOptions(apsectTolerance: 0.5))

You would read in those options in the Kotlin and Objective-C code which you can see examples of in that guide.

Here are the relevant areas of code to start with in the native code:

Kotlin: https://github.com/apptreesoftware/flutter_barcode_reader/blob/master/android/src/main/kotlin/com/apptreesoftware/barcodescan/BarcodeScanPlugin.kt#L26

ObjC:

https://github.com/apptreesoftware/flutter_barcode_reader/blob/master/ios/Classes/BarcodeScanPlugin.m#L14

the class MethodCall has arguments that you can pull out anything you pass into it.

vuchl commented 6 years ago

I started a fork and toyed around a bit here: https://github.com/vuchl/flutter_barcode_reader/commits/master

But I have just made the edits in GitHub. I'll see if I can get this to work on PC at home. Unfortunately I can not check the iOS specific stuff and I am not sure if it would actually be needed at all.

devtronic commented 4 years ago

https://pub.dev/packages/barcode_scan/versions/3.0.0-dev.1