AVCaptureSession preset creates a photo that is to

2019-04-14 13:52发布

I have a photo taking app that is using AVFoundation. Once an image is captured, I have 2 core graphics methods that I have to run in order to properly rotate and crop the image.

When testing this using the typical AVFoundation setup for capturing camera photos with a session preset of AVCaptureSessionPresetPhoto, I was always receiving a ton of memory warnings and I spent 2 weeks trying to solve these and I finally gave up.

I ended up ditching the typical captureStillImageAsynchronouslyFromConnection setup and using another setup that just "captures" the video frames. This new method works perfectly, the final image quality matches the old image quality produced by AVCaptureSessionPresetPhoto and the image has a much smaller resolution so I am no longer dealing with memory issues or warnings.

The image rotation and crop also happens almost instantly now and is almost completely unnoticeable since the new size is much smaller.

Literally the only difference, as far as I can tell, is that AVCaptureSessionPresetPhoto produces a photo with a resolution of 2448 x 3264 whereas my new method produces a resolution of 852 x 640 yet the quality appears to be identical.

However, since this new method does not technically perform a real "camera capture", I am going to have to spend some time adding the camera sound effect, programmatically calling the flash/torch to add flash functionality, etc. Before I start down this road of customization I decided to revisit my old setup that developers typically use when capturing photos using AVFoundation.

Here's a link to the "typical" setup that I'm talking about: https://stackoverflow.com/a/22700723/3344977

I tested all of the session presets one last time and none of them work like AVCaptureSessionPresetPhoto. The resolution is either too small, or the resolution could possibly work but the preview is zoomed in which is unacceptable.

Are there any other options? Can I some how disable the zoom on some of these presets? Or can I customize the actual image size for the AVCaptureSessionPresetPhoto preset? Can I create a new custom preset from scratch and add that?

I have been searching for answers but it seems like most people just recommend using the default presets that are available.

0条回答
登录 后发表回答