iOS10:什么是 AVCapturePhotoOutput 等同于 captureStillImageAsynchronouslyFromConnection?
iOS10: What is AVCapturePhotoOutput equivalent for captureStillImageAsynchronouslyFromConnection?
AVCapturePhotoOutput 是已弃用的 AVCaptureStillImageOutput 库,它允许从 iOS 10.
中的视频连接捕获静止图像异步
这不是 AVCaptureStillImageOutput
的简单替换。
检查the reference of AVCapturePhotoOutput
:
特别是,您可能需要阅读概述中的这一部分:
- Capture an image by passing your photo settings object to the capturePhoto(with:delegate:) method along with a delegate object
implementing the AVCapturePhotoCaptureDelegate protocol. The photo
capture output then calls your delegate to notify you of significant
events during the capture process.
实际代码示例在Apple的示例代码中:
AVCam-iOS
消化,你需要两件事,一个AVCapturePhotoSettings
的实例和一个符合AVCapturePhotoCaptureDelegate
的实例。然后调用AVCapturePhotoOutput
.
的capturePhoto(with:delegate:)
方法
let photoSettings = AVCapturePhotoSettings()
//setup `photoSettings`
//...
//create an instance conforming to `AVCapturePhotoCaptureDelegate`
let photoCaptureDelegate = PhotoCaptureDelegate(with: photoSettings,...)
//`AVCapturePhotoCaptureDelegate` can be a complex object, so in the sample code, implemented in a separate file as `PhotoCaptureDelegate`.
//You need to keep strong reference to the delegate instance while capturing in progress.
self.photoOutput.capturePhoto(with: photoSettings, delegate: photoCaptureDelegate)
示例代码可能包含一些您可能不需要的无关功能。您可以通过删除它们来简化它。
(您没有指定语言标签,但上面的示例代码包含 Objective-C 版本。)
使用此委托方法,您可以获取图像,RAW 或 Live Photo 也存在类似的方法。
func capture(AVCapturePhotoOutput, didFinishProcessingPhotoSampleBuffer: CMSampleBuffer?, previewPhotoSampleBuffer: CMSampleBuffer?, resolvedSettings: AVCaptureResolvedPhotoSettings, bracketSettings: AVCaptureBracketedStillImageSettings?, error: Error?)
AVCapturePhotoOutput 是已弃用的 AVCaptureStillImageOutput 库,它允许从 iOS 10.
中的视频连接捕获静止图像异步这不是 AVCaptureStillImageOutput
的简单替换。
检查the reference of AVCapturePhotoOutput
:
特别是,您可能需要阅读概述中的这一部分:
- Capture an image by passing your photo settings object to the capturePhoto(with:delegate:) method along with a delegate object implementing the AVCapturePhotoCaptureDelegate protocol. The photo capture output then calls your delegate to notify you of significant events during the capture process.
实际代码示例在Apple的示例代码中: AVCam-iOS
消化,你需要两件事,一个AVCapturePhotoSettings
的实例和一个符合AVCapturePhotoCaptureDelegate
的实例。然后调用AVCapturePhotoOutput
.
capturePhoto(with:delegate:)
方法
let photoSettings = AVCapturePhotoSettings()
//setup `photoSettings`
//...
//create an instance conforming to `AVCapturePhotoCaptureDelegate`
let photoCaptureDelegate = PhotoCaptureDelegate(with: photoSettings,...)
//`AVCapturePhotoCaptureDelegate` can be a complex object, so in the sample code, implemented in a separate file as `PhotoCaptureDelegate`.
//You need to keep strong reference to the delegate instance while capturing in progress.
self.photoOutput.capturePhoto(with: photoSettings, delegate: photoCaptureDelegate)
示例代码可能包含一些您可能不需要的无关功能。您可以通过删除它们来简化它。
(您没有指定语言标签,但上面的示例代码包含 Objective-C 版本。)
使用此委托方法,您可以获取图像,RAW 或 Live Photo 也存在类似的方法。
func capture(AVCapturePhotoOutput, didFinishProcessingPhotoSampleBuffer: CMSampleBuffer?, previewPhotoSampleBuffer: CMSampleBuffer?, resolvedSettings: AVCaptureResolvedPhotoSettings, bracketSettings: AVCaptureBracketedStillImageSettings?, error: Error?)