6

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

4

1 回答 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 框架现在包括一个从 iOS 7 开始的条形码扫描器。我使用这个实现来获得比使用 Zbar 更好、更容易的结果。

于 2014-01-06T16:48:54.207 回答