I want to scan a VIN barcode, which in Code 39 format, using the camera of iphone/ipad. I tried zxing and zbar, but they don't work well. Most of time they can not recognize the barcode. Can anyone show me a better way to do that? or is there anything I can do to increase the result, because I only need scanning Code 39 (for VIN car).
Asked
Active
Viewed 3,712 times
1 Answers
8
use Zbar to accomplish this. In order to get enough resolution to scan, you will want to scan the barcode in landscape mode. Here are my settings (tested & working)
// ADD: present a barcode reader that scans from the camera feed
ZBarReaderViewController *reader = [ZBarReaderViewController new];
reader.readerDelegate = self;
reader.supportedOrientationsMask = ZBarOrientationMaskAll;
ZBarImageScanner *scanner = reader.scanner;
//disable other codes to improve performance
[scanner setSymbology: 0
config: ZBAR_CFG_ENABLE
to: 0];
[scanner setSymbology:ZBAR_CODE39 config:ZBAR_CFG_ENABLE to:1];
//only scan vertically, in the middle of the screen (also improves performance)
[reader setScanCrop:CGRectMake(0, 0.4, 1, 0.2)];
[reader setShowsZBarControls:NO];
[reader setShowsHelpOnFail:NO];
//VERY IMPORTANT: reset zoom. by default, the screen is partially zoomed in and will cause a loss of precision
reader.readerView.zoom = 1.0;
reader.readerView.allowsPinchZoom=NO;
reader.readerView.showsFPS=YES;
reader.readerView.tracksSymbols=YES;
//scan landscape only (this also improves performance)
[scanner setSymbology:ZBAR_CODE39 config:ZBAR_CFG_X_DENSITY to:0];
[scanner setSymbology:ZBAR_CODE39 config:ZBAR_CFG_Y_DENSITY to:1];
That should pretty much do it! Good luck!
Edit/Note:the iOS framework now includes a barcode scanner as of iOS 7. I used this implementation to get better and easier results than using Zbar.

Jeremie D
- 4,145
- 1
- 35
- 41
-
-
sure, can you put up a link to your code, describe which version of xcode you are using, device, and version of zbar?I'm going to take a shot in the dark and assume you are using the wrong version of zbar for the ios. if you are using ios use this version: http://www.nerdvision.net/app-development/ios/zbar-sdk – Jeremie D Apr 20 '14 at 12:46
-
@Ravan you can also use this version if the nerdvision doesnt work: (I also built for iphone 5,sim, etc https://db.tt/SBiNwrmZ – Jeremie D Jul 03 '14 at 18:25
-
1I was encountering issue with increasing memory over 100Mb after some scans. https://db.tt/SBiNwrmZ doesn't work, http://www.nerdvision.net/app-development/ios/zbar-sdk helped me. – M.Y. Sep 05 '14 at 09:01
-
-
@Jeremie Its not detect vin number and I think its convert to 2D barcode number, correct? please comment. – Nikunj Jadav Apr 28 '15 at 10:49