rmtmckenzie/flutter_qr_mobile_vision

iPhone 14 Pro focal length issue - can't scan small barcodes

lovelessX opened this issue ยท 5 comments

This seems to be specific to the iPhone 14 Plus in that Apple changed the lens/focal length. The library can't seem to scan particularly small barcodes anymore (they have to hold the barcode quite far away or use a magnifying glass).

I'm wondering about what the best fix would be. Perhaps a zoom function exposed?

hmm. One thought could be to use the ultrawide sensor; I'm pretty sure that it supports macro which seems like it would be great for that. Does the image preview just stay out of focus indefinitely? If that is the case, could you try editing the iOS code to use the UW sensor instead? (should be a simple change of this line: https://github.com/rmtmckenzie/flutter_qr_mobile_vision/blob/16506869352521adc33cf905ef0db53394de92f9/ios/Classes/QrReader.swift#LL152C84-L152C84). Unfortunately supporting choosing the camera is a larger bit of work than I'm willing to commit to getting done quickly although I'd definitely accept a PR for it - but there's some thought that would need to go into how that would even work. A simple fix could be to have a check for if the device has a UW sensor and use it if it does (although if it's possible to check if the UW sensor supports macro that would be even more ideal).

If the preview does look like it is in focus then another potential issue is that the image being taken isn't high enough resolution which could explain why small QRs in particular are failing. For the basic usage of the plugin I tried to use the size of the preview to determine which resolution of image to request from the sensor so that it uses less power/processing/etc, which works well when the scanner is close to being full screen, but when it isn't it can be problematic (something I should address eventually). I think I exposed the "targetWidth" and "targetHeight" properties in the lower-level classes in the plugin, and if you bumped that up it could potentially fix the issue. The "right" way to fix that would probably be to expose the resolutions to the dart code and let it choose which from there, but that's another big piece of work. A simple solution might be to just add a multiplier in which could make it choose a bigger size....

A last thing to try if the preview looks clear and the resolution is high enough is to make sure you're using the most recent iOS version of the barcode scanning library (you'll have to do a cocoapods update in your app's iOS folder for that). Maybe they would have added something in if iOS changed things, although this does sound to me like it probably isn't directly related to the library.

To clarify, it's actually the iPhone 14 Pro that was the issue because of the triple camera.

Here is a PR which fixes it: #220

I'm going to close this since the PR has been merged in. I'll do a release shortly including that.

Just wanted to follow up that I released the app update today and my users are reporting it did fix the problem.