jhoogstraat / fast_barcode_scanner

A flutter plugin that allows your users to scan any type of barcode on iOS and Android
41 stars 53 forks source link

[iOS] Scanner is very bad at detecting horizontal barcodes on arched objects like bottles #68

Open AKortak opened 2 years ago

AKortak commented 2 years ago

I noticed, that the scanner is not able to detect horizontal barcodes on arched objects with an iPhone. On Android it works perfectly fine but on iOS it sometimes is impossible to detect a barcode. I use the scanner in my production code and I would be very happy if this is fixxed fast.

This image shows an example of an object where it is very hard to scan the barcode:

IMG_20220215_133130 2195

jhoogstraat commented 2 years ago

The heavy lifting of actually extracting the barcode information from the image is not done by this plugin. This plugin uses AVFoundation by Apple for this task.

The (newer) Vision Framework can also scan barcodes and is already implemented into the plugin. Maybe it works better in edge cases because its based on machine learning, instead of manually coded algorithms. As soon as #66 is merged, you will be able to switch between the two implementations.

dustin-graham commented 2 years ago

@AKortak , I encountered the same issues while working on this plugin. Here's the summary of what I learned:

The current implementation of barcode scanning @jhoogstraat mentioned is AVFoundation. AVFoundation has a documented limitation for lnear barcodes where it will only recognize them if the barcode is exactly in the center of the screen. This took me a comically long time to discover and I was able to find old documentation from Apple which confirms it.

As @jhoogstraat pointed out, my PR #66 provides you the option to switch to the new Vision API for scanning. The Vision API does a fantastic job with linear barcodes regardless of where they appear on the screen. Hopefully we'll get this merged soon and you can enjoy the new implementation.

Cheers.

rsi2m commented 2 years ago

@dustin-graham great job on that PR #66 ! Looking forward to test it out once it's merged!