Mohamed Emad Hegab
Mohamed Emad Hegab

Reputation: 2675

iPhone : take photo with front camera programmatically

i want to take a picture programmatically by the front camera in my iphone app i don't want the user to pick or do any interaction with the image picker .. just want to take the image and save it in the document.. is that possible?

Upvotes: 7

Views: 6411

Answers (3)

Nishant Mahajan
Nishant Mahajan

Reputation: 264

try this--

   - (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];
                 }

Upvotes: 0

Peter Sarnowski
Peter Sarnowski

Reputation: 11970

EDIT: My bad, it seems you can actually do that from AVCaptureSession. Though I can't wrap my mind why should this be possible. Seems like a potential ground for abuse to me.

Original (wrong) answer: No, it is not possible to take photos without user interaction, no matter if it's the front or back camera.

Upvotes: 0

Nebary
Nebary

Reputation: 499

As I can understand from your question, AV Foundation is all you need. Look at this demo sources from Apple: AVCam

Upvotes: 8

Related Questions