Free SDK for scanning barcode (code 39 format) in iOS

眉间皱痕 提交于 2019-12-30 03:24:16

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/11340418/free-sdk-for-scanning-barcode-code-39-format-in-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!