mikebuss / MTBBarcodeScanner

A lightweight, easy-to-use barcode scanning library for iOS 8+
MIT License
1.09k stars 197 forks source link

Are white-on-black 2D barcodes supposed to be recognized? #56

Closed winzig closed 8 years ago

winzig commented 8 years ago

We're scanning VIN barcodes, both 1D and 2D, so I set the MTBBarcodeScanner to scan for types: AVMetadataObjectTypeCode39Code, AVMetadataObjectTypeCode128Code, AVMetadataObjectTypeDataMatrixCode.

In my testing, it doesn't seem like white-on-black 2D barcodes are supported currently, though 1D barcodes seem to work well either black-on-white or white-on-black.

Is this expected behavior? The only reason I'm not 100% sure is because the one 2D barcode I have that's white-on-black also has the issue of not being 100% easily visible, so I'm not positive where the issue is.

If it's a known problem, are there any thoughts on how we might try to scan white-on-black 2D barcodes? I know this library is relying on Apple's built-in decoding (at least, last time I looked through the source code), but was thinking perhaps there's a way to internally try scanning a few frames of video after inverting the colors, to try and catch edge cases like this?

mikebuss commented 8 years ago

I haven't encountered this before, unfortunately. One thing you might try is dropping down to using AVFoundation directly (there are a few examples on the web, I believe) and seeing if the issue still exists. If it does, you might file a radar so Apple can take a look.

It's a solid bet if it doesn't work in MTBBarcodeScanner it won't work in AVFoundation because it's just a thin wrapper, but I'm not sure if Apple will accept the entire MTBBarcodeScanner source in a radar. You're welcome to try using the sample project, though!

mikebuss commented 8 years ago

I'm going to close this, since it doesn't seem to be specific to MTBBarcodeScanner. Please let me know if you're able to get around this issue using AVFoundation directly, and I will bake it into the library.