有什么方法可以改善 ARKit 平面检测并减少检测它所消耗的时间吗?在这里,我们正在检测水平面,如果我们保持相机稳定,则需要时间来检测并且它在地板上不起作用。
对于桌子和其他类似表面,大约需要 5 到 6 秒。但是对于地板,它超过 20 或半分钟,如果我们不移动相机,它根本不起作用。
这是我的代码:-
override func viewDidLoad() {
super.viewDidLoad()
SVProgressHUD.show(withStatus: "Detecting Plane and Getting ready")
sceneView.delegate = self
sceneView.session.delegate = self
sceneView.showsStatistics = false
let configuration = ARWorldTrackingConfiguration()
configuration.planeDetection = .horizontal
configuration.isLightEstimationEnabled = true
sceneView.session.run(configuration)
sceneView.debugOptions = [ARSCNDebugOptions.showFeaturePoints]
}
func renderer(_ renderer: SCNSceneRenderer, didAdd node: SCNNode, for anchor: ARAnchor) {
if currentAnchor == nil {
currentAnchor = anchor
let light = SCNLight()
light.type = .directional
light.color = UIColor(white: 1.0, alpha: 1.0)
light.shadowColor = UIColor(white: 0.0, alpha: 0.8).cgColor
let lightNode = SCNNode()
lightNode.eulerAngles = SCNVector3Make(-.pi / 3, .pi / 4, 0)
lightNode.light = light
sceneView.scene.rootNode.addChildNode(lightNode)
let ambientLight = SCNLight()
ambientLight.type = .ambient
ambientLight.color = UIColor(white: 0.8, alpha: 1.0)
let ambientNode = SCNNode()
ambientNode.light = ambientLight
sceneView.scene.rootNode.addChildNode(ambientNode)
}
}
}