You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

ARCore SceneView垂直平面检测异常问题求助

ARCore垂直平面检测故障排查

我正在开发一款用于表面检测测量的应用,基于ARCore SDK实现。该SDK在水平视角下工作完全正常,但垂直平面分析环节存在问题,无法显示用于检测表面的点。

问题代码

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 ->
        this@MainActivity.trackingFailureReason = 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()
    }
}

上述代码在水平平面模式下运行正常,但切换为垂直平面配置后,无法检测到带有垂直纹理的垂直平面。

已尝试操作

config.planeFindingMode = Config.PlaneFindingMode.VERTICAL

排查修复建议

  • 修复深度模式重复赋值问题:代码中先通过设备支持性判断设置depthMode,随后又直接覆盖为AUTOMATIC,这会导致不支持自动深度的设备出现异常。保留条件判断逻辑,删除重复赋值:
    config.depthMode = when (session.isDepthModeSupported(Config.DepthMode.AUTOMATIC)) {
        true -> Config.DepthMode.AUTOMATIC
        else -> Config.DepthMode.DISABLED
    }
    // 移除下面这行重复赋值
    // config.depthMode = Config.DepthMode.AUTOMATIC
    
  • 调整平面检测逻辑:当前仅在anchorNode为空时检测垂直平面,若锚点已创建就会停止检测。如果需要持续检测,移除anchorNode == null的判断,或者将锚点创建逻辑嵌套在内部:
    onSessionUpdated = { _, frame ->
        frame.getUpdatedPlanes()
            .firstOrNull { it.type == Plane.Type.VERTICAL }
            ?.let { plane ->
                if (anchorNode == null) {
                    addAnchorNode(plane.createAnchor(plane.centerPose))
                }
            }
    }
    
  • 确保平面渲染正常:虽然已开启planeRenderer.isEnabled = true,但可以在检测到垂直平面时主动触发渲染更新,或者检查是否有其他逻辑意外关闭了平面渲染。
  • 测试场景优化:垂直平面检测对表面纹理要求较高,测试时选择纹理丰富的垂直表面(如带图案的墙面、海报),避免纯色光滑墙面。
  • 验证会话配置生效:确认configureSession的配置是在会话启动前完成的,若会话已启动,需调用session.configure(config)重新应用配置。

内容的提问来源于stack exchange,提问作者Syed Moiz

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.29 09:27:21