Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use front camera for barcode scanning in ipod

I am using back camera to read bar code data...and it is scanning perfectly.Now I want to use front camera for this...How can I do this? Where should I make change?I have used ZBar bar code reader

my code is:

   - (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;
           // 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
                          resultText.text = symbol.data;
                          bid.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];
                     }
like image 933
Khushbu Shah Avatar asked Feb 11 '12 05:02

Khushbu Shah


People also ask

How do you scan a code with a front camera?

Google's Pixel can scan QR Codes. You don't even need Google Lens to do so. Open the camera app and point it to a QR Code and you will see the link appear just above the shutter button.

Can I scan QR code with front camera?

You can also scan QR Codes with your desktop, laptop or tablet. Several websites allow you to scan QR Codes through your webcam or front-facing camera. Hold up the QR Code in front of your device and the associated link will appear on the screen.

Can iPhone front camera scan QR codes?

Use the camera to read a QR code Open Camera, then position iPhone so that the code appears on the screen. Tap the notification that appears on the screen to go to the relevant website or app.


1 Answers

If I understand your question correctly, all you have to do is open your Camera to be in Front Mode instead of Rear Mode, so write this inside the method where you call the picker for the first time:

  picker.cameraDevice=UIImagePickerControllerCameraDeviceFront;

Hope this answers your question. If not, tell me.

like image 78
Karim Avatar answered Oct 06 '22 07:10

Karim