我正在编写使用相机的小型iOS应用。我使用AVFoundation Framework API,并考虑AVCaptureSessionPreset的最高质量。在我的具体设备上,这些是:CaptureQualityPhoto = (640 852)CaptureQualityHigh = (1088 1920)CaptureQualityMedium = (368 480)CaptureQuality1280x720 = (720 1280)CaptureQuality640x480 = (480 640)CaptureQualityiFrame960x540 = (540 960)
标准相机应用程序以2448 × 3264分辨率保存照片。
假设我想以相同的分辨率保存照片,但是可以达到的最大质量是1088 x 1920。当然,我可以调整UIImage的大小,但这是最好的方法吗?标准应用程序可以访问更高分辨率吗?还是仅使用一些缩放和插值?

编辑:
现在,我使用2248x3264照片预设的工作代码如下所示:

-(void) initCapturingDevice
{
    [self releaseCapturingDevice];

    self.capture_session = [[AVCaptureSession alloc] init];
    [self.capture_session beginConfiguration];

    self.video_data_output = [[AVCaptureVideoDataOutput alloc] init];
    self.video_data_output.videoSettings = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:kCVPixelFormatType_32BGRA] forKey:(id)kCVPixelBufferPixelFormatTypeKey];
    [self.video_data_output setSampleBufferDelegate:self queue:dispatch_get_main_queue()];
    [self.capture_session addOutput:self.video_data_output];

    self.capture_session.sessionPreset = AVCaptureSessionPresetPhoto;
    // some code here ...
}

最佳答案

您可以使用AVCaptureSessionPresetPhotoAVCaptureStillImageOutput获得最高质量的照片(手机上为4032 x 3024):

let captureDevice = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo)
let input = try! AVCaptureDeviceInput(device: captureDevice)

captureSession.addInput(input)
captureSession.sessionPreset = AVCaptureSessionPresetPhoto

let stillImageOutput = AVCaptureStillImageOutput()
captureSession.addOutput(stillImageOutput)

captureSession.startRunning()

let connection = stillImageOutput.connectionWithMediaType(AVMediaTypeVideo)
stillImageOutput.captureStillImageAsynchronouslyFromConnection(connection) { (sampleBuffer, error) in
    print("maximum quality photo: \(sampleBuffer)\n")
}

关于ios - AVCaptureSessionPreset:如果最大预设为1088x1920,为什么标准的iPhone相机会保存2448×3264?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34453030/

10-14 11:48