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];
}