如何在低分辨率预览配置文件中使用AVCaptureVideoDataOutput并以高分辨率拍摄照片(预览时)

时间:2013-03-05 17:46:01

标签: iphone objective-c avfoundation video-capture avcapturesession

我想使用AVFoundation Famework预览和拍摄照片。 我创建了AVCaptureSession并在此会话中添加了AVCaptureVideoDataOutputAVCaptureStillImageOutput。我将预设设置为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];

拍照:

//[cameraSession beginConfiguration];
//[cameraSession setSessionPreset:AVCaptureSessionPresetPhoto];  <-- slow
//[cameraSession commitConfiguration];
[cameraStillImage captureStillImageAsynchronouslyFromConnection:photoConnection completionHandler:^(CMSampleBufferRef imageDataSampleBuffer, NSError *error)
{
    ...
}];

我通过将预设更改为照片来尝试拍摄图像。但这非常慢(更改预设需要2-3秒)。我不想有这么大的延迟。

我该怎么做?感谢。

0 个答案:

没有答案
相关问题