Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

swift AVCapturePhotoOutput capturePhoto hangs preview

Showing preview in 1080 x 1440; getting photo with max resolution (3024 x 4032) and quality on iPhone 8 Plus with code:

capturePhotoOutput?.capturePhoto(with: configurePhotoSettings(), delegate: self)

with photo settings:

private func configurePhotoSettings() -> AVCapturePhotoSettings {
    let photoSettings = AVCapturePhotoSettings()
    photoSettings.isHighResolutionPhotoEnabled = true
    photoSettings.isAutoStillImageStabilizationEnabled = (capturePhotoOutput?.isStillImageStabilizationSupported)!
    photoSettings.isAutoDualCameraFusionEnabled = (capturePhotoOutput?.isDualCameraFusionSupported)!
        
    return photoSettings
}

Doing this one by one (like sequential shooting mode) and preview freezes each time for a short time even if I do nothing in didFinishProcessingPhoto.


Looking for solution to make capturing smooth, maybe in background thread, but currently I'm stuck..

like image 387
Volodymyr Kulyk Avatar asked Nov 07 '22 06:11

Volodymyr Kulyk


1 Answers

The reason of preview hangs is feature called optical stabilization.


You just need to turn it off for smooth preview while capturing photo:

photoSettings.isAutoStillImageStabilizationEnabled = false
like image 199
Volodymyr Kulyk Avatar answered Nov 14 '22 23:11

Volodymyr Kulyk