gpt4 book ai didi

ios - AVCapturePhotoCaptureDelegate 方法不是每次都被调用

转载 作者:行者123 更新时间:2023-12-03 20:51:45 24 4
gpt4 key购买 nike

我正在构建一个自定义相机,并且得到了古怪的结果。当我 try catch 图像时,有时 没有收到预期的委托(delegate)回调。例如,这是我的委托(delegate)方法:

func photoOutput(_ output: AVCapturePhotoOutput, willBeginCaptureFor resolvedSettings: AVCaptureResolvedPhotoSettings) {
print("will begin")
}

func photoOutput(_ output: AVCapturePhotoOutput, willCapturePhotoFor resolvedSettings: AVCaptureResolvedPhotoSettings) {
print("will capture")
}

func photoOutput(_ output: AVCapturePhotoOutput, didCapturePhotoFor resolvedSettings: AVCaptureResolvedPhotoSettings) {
print("did capture")
}

func photoOutput(_ output: AVCapturePhotoOutput, didFinishCaptureFor resolvedSettings: AVCaptureResolvedPhotoSettings, error: Error?) {
print("finished capture")
}

func photoOutput(_ output: AVCapturePhotoOutput, didFinishProcessingPhoto photo: AVCapturePhoto, error: Error?) {
print("finish process")
}

我有一个触发以下方法的按钮:

func capture() {
print("capture called")
let settings = AVCapturePhotoSettings()
captureOutput.capturePhoto(with: settings, delegate: self)
}

每次调用此方法时,我都希望在控制台中输出以下内容:

capture called

will begin
will capture
did capture
finish process
finished capture
image set

但是,我似乎只有 50/50 的机会得到以下输出:

capture called
did capture

这是怎么回事?

最佳答案

我遇到了同样的问题。我无法深入了解它,但我可以通过将输出从 AVCapturePhotoOutput 切换到 AVCaptureVideoDataOutput 来绕过它。我发现这篇文章真的很有帮助:https://medium.com/@barbulescualex/making-a-custom-camera-in-ios-ea44e3087563

关于ios - AVCapturePhotoCaptureDelegate 方法不是每次都被调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62474752/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com