ARCore - SceneView 中的垂直平面检测问题

问题描述 投票:0回答:1

场景: 我正在开发用于检测测量表面的应用程序,我正在使用 ARCore SDK 来实现此目的,这对于

HORIZONTAL VIEW
来说效果非常好,但问题出在垂直分析部分,因为它没有显示任何检测表面的点。

 sceneView = findViewById<ARSceneView?>(R.id.sceneView).apply {
            planeRenderer.isEnabled = true
            configureSession { session, config ->
                config.depthMode = when (session.isDepthModeSupported(Config.DepthMode.AUTOMATIC)) {
                    true -> {Config.DepthMode.AUTOMATIC
                    }
                    else -> Config.DepthMode.DISABLED


                }


               config.planeFindingMode = Config.PlaneFindingMode.VERTICAL
               config.depthMode = Config.DepthMode.AUTOMATIC
               config.instantPlacementMode = Config.InstantPlacementMode.LOCAL_Y_UP
                config.lightEstimationMode = Config.LightEstimationMode.ENVIRONMENTAL_HDR
               // config.updateMode=Config.UpdateMode.LATEST_CAMERA_IMAGE


            }

  
            onSessionUpdated = { _, frame ->
                if (anchorNode == null) {
                    frame.getUpdatedPlanes()
                        .firstOrNull { it.type == Plane.Type.VERTICAL }
                        ?.let { plane ->

                            //   addAnchorNode(plane.createAnchor(plane.centerPose))
                        }
                }
            }

            onTrackingFailureChanged = { reason ->
                [email protected] = reason
                Toast.makeText(this@MainActivity, "$reason", Toast.LENGTH_SHORT).show()
            }
            onSessionFailed={ fail->
                Toast.makeText(this@MainActivity, "$fail", Toast.LENGTH_SHORT).show()

            }
            onSessionUpdated={
                session, frame ->

               // Toast.makeText(this@MainActivity, "$session", Toast.LENGTH_SHORT).show()

            }
        }

上面的代码在水平平面上工作正常,但是当我们将configureSession更改为垂直时,它没有检测到任何垂直纹理的任何垂直平面。

已经尝试过

config.planeFindingMode = Config.PlaneFindingMode.VERTICAL

android kotlin augmented-reality arcore sceneview
1个回答
0
投票

ARCore 中的垂直平面检测

尽管垂直平面检测从来都不是 ARCore 或 ARKit 的强项,但遵循一些规则将允许您提高 ARCore 1.45 中垂直平面检测的质量和速度。跟踪垂直表面时最重要的两个方面是房间有足够的照明水平,墙壁有“丰富的纹理”和上面的一些物体。下面是工作的 Kotlin 代码,允许您从水平跟踪切换到垂直跟踪并返回(只需点击屏幕)。 class MainActivity : AppCompatActivity() { private lateinit var arFragment: ArFragment private lateinit var session: Session private var counter: Int = 0 override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) enableEdgeToEdge() setContentView(R.layout.activity_main) arFragment = supportFragmentManager.findFragmentByTag("frag") as ArFragment val button = findViewById<Button>(R.id.button_id) this.session = Session(this) val config = Config(session) config.updateMode = Config.UpdateMode.LATEST_CAMERA_IMAGE config.planeFindingMode = Config.PlaneFindingMode.DISABLED session.configure(config) arFragment.arSceneView.setupSession(session) button.setOnClickListener { counter += 1 if (counter % 2 == 1) { config.planeFindingMode = Config.PlaneFindingMode.VERTICAL session.configure(config) } else { config.planeFindingMode = Config.PlaneFindingMode.HORIZONTAL session.configure(config) } } } }

	
© www.soinside.com 2019 - 2024. All rights reserved.