AVCaptureSession is not giving a good photo quality and good resolution

前端 未结 3 536
粉色の甜心
粉色の甜心 2021-02-02 14:44

I\'m working with AVCaptureSession for capturing the image. Its working fine but not giving a good resolution. I compared it with the image captured by iPhone Came

相关标签:
3条回答
  • 2021-02-02 14:48

    When using the preset AVCaptureSessionPresetPhoto with an AVCaptureStillImageOutput, I'm able to capture images on an iPhone 4S at a resolution of 3268x2448, which is the exact same resolution that the built-in camera application yields. The same is true for the iPhone 4, Retina iPad, etc., so if you use that preset with a still image input, you will get a sample buffer back from -captureStillImageAsynchronouslyFromConnection:completionHandler: that is the native camera resolution.

    In regards to photo quality, remember that the built-in camera application has the ability to capture high-dynamic-range (HDR) photos by the quick acquisition of images at different exposure levels. We do not have access to this via the standard AV Foundation APIs, so all we get is one image at a defined exposure level.

    If you turn HDR off, the image quality looks identical to me. Here is a zoomed-in portion of a photo captured using an AVCaptureStillImageOutput:

    AVCaptureStillImageOutput image

    and here is one from the built-in photo application:

    Built-in Photos image

    Ignoring the slight differences in lighting due to a little shift in camera direction, the resolution and fidelity of images captured both ways appear to be the same.

    I captured the first image using the SimplePhotoFilter example application from my open source GPUImage framework, replacing the default GPUImageSketchFilter with a GPUImageGammaFilter that didn't adjust the gamma any, just acted as a passthrough.

    0 讨论(0)
  • 2021-02-02 14:56

    We had the same issue using that code reference. The photos were especially bad using the iPad front facing camera.

    We fixed it by adding a 1 second delay between setting up the capture manager and calling the capture image method. It made a big enough difference to us that we were happy with the result. It appears that the camera needed some time to open the shutter and perform the auto-focus / white-balancing default options.

    [NSTimer scheduledTimerWithTimeInterval:1.0 
        target:self.captureManager 
        selector:@selector(captureStillImage) 
        userInfo:nil repeats:NO];
    
    0 讨论(0)
  • 2021-02-02 14:59

    Just add this line of code in your file

    self.captureSession.sessionPreset = .photo
    

    You will get a awesome resolution like the integrated camera app from apple.

    0 讨论(0)
提交回复
热议问题