Bas*_*stl 5 iphone video-capture objective-c avfoundation avcapturesession
我想用它AVFoundation Famework来预览和拍摄照片.我创建了一个AVCaptureSession和添加AVCaptureVideoDataOutput,AVCaptureStillImageOutput本届会议.我将预设设置为AVCaptureSessionPresetLow.
现在我想以全分辨率拍摄照片.但在captureStillImageAsynchronouslyFromConnection分辨率内与我的预览代表相同.
这是我的代码:
AVCaptureSession* cameraSession = [[AVCaptureSession alloc] init];
cameraSession.sessionPreset = AVCaptureSessionPresetLow;
AVCaptureVideoDataOutput* output = [[AVCaptureVideoDataOutput alloc] init];
[cameraSession addOutput:output];
AVCaptureStillImageOutput* cameraStillImage = [[AVCaptureStillImageOutput alloc] init];
[cameraSession addOutput:cameraStillImage];
// delegation
dispatch_queue_t queue = dispatch_queue_create("MyQueue", NULL);
[output setSampleBufferDelegate:self queue:queue];
dispatch_release(queue);
[cameraSession startRunning];
Run Code Online (Sandbox Code Playgroud)
拍照:
//[cameraSession beginConfiguration];
//[cameraSession setSessionPreset:AVCaptureSessionPresetPhoto]; <-- slow
//[cameraSession commitConfiguration];
[cameraStillImage captureStillImageAsynchronouslyFromConnection:photoConnection completionHandler:^(CMSampleBufferRef imageDataSampleBuffer, NSError *error)
{
...
}];
Run Code Online (Sandbox Code Playgroud)
我通过将预设更改为照片来尝试拍摄图像.但这非常慢(更改预设需要2-3秒).我不想有这么大的延迟.
我怎样才能做到这一点?谢谢.