问题
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 Camera and I found that the iPhone Camera Image is much better than AVCaptureSession
image.
I have seen 3-4 links on stackOverflow about this but could not find any solution.
also I have tried all the presets
AVCaptureSessionPresetPhoto,
AVCaptureSessionPresetHigh,
AVCaptureSessionPresetMedium,
AVCaptureSessionPresetLow,
AVCaptureSessionPreset352x288,
AVCaptureSessionPreset640x480,
AVCaptureSessionPreset1280x720,
AVCaptureSessionPreset1920x1080,
AVCaptureSessionPresetiFrame960x540,
AVCaptureSessionPresetiFrame1280x720,
but still image is of lesser quality. Please let me know if my question is not clear enough or I missed something.
回答1:
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:
and here is one from the built-in photo application:
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.
回答2:
Just add this line of code in your file
self.captureSession.sessionPreset = AVCaptureSessionPresetPhoto
You will get a awesome resolution like the integrated camera app from apple.
回答3:
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];
来源:https://stackoverflow.com/questions/10961521/avcapturesession-is-not-giving-a-good-photo-quality-and-good-resolution