ArCore:如何将 PlaneFindingMode 限制为仅垂直表面? [英] ArCore: How to restrict PlaneFindingMode to only vertical surfaces?

查看:22
本文介绍了ArCore:如何将 PlaneFindingMode 限制为仅垂直表面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am new to ARCORE and Kotlin and trying a simple android-kotlin app that need to detect walls. I know Google's made it possible with PlaneFindingMode.VERTICAL tag, but I am not sure how to use it.

任何帮助将不胜感激.

推荐答案

可能重复这里 但我还是会回答.

Possible duplicate here but I'll answer it anyway.

此实现可能也适用于 ARCore.但是我用 SceneForm SDK 测试了这个

This implementation is probably applicable to ARCore as well. But I tested this with SceneForm SDK

先设置 AR Session,然后使用扩展函数修改平面查找.

Setup the AR Session first and use an extension function to modify plane finding.

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)
}

这篇关于ArCore:如何将 PlaneFindingMode 限制为仅垂直表面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆