ios - 提高 captureStillImageAsynchronouslyFromConnection 的速度

标签 ios objective-c avfoundation

有什么办法可以提高 captureStillImageAsynchronouslyFromConnection 的速度吗? ?

我试着只关注输出的帧,像这样:captureOutput:didOutputSampleBuffer:fromConnection: ,但这并不能真正解决问题。此外,我无法从该委托(delegate)方法获得与使用上面的 captureAsync 方法相同的分辨率。

所以我的问题是,有什么方法可以提高 captureAsync 的返回速度吗?现在,我在 iPhone 7 上平均每次约 0.5 秒。

也许禁用 HDR 等?如果有人有任何意见,我将永远感激不已。

最佳答案

您可能已经知道,captureStillImageAsynchronouslyFromConnection:completionHandler: 已从 iOS 10 中弃用。

根据苹果文档

The AVCaptureStillImageOutput class is deprecated in iOS 10.0 and does not support newer camera capture features such as RAW image output, Live Photos, or wide-gamut color. In iOS 10.0 and later, use the AVCapturePhotoOutput class instead. (The AVCaptureStillImageOutput class remains supported in macOS 10.12.)

由于您的目标是 iPhone 7,我建议使用 AVCapturePhotoOutput 及其委托(delegate) AVCapturePhotoCaptureDelegate

有关更多信息,请查看我之前的 SO answer

为了提高速度,AFAIK 唯一的方法是使用 captureOutput:didOutputSampleBuffer:fromConnection:

  • 它为您提供由捕获设备处理的帧。
  • 为确保获得高质量的图片,您需要添加正确的 AVCapturePhotoSettings 并获得高质量的图像数据。

从我的处理速度测试结果来看,这种方法在 iPhone 6 上每秒可以处理超过 20 帧,在 iPhone 7 和 7 plus 上每秒可以处理超过 50 帧(请注意,这可能不是我的照片设置和图像的准确结果处理可能与您的不同)

关于ios - 提高 captureStillImageAsynchronouslyFromConnection 的速度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43860028/

相关文章:

ios - 从单元测试运行时,CATextLayer 不会出现在 AVMutableComposition 中

ios - AVFoundation 我使用 setActiveVideoMinFrameDuration 没有工作

ios - 在应用内启用或禁用 Iphone 推送通知

ios - 创建一个裁剪图像并在 50x 和 200y 下仅显示 100w 100h 的 UIImageView

objective-c - 将按钮添加到 OSX 锁定屏幕

ios - objective-c : Center with NSLayoutConstraint

ios - 在相机预览 View 上添加按钮 [BESwiftCamera lib]

ios - React Native 响应式字体大小

iphone - 可以将 PDF 文件和视频嵌入到 iOS 应用程序中吗?

ios - 静音播放背景歌曲但不显示静音图像?