0

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.

enter image description here

enter image description here

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

Rahul Sharma
  • 3,013
  • 1
  • 20
  • 47
  • Does the blurred image move at all? It looks like the camera feed is frozen, possibly because the scanner has not been restarted successfully on the second invocation. Apologies if all that seems obvious. – Snips Sep 04 '12 at 08:06
  • No The camera feed works normally even on the second run but somehow its not able to focus and decode the subsequent scanned codes. Unlike the first scan I can neither see a sharp feed nor does it decode the new code – Rahul Sharma Sep 04 '12 at 10:18
  • That is weird... I'll post my code. – Snips Sep 04 '12 at 10:23

2 Answers2

0

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];
}
Snips
  • 6,575
  • 7
  • 40
  • 64
0

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.

Rahul Sharma
  • 3,013
  • 1
  • 20
  • 47
  • essential settings please elaborate your answer cause i also face same problem when real time barcode size is too small. – AJPatel Jan 16 '13 at 07:37
  • What I referred as Essential Settings meant I Removed all the references, cleaned all builds and then Reintegrated the sdk as mentioned in the Readme file and followed the example provided in ZBarSDk. In your comment what I find is that If its a issue with Small Sized Bar Codes and not the ZBarSDK Itself. – Rahul Sharma Jan 16 '13 at 08:36