首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用AVCapturePhotoOutput使用闪光灯拍照时出现问题

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

Stack Overflow用户
提问于 2017-06-05 21:40:37
回答 3查看 1.2K关注 0票数 5

我正在开发相机应用程序。我为iOS10.x设备使用AVCapturePhotoOutput,为低于10.x的设备使用AVCaptureStillImageOutput。

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

代码语言:javascript
复制
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)

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

代码语言:javascript
复制
captureOutput:didFinishProcessingPhotoSampleBuffer:previewPhotoSampleBuffer:resolvedSettings:bracketSettings:error

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

EN

回答 3

Stack Overflow用户

发布于 2017-06-08 16:32:55

来自Apple documentation

如果闪光灯模式处于打开状态,则不能启用图像稳定。(启用闪存的优先级高于isAutoStillImageStabilizationEnabled设置。)

不确定它是否会抛出错误,但您可以尝试删除此字符串

代码语言:javascript
复制
settings.isAutoStillImageStabilizationEnabled = true
票数 -1
EN

Stack Overflow用户

发布于 2017-06-14 15:23:51

我正在使用这个方法来处理闪存设置。AVCaptureDevice基本上是你正在使用的相机,而AVCaptureFlashMode是你想要使用的闪光灯模式。

代码语言:javascript
复制
func changeFlashSettings(device: AVCaptureDevice, mode: AVCaptureFlashMode) {
    do {
        try device.lockForConfiguration()
        device.flashMode = mode
        device.unlockForConfiguration()
    } catch {
        print("Change Flash Configuration Error: \(error)")
    }
}

使用此选项,您可以将闪存设置为onoffauto。希望这能有所帮助。

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44370328

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档