ios - 使用 AVCapturePhotoOutput 使用闪光灯拍照时出现问题

标签 ios swift avcapturesession avcapturephotosettings

我正在开发相机应用程序。我正在为 ios 10.x 设备使用 AVCapturePhotoOutput,为 10.x 以下设备使用 AVCaptureStillImageOutput。

我在拍摄照片时使用以下拍摄设置

let settings = AVCapturePhotoSettings()

let previewPixelType = settings.availablePreviewPhotoPixelFormatTypes.first!
        let previewFormat = [kCVPixelBufferPixelFormatTypeKey as String: previewPixelType,
                             kCVPixelBufferWidthKey as String: 1080,
                             kCVPixelBufferHeightKey as String: 1080,
                             ]
settings.previewPhotoFormat = previewFormat
settings.isHighResolutionPhotoEnabled = true
settings.flashMode = .on
settings.isAutoStillImageStabilizationEnabled = true
self.captureOutputPhoto?.capturePhoto(with: settings, delegate: self)

当我尝试使用上述设置拍摄照片时

captureOutput:didFinishProcessingPhotoSampleBuffer:previewPhotoSampleBuffer:resolvedSettings:bracketSettings:error

上面的委托(delegate)第一次抛出错误。我是 AVCapturePhotoSettings 的初学者。每次使用闪光灯模式成功拍摄照片后都会出现此问题。

最佳答案

来自 Apple documentation :

You may not enable image stabilization if the flash mode is on . (Enabling the flash takes priority over the isAutoStillImageStabilizationEnabled setting.)

不确定,如果它应该抛出错误,但你可以尝试删除这个字符串

settings.isAutoStillImageStabilizationEnabled = true

关于ios - 使用 AVCapturePhotoOutput 使用闪光灯拍照时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44370328/

相关文章:

javascript - React Native ios运行问题

ios - 播放带有音频的视频后录制音频和视频

swift - 当用户来到 Controller 时如何存储开关值

iPhone 相机对焦

swift - 使用 AVCaptureVideoDataOutput 正确录制视频

ios - iOS如何支持IAP订阅免费试用?

ios - 在 SwiftUI 中使用 Form view 时是否可以得到圆角分组的表格样式?

ios - 停止 WKWebView 重定向到基于通用链接的另一个应用程序

ios - 更新纹理不起作用

swift - 在 RealityKit 中启用手势