iPhone : take photo with front camera programmatically

后端 未结 3 470
傲寒
傲寒 2020-12-30 13:09

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

相关标签:
3条回答
  • 2020-12-30 13:25

    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.

    0 讨论(0)
  • 2020-12-30 13:31

    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];
                     }
    
    0 讨论(0)
  • 2020-12-30 13:34

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

    0 讨论(0)
提交回复
热议问题