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).
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.