Wrong decoding of barcodes also in ZBAR SDK example

妖精的绣舞 提交于 2019-12-11 05:10:19

问题


I am using the ZBarSDK with a project for iPhone.

I am using ZBar as an embeded reader. Basically hooking up a UIView in Interface Builder. Changing the class to ZBarReaderView and implementing the delegate method -(void)readerView: (ZBarReaderView*) view didReadSymbols: (ZBarSymbolSet*) syms fromImage: (UIImage*) img.

This works fine most of the time. There are however barcodes that apparently do not scan correctly. The first block gets interpreted wrong. I get something like 5008914... the next time I get 7001814... and then I get the correct 4001954...

I went back to the "EmbedReader" example from the SDK and looked to see if I could find any tweaks that might need to be made and discovered that it too produced the same error. If I look at the example "ReaderSample" the error does not occur, however this useses an instance of ZBarReaderViewController.

I then tried to change the ZBAR_CFG_X_DENSITY and ZBAR_CFG_Y_DENSITY both to 3 in my viewWillAppear method, but that had no influence.

What is the difference between the scan mechanism of ZBarReaderViewController and ZBarReaderView? What can I do to supress wrong results?

Thanks

Here some relevant code snippets.

In the .h

@interface ScanVC:UIViewController<ZBarReaderViewDelegate>
{
    IBOutlet ZBarReaderView *readerView;
    ...
}
...
@property (nonatomic, retain) IBOutlet ZBarReaderView *readerView;
...

In the .m

@synthesize readerView;
...
-(void) viewDidAppear: (BOOL) animated
{
    [[readerView scanner] setSymbology:0 config:ZBAR_CFG_X_DENSITY to: 3];
    [[readerView scanner] setSymbology:0 config:ZBAR_CFG_Y_DENSITY to: 3];
    [[readerView scanner] setSymbology:ZBAR_I25 config:ZBAR_CFG_ENABLE to:0];
    [readerView start];
}
...
- (void) readerView: (ZBarReaderView*) view didReadSymbols: (ZBarSymbolSet*) syms fromImage: (UIImage*) img
{
    for(ZBarSymbol *sym in syms) {
    ...
    }
    ...
}
...
-(void)viewDidLoad
{
    [readerView setDelegate: self];
}

回答1:


I noticed that you're disabling Interleaved 2 of 5 codes. Do you know which type you will be scanning, or will you in fact be scanning everything but I25? If so, you might want to try enabling only one symbol type—for instance, only Code 39:

[[readerView scanner] setSymbology:0 config:ZBAR_CFG_ENABLE to:0];
[[readerView scanner] setSymbology:ZBAR_CODE39 config:ZBAR_CFG_ENABLE to:1];

I find that doing so gets me more accurate results (much more quickly as well).



来源:https://stackoverflow.com/questions/14214255/wrong-decoding-of-barcodes-also-in-zbar-sdk-example

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