相机需要很长时间才能在iPhone中捕捉图像

时间:2016-01-29 05:51:52

标签: ios objective-c camera avfoundation

我正在开发一款包含相机功能的应用程序,用户可以一个接一个地捕获多达5张图像。我正在使用avfoundation捕获多个图像,所有东西都正常工作但只有问题是当我点击捕获时按钮,需要大约5秒才能捕获,任何研究都可以帮助我,如果我错了吗?我的代码如下。

        AVCaptureSession *session = [[AVCaptureSession alloc] init];
         [session beginConfiguration];
        session.sessionPreset = AVCaptureSessionPresetPhoto;
-(void)takePhoto :(UIViewController *)sender
{

    if ([CustomCamera isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
    {

        currentPicker = self.picker;
        self.picker.sourceType = UIImagePickerControllerSourceTypeCamera;
        if (self.mediatype == VIDEOTYPE)
        {

            self.picker.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeMovie];
            self.picker.videoQuality = UIImagePickerControllerQualityTypeMedium;
            self.picker.videoMaximumDuration = 180.0f;
        }
        else{

                //self.multipleImagePicker = [[RPMultipleImagePickerViewController alloc] init];
                self.multipleImagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
                self.multipleImagePicker.delegateCaptureImage = self;
                self.picker.delegate = self;
                self.picker.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeImage];
                self.picker.showsCameraControls = NO;
                self.picker.navigationBarHidden = YES;
                self.picker.toolbarHidden = YES;
                [self setCameraOverlayView];

            //Added by jigar...
                camOverLayView.view.alpha = 0.0f;
                self.picker.cameraOverlayView = camOverLayView.view;
                [UIView beginAnimations:nil context:NULL];
                [UIView setAnimationDelay:2.2f];
                camOverLayView.view.alpha = 1.0f;
                [UIView commitAnimations];

            //setting delay to capture screen

        }
        [self presentViewController:self.picker animated:YES completion:nil];
    }
    else
    {
        UIAlertView *alert =[[UIAlertView alloc] initWithTitle:nil message:@"No Camera Available in Device" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
        [alert show];
    }


}

0 个答案:

没有答案