-->

iOS Capture high resolution photo while using a lo

2019-06-26 13:10发布

问题:

I have pretty much the same question as this one below:

Switching AVCaptureSession preset when capturing a photo

The issue however is that the (self) answer doesn't help me one bit. I am wondering if someone has a clue as to how to do this.

I am capture video frames so I can process them and do something with them. For this, I am using the AVCaptureSessionPrese640x480 as I need all the frame rate I can get while getting a decent frame for computation. Now, when the user wants to capture the photo, I want him to be able to capture the photo in the highest resolution possible. For this, I am not in the favor of:

[captureSession beginConfiguration];
captureSession.sessionPreset = <some_preset>
[captureSession commitConfiguration];

I have tried this and I am getting an error in some cases; but still there is a definite lag on the screen for some reason and I don't trust this anymore.

Is there a definite way of getting a high resolution image from the camera while capturing video output in a very low resolution (for e.g. 640x480)?

回答1:

For iPhone6 and iPhone6+, you can use the new API [AVCaptureStillImageOutput setHighResolutionStillImageOutputEnabled:YES] When this flag has been turned on (it is off by default), you can capture the high res still image while using a low resolution capture session.



回答2:

You can add AVCapturePhotoOutput to the AVCaptureSession object and set its highResolutionCaptureEnabled property to YES. During capture you can use AVCapturePhotoOutput's capturePhotoWithSettings message to capture the image by passing it AVCapturePhotoSettings object and AVCapturePhotoCaptureDelegate. By using the AVCapturePhotoSettings object, you can further modify the capture properties like flashMode, autoStillImageStabilizationEnabled and highResolutionPhotoEnabled. The usage is shown in AVCamManual example.