ArCore:如何将 PlaneFindingMode 限制为仅垂直表面?

ArCore: How to restrict PlaneFindingMode to only vertical surfaces?

我是 ARCORE 和 Kotlin 的新手,正在尝试一个需要检测墙壁的简单 android-kotlin 应用程序。我知道 Google 使 PlaneFindingMode.VERTICAL 标签成为可能,但我不确定如何使用它。

如有任何帮助,我们将不胜感激。

可能重复here但我还是会回答的。

这个实现可能也适用于 ARCore。但我用 SceneForm SDK

测试了这个

先设置AR Session,然后使用扩展功能修改平面查找。

override fun onResume() {
    super.onResume()

    //Check if ARSession is null. If it is, instantiate it
    if(arSession == null) {
        arSession = Session(this@EdgeActivity)
        arSession?.setupPlaneFinding()
    }
}


// Setup plane detection
private fun Session.setupPlaneFinding() {

    //Create the config
    arConfig = Config(this)

    //Pause the session | Not sure if this is required for modifying plane detection. I was using this for something else, try & modify at your end
    pause()

    // Modify the plane finding mode
    arConfig?.planeFindingMode = Config.PlaneFindingMode.VERTICAL

    //Reinstate the session
    resume()

    //Sceneform requires that the ARCore session is configured to the UpdateMode LATEST_CAMERA_IMAGE. | I kept getting an exception if I remove this line. Again, this method is part of a bigger code, this particular line may not be required at your end. Try & Modify
    arConfig?.updateMode = Config.UpdateMode.LATEST_CAMERA_IMAGE

    //Reconfigure the session
    configure(arConfig)

    //Setup the session with ARSceneView | Very important
    fragment.arSceneView.setupSession(this)
}