Wrong decoding of barcodes also in ZBAR SDK exampl

2019-08-05 00:28发布

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条回答
Ridiculous、
2楼-- · 2019-08-05 00:42

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).

查看更多
登录 后发表回答