【发布时间】:2020-07-11 09:09:31
【问题描述】:
我正在捕获 ARFrame 并应用过滤器,效果很好,但我想关闭过滤器并返回原始相机源,但我遇到了问题。此代码正在应用过滤器:
func session(_ session: ARSession, didUpdate frame: ARFrame) {
let filterImage = setFilter(session.currentFrame)
sceneView.scene.background.contents = context.createCGImage(filterImage, from: filterImage.extent)
}
一旦我设置了sceneView.scene.background.contents,我就无法将其设置回原始来源。原始来源是一个名为:SCNCaptureDeviceOutputConsumerSource 的对象,它不在文档中。我尝试保存该对象并再次使用它设置背景内容,但它只会显示它所持有的最后一帧(因此会有静止图像)。它不会持续更新。我不知道如何让sceneView.scene.background.contents 从与替换之前相同的源中提取数据。
我尝试设置sceneView.session.delegate = nil,但这不起作用,它只是停止更新,并且屏幕看起来像冻结了一样。
有没有办法将 ARSCNView 背景内容重置为其获取数据的原始来源?
如果我重新加载 ARSCNView,它可以工作,但重新加载至少需要一秒半:
sceneView.session.delegate = nil
sceneView = nil
sceneView = ARSCNView(frame: view.bounds)
view.addSubview(sceneView)
sceneView.delegate = self
sceneView.session.run(ARFaceTrackingConfiguration())
感谢您提供的任何帮助。
【问题讨论】:
标签: ios swift augmented-reality arscnview