ZBar API Embedded Scanner Blur issue

∥☆過路亽.° 提交于 2019-12-08 10:44:53

问题


I am using ZBar iPhone SDK in one of my projects (iOS SDK 5.1 ,XCode 4.4.1 and device running iOS 5.5.1). I am using the embedded scanner from the examples provided in the SDk itself.

Now the issue which I am facing is that I successfully scan a bar code and move to another view controller ( using navigation controller). When I come back (pop the second view controller) the scanner i.e the ZBarReaderView doesn't scan the subsequent bar codes , infact the overlay shows a blur image of the scanned barcode and is never able to scan it properly.

This is what all I have implemented . In BarScannerViewController.h I have declared

ZBarReaderView*             readerView;

with property

@property (nonatomic , retain)    IBOutlet UIImageView* imgvScannedBarCode;

Now this is connected to one of the views in xib.

Finally I use set up the required methods as follows -

- (void)viewDidLoad {
    [super viewDidLoad];

    // the delegate receives decode results
    readerView.readerDelegate = self;
    [readerView start];
}


- (void) viewDidAppear: (BOOL) animated {
    // run the reader when the view is visible
    [activityIndicatorScanning startAnimating];
    [readerView start];
}

- (void) viewWillDisappear: (BOOL) animated {
    [activityIndicatorScanning stopAnimating];
    [readerView stop];
}

With all this set up when I scan any bar code say EAN123 for the first time I get the call back in

- (void) readerView: (ZBarReaderView*) view
     didReadSymbols: (ZBarSymbolSet*) syms
          fromImage: (UIImage*) img
{
    // do something useful with results
    ZBarSymbol *symbol = nil;
    for(symbol in syms) {
        barCodeFound = YES;
        break;
    }
    // EXAMPLE: do something useful with the barcode data
    NSLog(@"%@",symbol.data);
}

but on subsequent runs (After I push a view and come back on this screen again) I get blurred view.

Am I missing something here ? Any help/Suggestion/Comments would be helpful.


回答1:


Here's the code that I use to start (and endlessly restart) the scanner. Interestingly, I note that I never stop the scan, but it works very reliably.

- (void) startScan
{
    ZBarReaderViewController *reader = [ZBarReaderViewController new];

    reader.readerDelegate = self;

    ZBarImageScanner *scanner = reader.scanner;

    [scanner setSymbology: ZBAR_I25
                   config: ZBAR_CFG_ENABLE
                   to: 0];

    // present and release the controller
    [self presentViewController:reader animated:YES completion:nil]; // Modal
    [reader release];
}



回答2:


I could solve the Blur issue by reconfiguring the SDK in my project. I followed the embedded scanner example as provided on ZBarSDk. I guess I might have missed some essential settings while configuring it earlier.



来源:https://stackoverflow.com/questions/12257995/zbar-api-embedded-scanner-blur-issue

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