如何在ARKit中使用垂直检测?如何在、ARKit

2023-09-04 01:40:02 作者:孤独在蔓延

如何插入垂直固定在ARKit上的SCNScene?我不能做滞留并将对象插入到垂直位置。

override func viewDidLoad() {
    super.viewDidLoad()

    // Set the view's delegate
    sceneView?.delegate = self

    // Show statistics such as fps and timing information
    sceneView?.showsStatistics = true

    // Create a new scene
    let scene = SCNScene(named: "art.scnassets/tabellone.scn")

    sceneView?.debugOptions = [SCNDebugOptions.showFeaturePoints]

    // Set the scene to the view
    sceneView?.scene = scene!
}

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)

    // Create a session configuration
    let configuration = ARWorldTrackingConfiguration()

    configuration.planeDetection = .vertical
    configuration.isLightEstimationEnabled = true

    // Run the view's session
    sceneView?.session.run(configuration)
}

推荐答案

您需要合适的垂直表面进行跟踪。纯色的墙(上面没有可区分的特征)是非常糟糕的情况(你可以在左边的图像上看到这样一个垂直的表面)。跟踪垂直表面最可靠的方法是光线良好的砖墙,或上面有图片的墙,或具有可识别图案的墙,等等。

因此,右图是跟踪和垂直平面检测的一个很好的例子。

如果您想探索如何将3D对象放置到检测到的平面上,请查看Apple的Handling 3D Interaction and UI Controls in AR项目。

希望这能有所帮助。

 
精彩推荐
图片推荐