用于在 iOS 中扫描条形码(代码 39 格式)的免费 SDK

问题描述 投票:0回答:1

我想使用iPhone/iPad的相机扫描Code 39格式的VIN条形码。我尝试了 zxing 和 zbar,但它们效果不佳。大多数时候他们无法识别条形码。谁能告诉我一个更好的方法来做到这一点?或者我可以做些什么来增加结果,因为我只需要扫描Code 39(对于VIN汽车)。

ios barcode scanning
1个回答
8
投票

使用 Zbar 来完成此操作。 为了获得足够的扫描分辨率,您需要以横向模式扫描条形码。这是我的设置(经过测试和工作)

// 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];

差不多应该可以了!祝你好运!

编辑/注意:从 iOS 7 开始,iOS 框架现在包含条形码扫描仪。我使用 此实现 比使用 Zbar 获得更好、更简单的结果。

© www.soinside.com 2019 - 2024. All rights reserved.