gpt4 book ai didi

iOS 12 深度数据捕获错误代码 11800

转载 作者:行者123 更新时间:2023-11-28 23:54:19 30 4
gpt4 key购买 nike

var captureSession = AVCaptureSession()

override func viewDidLoad() {
super.viewDidLoad()

AVCaptureDevice.requestAccess(for: .video) { (succ) in
print("\(succ) video")
}
}

@IBAction func Shoot(_ sender: Any) {
if captureSession.isRunning == true {
captureSession.stopRunning()
}
let cam = AVCaptureDevice.DiscoverySession.init(deviceTypes: [.builtInDualCamera], mediaType: AVMediaType.video, position: .back)
captureSession = AVCaptureSession()
captureSession.beginConfiguration()
do {
let input = try AVCaptureDeviceInput(device: cam.devices.first!)
captureSession.addInput(input)
} catch {
print(error)
}
captureSession.sessionPreset = .photo
let output = AVCapturePhotoOutput()
captureSession.addOutput(output)
captureSession.commitConfiguration()
output.isDepthDataDeliveryEnabled = true
output.isHighResolutionCaptureEnabled = true
captureSession.startRunning()
}

@IBAction func Go(_ sender: Any) {
let output = captureSession.outputs.first as! AVCapturePhotoOutput
output.capturePhoto(with: photoSettingsCreator(), delegate: self)
}

func photoOutput(_ output: AVCapturePhotoOutput, didFinishProcessingPhoto photo: AVCapturePhoto, error: Error?) {
if error != nil {
print(error!)
}
let dat = photo.fileDataRepresentation()!
let img = UIImage(data: dat)
print(photo.depthData!)
}

func photoSettingsCreator() -> AVCapturePhotoSettings {
let settings = AVCapturePhotoSettings(format: [AVVideoCodecKey : AVVideoCodecType.hevc, AVVideoCompressionPropertiesKey : [AVVideoQualityKey : 1.0]])
settings.isDepthDataDeliveryEnabled = true
settings.isHighResolutionPhotoEnabled = true
settings.isAutoStillImageStabilizationEnabled = true
settings.flashMode = .off
return settings
}

直到我在手机上安装 iOS 12 beta 之前,捕获深度数据都工作正常,但现在出现错误:

Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSLocalizedFailureReason=An unknown error occurred (-16800), NSLocalizedDescription=The operation could not be completed, NSUnderlyingError=0x283094510 {Error Domain=NSOSStatusErrorDomain Code=-16800 "(null)"}}

我不明白这个错误是从哪里来的。该错误打印在照片输出的 if error 部分。

最佳答案

这可能是因为您的captureSession被deinit了。在关闭 View 时进行反初始化,很可能在 viewWillDisappear

self.captureSession.deinitialize()

关于iOS 12 深度数据捕获错误代码 11800,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51576443/

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