ioscameraphotoavcapturesession

AVCaptureSessionPreset: why does standard iPhone camera save 2448 × 3264, if max preset is 1088x1920?


I'm writing small iOS app which uses camera. I use AVFoundation Framework API, and consider the maximal quality of AVCaptureSessionPreset. On my concrete device those are:
CaptureQualityPhoto = (640 852)
CaptureQualityHigh = (1088 1920)
CaptureQualityMedium = (368 480)
CaptureQuality1280x720 = (720 1280)
CaptureQuality640x480 = (480 640)
CaptureQualityiFrame960x540 = (540 960)

Standard camera app saves photos with resolution 2448 × 3264.
Say I want to save photos with the same resolution, but maximum quality I can achieve is 1088 x 1920.
Of course, I can resize UIImage, but is this the best approach?
Has standard app access to higher resolution or just uses some scaling and interpolation?

Edit: Now my working code with 2248x3264 photo preset looks like that:

-(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 ...  
}

Solution

  • You can get a maximum quality photo (4032 x 3024 on my phone) with AVCaptureSessionPresetPhoto and AVCaptureStillImageOutput:

    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")
    }