我正在开发相机应用程序。我为iOS10.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上面的委托第一次抛出错误。我是AVCapturePhotoSettings的初学者。每次使用闪光灯模式成功拍摄照片后,都会出现问题。
发布于 2017-06-08 16:32:55
如果闪光灯模式处于打开状态,则不能启用图像稳定。(启用闪存的优先级高于isAutoStillImageStabilizationEnabled设置。)
不确定它是否会抛出错误,但您可以尝试删除此字符串
settings.isAutoStillImageStabilizationEnabled = true发布于 2017-06-13 04:02:13
发布于 2017-06-14 15:23:51
我正在使用这个方法来处理闪存设置。AVCaptureDevice基本上是你正在使用的相机,而AVCaptureFlashMode是你想要使用的闪光灯模式。
func changeFlashSettings(device: AVCaptureDevice, mode: AVCaptureFlashMode) {
do {
try device.lockForConfiguration()
device.flashMode = mode
device.unlockForConfiguration()
} catch {
print("Change Flash Configuration Error: \(error)")
}
}使用此选项,您可以将闪存设置为on、off或auto。希望这能有所帮助。
https://stackoverflow.com/questions/44370328
复制相似问题