2012-07-05 39 views
6

我想使用iphone/ipad的相机扫描代码39格式的VIN条形码。我尝试了zxing和zbar,但它们不能很好地工作。大多数时候他们无法识别条形码。任何人都可以告诉我一个更好的方法来做到这一点?或者有什么我可以做的,以增加结果,因为我只需要扫描代码39(VIN车)。用于在iOS中扫描条形码(代码39格式)的免费SDK

+0

我的答案能解决您的问题吗? – Jeremie

回答

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的框架,现在包括为iOS的7我以前this implementation以获得更好的和更容易的结果比使用zbar和条形码扫描仪。

+1

它工作吗? – wod

+1

是的,它工作的很棒:)我有0个问题。 – Jeremie

+0

嗨,我使用相同的代码,但它不工作,我可以请你帮我 – Ravi