标签: avcapturephotosettings

拍摄照片时使用AVCapturePhotoOutput拍摄重量闪光问题

我正在开发相机应用程序.我正在为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)
Run Code Online (Sandbox Code Playgroud)

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

captureOutput:didFinishProcessingPhotoSampleBuffer:previewPhotoSampleBuffer:resolvedSettings:bracketSettings:error
Run Code Online (Sandbox Code Playgroud)

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

ios avcapturesession swift avcapturephotosettings

5
推荐指数
1
解决办法
657
查看次数

AVCapturePhotoOutput 颜色与预览图层不同

捕获图像时,输出图像的颜色与我在预览图层上看到的颜色不同。由于某种原因,颜色略有变化。以前有人遇到过这个问题吗?我怎样才能解决这个问题?

当我从以下位置获取图像时,绿色有点暗didFinishProcessingPhotoSampleBuffer 在此输入图像描述

avfoundation avcapturephotosettings

5
推荐指数
1
解决办法
551
查看次数

AVCapture?照片?输出为FlashScene键值观察

我正在关注 Apple 的最新示例代码AVCam Swift,该代码已更新为使用AVCapture\xe2\x80\x8bPhoto\xe2\x80\x8bOutput

\n\n
\n

var isFlashScene: Bool { 获取 }

\n\n

一个布尔值,指示相机当前预览的场景是否允许使用闪光灯。此属性\xe2\x80\x99s 值会根据相机当前可见的场景而变化。例如,您可以使用此属性突出显示应用程序 xe2x80x99s 相机 UI 中的闪光灯控制,向用户表明场景足够暗,可能需要启用闪光灯。如果照片捕获输出\xe2\x80\x99ssupportedFlashModes 值关闭,则此属性\xe2\x80\x99s 值始终为 false。该属性支持键值观察。

\n
\n\n

我正在尝试键值观察这一点,以便当自动闪光模式指示这是闪光灯将闪光的场景时(就像库存的 iOS 相机应用程序一样),所以我可以更改 UI,就像文档注释一样。

\n\n

所以我这样设置:

\n\n
private let photoOutput = AVCapturePhotoOutput()\n\nprivate var FlashSceneContext = 0\n\nself.addObserver(self, forKeyPath: "photoOutput.isFlashScene", options: .new, context: &FlashSceneContext)\n\noverride func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {\n  if context == & FlashSceneContext {\n     print ("Flash Scene Changed")\n  }\n}\n
Run Code Online (Sandbox Code Playgroud)\n\n

上面从未显示出任何变化。即使我登录查看

\n\n
print (self.photoOutput.isFlashScene)\n …
Run Code Online (Sandbox Code Playgroud)

key-value-coding avfoundation ios swift avcapturephotosettings

2
推荐指数
1
解决办法
513
查看次数