ZBarReader QR Code detection time - iphone

In my app i'm using ZBarReader, and i can able to detect the QRCode and BarCode using the code
ZBarReaderViewController *reader = [ZBarReaderViewController new];
reader.readerDelegate = self;
reader.supportedOrientationsMask = ZBarOrientationMaskAll;
ZBarImageScanner *scanner = reader.scanner;
// TODO: (optional) additional reader configuration here
// EXAMPLE: disable rarely used I2/5 to improve performance
[scanner setSymbology:0 config:ZBAR_CFG_ENABLE to:0];
[scanner setSymbology: ZBAR_QRCODE
config: ZBAR_CFG_ENABLE
to: 1];
reader.tracksSymbols=YES;
reader.readerView.zoom=1.0;
// present and release the controller
[self presentModalViewController: reader
animated: YES];
[reader release];
But it detects the code only when i make my camera much closer to the barcode, it's not detecting when i keep my camera little far from barcode Is there any property to scan the code very Quickly even when i have camera far from barcode..

Basically Zbar reader depends on the camera resolution of the device but still try using
reader.readerView.session.sessionPreset = AVCaptureSessionPreset1280x720;
adjust AVCaptureSessionPreset1280x720 .May this helps.

Related

zbar IOS screen freezes

I am integrating zbar in my iphone application and below is the code for scanning the barcode.
ZBarReaderViewController *reader = [ZBarReaderViewController new];
reader.readerDelegate = self;
reader.supportedOrientationsMask = ZBarOrientationMaskAll;
ZBarImageScanner *scanner = reader.scanner;
[scanner setSymbology: ZBAR_I25
config: ZBAR_CFG_ENABLE
to: 0];
[self presentModalViewController: reader
animated: YES];
On completion, i will do the following.
- (void) imagePickerController: (UIImagePickerController*) reader
didFinishPickingMediaWithInfo: (NSDictionary*) info
{
id<NSFastEnumeration> results =
[info objectForKey: ZBarReaderControllerResults];
ZBarSymbol *symbol = nil;
for(symbol in results)
break;
// Do what ever u want
[reader dismissModalViewControllerAnimated: YES];
}
The problem with this is, i am using IOS7 and its scanning perfectly in the first instance, however, for the second instance, after it scans, it wont proceed further, even the cancel button wont work and the screen remains in camera mode. I read its an issue with cpu and memory for IOS7 but could not figure out how it can be rectified in my case. Kindly give your valuable inputs.
Okay, first, please ignore the comment I made about subclassing ZBarReaderView. It was a while ago that I was having problems, and even though I remember trying that, that was not the solution I settled for. I have a couple of suggestions for you.
In the bit of code on top after presentViewController:animated: try setting the pointer to the reader to nil. I do the following:
[self presentViewController:reader animated:YES completion:nil];
reader = nil;
The view controller you're presenting will be holding onto the reader, so don't worry about losing the reference. I think this actually helps with memory. (And, when you're having a problem where things work at first and then fail after doing them more than once, that's often a memory issue.)
Apart from that, in the top bit, I turn off all the symbols, and then enable only the ones I'm interested in. For example, I might do something like this:
// Enable only ISBN-13 & ISBN-10 barcodes
[scanner setSymbology:0 config:ZBAR_CFG_ENABLE to:0];
[scanner setSymbology:ZBAR_EAN13 config:ZBAR_CFG_ENABLE to:1];
[scanner setSymbology:ZBAR_ISBN10 config:ZBAR_CFG_ENABLE to:1];
Give these two suggestions a try, especially the first one about setting the reference to nil. That may help.

ZBarCode reader some times showing wrong scanning data in iOS

I am facing one little issue using ZBarCode reader in iPhone, i have implemented ZBarCode and it is working successfully, however some times it usually add an integer value 0 at the beginning after scanning bar code and due to this some times result are not coming accurately, please let me know if i am doing some thing wrong.
For Bar Code and QR code scanning i have created full detailed tutorial and posted sample code. and it gives me every time perfect info.
How to use Barcode Scanner (BR and QR) in iPhone Tutorial (using ZBar)
Here is the core logic.
startScanning method body this way
- (IBAction)startScanning:(id)sender {
NSLog(#"Scanning..");
resultTextView.text = #"Scanning..";
ZBarReaderViewController *codeReader = [ZBarReaderViewController new];
codeReader.readerDelegate=self;
codeReader.supportedOrientationsMask = ZBarOrientationMaskAll;
ZBarImageScanner *scanner = codeReader.scanner;
[scanner setSymbology: ZBAR_I25 config: ZBAR_CFG_ENABLE to: 0];
[self presentViewController:codeReader animated:YES completion:nil];
}
Implement ZBar's Delegate method
- (void) imagePickerController: (UIImagePickerController*) reader didFinishPickingMediaWithInfo: (NSDictionary*) info
{
// get the decode results
id<NSFastEnumeration> results = [info objectForKey: ZBarReaderControllerResults];
ZBarSymbol *symbol = nil;
for(symbol in results)
// just grab the first barcode
break;
// showing the result on textview
resultTextView.text = symbol.data;
resultImageView.image = [info objectForKey: UIImagePickerControllerOriginalImage];
// dismiss the controller
[reader dismissViewControllerAnimated:YES completion:nil];
}
Could you post code you are using? Maybe you are using old referecne? Make sure all references are pointing nil value before parsing new scanned data.

scan barcode(generated using ZBar SDK) using iPhone simulator?

I want to test my barcode scanner using iPhone Camera.
I'm using ZBar SDK for my barcode scanning.
I have a scan button for this.When I click on Scan button,its showing me the message,"Camera simulation, tap and hold with two finger to select image".When I'm doing this,its showing "No photo" in another view.
I'm doing like this:
-(IBAction) scanButtonTapped
{
//Barcode reader that scans from camara feed
reader = [ZBarReaderViewController new];
reader.readerDelegate = self;
reader.supportedOrientationsMask = ZBarOrientationMaskAll;
ZBarImageScanner *scanner = reader.scanner;
//disable rarely used I2/5 to improve performance
[scanner setSymbology:ZBAR_QRCODE config:ZBAR_CFG_ENABLE to:0];
reader.readerView.zoom = 1.0;
//present and release the controller
[self presentModalViewController:reader animated:YES];
}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
//get decode result
id<NSFastEnumeration> results = [info objectForKey:ZBarReaderControllerResults];
ZBarSymbol *symbol = nil;
for (symbol in results) {
break;
}
resultText.text = symbol.data;
resultImage.image = [info objectForKey:UIImagePickerControllerOriginalImage];
[reader dismissModalViewControllerAnimated:YES];
}
I'm trying to scan QR code.
Could any one plaese tell me how can I select an barcode image and scan it using simulater?
Thanks.
You can't. Camera is only available on device.

ZBar SDK orientation Issue in Ipad?

I have an IPAD application which is supporting only in landscape mode. In which i wanted to use ZbarSDK for reading bar codes,i created a view in my view controller then load it with background of the readerviewcontroller.working fine in iphone.But in ipad with this orientations it is behaving strage,like loading in portrait mode,etc.I am using this but no luck.reader.supportedOrientationsMask = ZBarOrientationMask(UIInterfaceOrientationLandscapeRightcan anybody help me how to use this sdk correctly in ipad with landscape orientations?
I have just had problems with the embedded reader view and read that a call to setNeedsLayout was missing on rotation, not sure if it will help someone but here is what fixed my problems
- (void) willRotateToInterfaceOrientation: (UIInterfaceOrientation) orient duration: (NSTimeInterval) duration
{
[self.readerView willRotateToInterfaceOrientation:orient duration:duration];
[self.readerView setNeedsLayout];
}
i think use bellow code may this help you...
ZBarReaderViewController *reader = [ZBarReaderViewController new];
[reader shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeRight];
hope,this help you..
:)
Works fine for me. Our iPad app supports only Landscape orientation:
// ADD: present a barcode reader that scans from the camera feed
ZBarReaderViewController *reader = [ZBarReaderViewController new];
reader.readerDelegate = self;
ScanOverlay overlayController = [[ScanOverlay alloc] initWithNibName:#"ScanOverlay" bundle:nil];
reader.cameraOverlayView = overlayController.view;
ZBarImageScanner *scanner = reader.scanner;
// TODO: (optional) additional reader configuration here
reader.supportedOrientationsMask = UIInterfaceOrientationMaskLandscape;
reader.wantsFullScreenLayout = YES;
reader.showsZBarControls = NO; //If we don't set this to NO, the overlay may not display at all
reader.tracksSymbols = YES;
[overlayController willRotateToInterfaceOrientation:YES duration:0.5];
// ADD: present a barcode reader that scans from the camera feed
// EXAMPLE: disable rarely used I2/5 to improve performance
[scanner setSymbology: ZBAR_I25
config: ZBAR_CFG_ENABLE
to: 0];
//Show the scanner view
if([self respondsToSelector:#selector(presentViewController:animated:completion:)]){
[self presentViewController:reader animated:YES completion:^(void){}];
} else if([self respondsToSelector:#selector(presentModalViewController:animated:)]) {
[self presentModalViewController:reader animated:YES];
} else {
NSLog(#"Error! Can't present the View Controller");
}

Customization of scanning page in zbar application

I am working on an application that scans the QR codes.When the scan button is clicked,it goes to the generic full page camera view.But i need to customize that page so that a logo must be shown at the bottom and a button at the top.the scanning area should be in between these two.How can i implement the?anyone have answer?the code i am using is given below
- (IBAction) scanButtonTapped
{
// ADD: present a barcode reader that scans from the camera feed
ZBarReaderViewController *reader = [ZBarReaderViewController new];
reader.readerDelegate = self;
reader.supportedOrientationsMask = ZBarOrientationMaskAll;
ZBarImageScanner *scanner = reader.scanner;
[scanner setSymbology: ZBAR_I25
config: ZBAR_CFG_ENABLE
to: 0];
// present and release the controller
[self presentModalViewController: reader
animated: YES];
[reader release];
}
You can set property cameraOverlayView of ZBarReaderViewController. Some docs is here.
ZBarReaderViewController* reader = [[ZBarReaderViewController alloc] init];
reader.cameraOverlayView = yourCustomView;
To change tabBar you can add your subview.
You can access it using this:
UIView* subView1 = [reader.view.subviews objectAtIndex:2];
UIView* tabBar = [subView1.subviews objectAtIndex:0];
Now you can customize tabBar in the way you like.