我想使用iphone / ipad的相机扫描Code 39格式的VIN条形码。我尝试过zxing和zbar,但它们效果不好。大多数时候他们无法识别条形码。有人能告诉我一个更好的方法吗?或者我可以做些什么来增加结果,因为我只需要扫描Code 39(用于VIN汽车)。
答案 0 :(得分:7)
使用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框架现在包含条形码扫描器。我使用this implementation获得比使用Zbar更好更容易的结果。