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

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.

Related

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.

ZBarReader QR Code detection time

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.

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");
}

iPhone getting value to two different textfields from single method

Using the below code, the issue is I have two buttons and two textfields but I am getting the qrcode value using single method. How can i use it for two textfields
- (IBAction) keyScanButtonTapped
{
NSLog(#"TBD: scan barcode here...");
// 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;
// TODO: (optional) additional reader configuration here
// EXAMPLE: disable rarely used I2/5 to improve performance
[scanner setSymbology: ZBAR_I25 config: ZBAR_CFG_ENABLE to: 0];
// present and release the controller
[self presentModalViewController: reader animated: YES];
[reader release];
}
-(void) imagePickerController: (UIImagePickerController*) reader didFinishPickingMediaWithInfo: (NSDictionary*) info
{
// ADD: get the decode results
id<NSFastEnumeration> results = [info objectForKey: ZBarReaderControllerResults];
ZBarSymbol *symbol = nil;
for(symbol in results)
// EXAMPLE: just grab the first barcode
break;
// EXAMPLE: do something useful with the barcode data
deviceKey.text = symbol.data;
// EXAMPLE: do something useful with the barcode image
resultImage.image = [info objectForKey: UIImagePickerControllerOriginalImage];
// ADD: dismiss the controller (NB dismiss from the *reader*!)
[reader dismissModalViewControllerAnimated: YES];
}
Do you simply want to connect two different buttons to this same function? That is no problem just go into interface builder and connect both buttons to this method. You can see this question on how to connect buttons in interface builder
How can I connect "File's Owner" with a button in a Toolbar?
when the callback function is called you can identify which button called the function in such a manner
-(void)buttonPressed:(id)sender{
//find out which button was pressed
UIButton * pressed = (UIButton*) sender;
NSInteger tag = pressed.tag;
}
the tags are defined in the interface builder, just make sure that they are different for the two buttons and you are good to go.

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.