BarcodeScanner icon indicating copy to clipboard operation
BarcodeScanner copied to clipboard

IOS not fullscreen: very hard to scan CODE_39 codes

Open DURK opened this issue 10 years ago • 23 comments

Using: latest barcodescanner (0.6.0) Devices: tested on iPhone5 and iPad2 (both iOS6)

I'm having the issue where my Android devices are able to scan rather long barcodes (CODE_39), even from quite a distance, but iOS devices aren't.

I'm building my app through the Phonegap Build API, with the following line in config.xml: <gap:plugin name="com.phonegap.plugins.barcodescanner" version="0.6.0" />

I think the problem is that the scanner window is smaller compared to previous versions. This means you have to keep your device farther away, making it very hard for the system to recognise the code. An older version of the barcode scanner filled the screen and recognised the same codes right away.

Old (working): Image New (not working): Image

Any ideas what's wrong here?

DURK avatar Jul 29 '13 12:07 DURK

I can confirm Code 39 does not work on iOS. I opened an issue on this about 2 months ago. I originally thought Code 39 was not supported as the iOS documentation did not state that it was. wildabeast then showed me that Code 39 is supported via code and he updated the iOS documentation to reflect such. It did not work < 0.6.0 and it does not work 0.6.0.

wjchristenson2 avatar Sep 11 '13 20:09 wjchristenson2

I just generated a basic Code 39 barcode here, and was able to scan it successfully with this plugin, so I don't think the problem is a lack of support for Code 39 -- I think its a problem with the camera and/or scanner library processing high density barcodes. For example, using the above website, a simple 7 digit Code 39 barcode scans successfully, while it seems to have trouble with 10+ digits.

@DURK I also don't believe the green overlay actually defines the boundaries of the scanning area -- I think it is simply a guide and the processing library would likely process the entire visible area (I've scanned barcodes while they extended outside of the border).

Note that this plugin is primarily a wrapper around a third party library. Its possible that updating the code from that project will improve things, but thats a shot in the dark.

wildabeast avatar Sep 11 '13 22:09 wildabeast

Also @DURK, if the old version did in fact work for you, any reason why you wouldn't just use that version? Any idea what version that was?

wildabeast avatar Sep 11 '13 22:09 wildabeast

Thanks wildabeast for your input. The 10+ characters makes sense and that's where my problem must be. I am trying to use the plugin to scan vehicle VIN number barcodes which are 17 alpha-numeric characters in length.

wjchristenson2 avatar Sep 11 '13 23:09 wjchristenson2

@wildabeast, Are there any plans to support high density code_39 barcodes with 10+ characters on iOS (In my case, vehicle VIN barcodes - 17)? As mentioned before, it works on Android. I just upgraded our Cordova to 3.0 and the Barcode Scanner plugin to 0.7.0 and I tested again with no luck.

If not, any direction you can give to assist me with doing it myself would be much appreciated. Thanks!

wjchristenson2 avatar Sep 30 '13 15:09 wjchristenson2

I also confirm Code 39 does not work on iOS.

wenhsiaoyi avatar Sep 30 '13 15:09 wenhsiaoyi

@wjchristenson2 as mentioned above, this plugin utilizes a third party library for all the heavy lifting around image / barcode processing. So any upgrades to those algorithms aren't in the roadmap.

As mentioned before, a shot in the dark will be to upgrade the scanning library used by the plugin to the latest code, in the hopes that improvements have been made.

wildabeast avatar Sep 30 '13 22:09 wildabeast

Might be relevant to this discussion: I've tested this on an iPad (revision 3, with iOS 7), with a 5MP camera.

On this set up, Code 39 does work, but only at large sizes - at minimum of 6mm per character, 8mm or higher per character for more reliability. So for your 10 char barcode you'd need it to be at least 6cm (2.4 inches) wide.

The same app running on a Samsung Android with 13MP camera could scan Code 39 at 2mm per character, 2.5 or higher for reliability. (So 2cm or 0.8in for the 10 chars).

The iPhones now have an 8MP camera. I didn't have one to use in my tests, but would guess the minimum sizes would be around 4/5 mm per char.

As @wildabeast says, the underlying scanning library determines what formats are supported, but seeing as Code39 is pretty simple and well established, I'd guess that it's supported across most devices.

Image stabilisation and decent auto-focus would help, but for small barcodes you basically just need a higher resolution camera. (...or make your barcodes bigger if possible).

These linear barcodes were designed for use with short wavelength light beams. 2D barcodes, like QR codes, were developed for optical recognition and avoid the banding/blurring issues you get with the narrow, high density lines.

karljacuncha avatar Feb 18 '14 10:02 karljacuncha

Unfortunately, we are working with vehicle VIN barcodes. We have no control over how the barcodes are printed. So for iOS, we are SOL at the moment.

wjchristenson2 avatar Feb 18 '14 13:02 wjchristenson2

Has anyone figured out how to scan VIN barcodes on iOS, or can suggest a work around?

Ank13 avatar Mar 25 '14 20:03 Ank13

Scanning VIN's with Droid isn't much better... I'd also like to know of any possible workaround? Thanks

tinnocente avatar Mar 26 '14 02:03 tinnocente

Code 39 actually works, but - as mentioned in #95 - the codes need to be short (less then 10 characters). I'm assuming the same problem is with VIN barcodes as they are very long. So it seems to be a problem of iOS version in that it only uses vertical view and so effectively scans less pixels.

Eccenux avatar Mar 29 '14 20:03 Eccenux

Agree. The issue seems to be that on the iOS version the scanner defaults to portrait/vertical mode and long CODE_39 bar codes, such as the 17-digit VIN, might work if the scanner was in landscape/horizontal mode.

Based on this StackOverflow (http://stackoverflow.com/questions/10945976/zxing-barcode-scanner-phonegap-plugin-ios-landscape-mode), it seems this could be fixed by deleting from zxing-all-in-one.cpp this section: if (result.empty() && hints.getTryHarder() && image->isRotateSupported()) {}

I don't write cpp (hence using PhoneGap)... can anyone verify this would work and enter a pull request?

Ank13 avatar Apr 07 '14 16:04 Ank13

@wjchristenson2, did you find a workaround to make +10 digits CODE_39 working?

BC17 avatar Jul 02 '14 09:07 BC17

@BC17 I did not find a workaround. I've not had time to dig into the iOS code to see if I could hack it. I'd love it if someone resolved this though! Currently I'm hiding the VIN scan feature for iOS devices... that's my workaround for now until a fix comes out. /sigh

wjchristenson2 avatar Jul 02 '14 18:07 wjchristenson2

did you try to force landscape mode with some plugin like screenOrientation ?

BC17 avatar Jul 02 '14 21:07 BC17

Has there been any progress on this issue? It would appear that, according to DURK, this feature did work at one time.

rdwebdevel avatar Aug 12 '14 19:08 rdwebdevel

Still can't scan 17 character vehicle barcodes (CODE_39) and it doesn't matter if I use a 20Mpix Sony Android or iPhone 5S. Other apps I have tested works fine so what's the problem to get this scanner to work?

appnewbie avatar Sep 21 '14 18:09 appnewbie

I have the same problem. The plugin does not work on iOS 7. I have implemented a hybrid application for iOS and Android. Android application is OK. IOS application does not read the barcode. Has anyone solved the problem? is there a working example? I tested these two versions but neither works on iOS:

https://github.com/wildabeast/BarcodeScanner https://github.com/Ornitorrinko/BarcodeScanner

fabiostrada1977 avatar Dec 04 '14 08:12 fabiostrada1977

Seems to me, that the problem I'm having is that the camera just can't focus in close enough to read the smallest lines. Instead, sometimes it will output the wrong code tupe and the wrong number. But if I print the code out, and big enough, it reads Code_39 just fine... Anyway to tap the screen to focus the camera?

ascendedmasta avatar Feb 05 '15 21:02 ascendedmasta

I solved this by changing CDVBarcodeScanner.mm file slightly. I changed the value AVCaptureSessionPresetMedium to AVCaptureSessionPresetHigh. It is used in two places, so just do a find and replace. It now picks up every barcode with ease.

mclhrn avatar Jul 16 '15 21:07 mclhrn

@mclhrn Thanks sooo much.

rakeshrockb avatar Sep 24 '15 03:09 rakeshrockb

@mclhrn Perfect! Thanks dude!

jacksonrdlc avatar Jan 28 '16 13:01 jacksonrdlc