【问题标题】:Local Area Description: Learning当地描述:学习
【发布时间】:2017-08-21 13:17:46
【问题描述】:

我刚刚开始学习有关 Google Tango 的知识,但在理解如何实施局部区域描述学习方面遇到了一些麻烦。我遵循了文档中的操作指南之一,即在 AR 中放置虚拟对象,我希望应用程序记住放置这些小猫的位置。我将附上 Unity 中的场景和我尝试为 AreaDEscription 启用 SaveCurrent 方法的脚本。 The scene from Unity 和以下代码主要是来自 How-To-Guide 的代码,我在其中尝试创建另一个线程来保存当前的 AreaDescription

public class KittyUIController : MonoBehaviour
{
Thread thread;
public GameObject m_kitten;
private TangoPointCloud m_pointCloud;

void Start()
{
    m_pointCloud = FindObjectOfType<TangoPointCloud>();
    thread = new Thread(Thread123);
}

void Update()
{
    if (Input.touchCount == 1)
    {
        // Trigger place kitten function when single touch ended.
        Touch t = Input.GetTouch(0);
        if (t.phase == TouchPhase.Ended)
        {
            PlaceKitten(t.position);
            thread.Start();
        }
    }
}

void PlaceKitten(Vector2 touchPosition)
{
    // Find the plane.
    Camera cam = Camera.main;
    Vector3 planeCenter;
    Plane plane;
    if (!m_pointCloud.FindPlane(cam, touchPosition, out planeCenter, out plane))
    {
        Debug.Log("cannot find plane.");
        return;
    }

    // Place kitten on the surface, and make it always face the camera.
    if (Vector3.Angle(plane.normal, Vector3.up) < 30.0f)
    {
        Vector3 up = plane.normal;
        Vector3 right = Vector3.Cross(plane.normal, cam.transform.forward).normalized;
        Vector3 forward = Vector3.Cross(right, plane.normal).normalized;
        Instantiate(m_kitten, planeCenter, Quaternion.LookRotation(forward, up));
    }
    else
    {
        Debug.Log("surface is too steep for kitten to stand on.");
    }
}

void Thread123()
{
    AreaDescription.SaveCurrent();
}

public void OnApplicationQuit()
{
    thread.Abort();
}

}

【问题讨论】:

    标签: augmented-reality google-project-tango


    【解决方案1】:

    我没有足够的声望点来发表评论,所以我在这里发布我的答案。您应该提供更多关于什么有效,什么无效的详细信息。

    首先,从this page开始,因为您需要在您的应用程序中正确设置AreaLearning。然后,检查this code 和相应的AreaLearning 场景示例,这就是您想做的所有事情。

    教程和代码中没有的东西,对于让它工作非常重要的是你需要检查“Tango AR相机”的“Tango AR Pose Controller”中的“使用区域描述”预制件(或 Tango 相机,如果您使用的是最新的 SDK 的预制件),否则您的对象将不会放置在 ADF 基础框架上。

    如果我必须总结一下,工作流程是:

    1. 加载现有的 ADF(无论是否处于学习模式)或开始学习新的 ADF。
    2. 如果加载了现有 ADF,请重新定位(如果您在学习模式下加载 ADF,这可能需要更长的时间)
    3. 重新定位后,加载存储对象的 xml(在您的 cas 中为小猫)。 XML 通常与 ADF 的 UUID 同名,并存储在 Application.persistentDataPath (Android/data/com.YourApp/files) 中。所有加载的对象都将放置在 ADF 基础框架上。
    4. 对于您放置的每只新小猫,请在放置时记录时间戳。此时间戳可让您恢复放置小猫时的框架与 ADF 基础框架之间的转换。
    5. 当您保存到 XML 时,由于转换,您将能够保存小猫关于 ADF 基本框架的坐标(在示例中,转换在 _UpdateMarkersForLoopClosures 中计算)。

    在示例中,他们会在保存后重新加载场景,因此他们会返回到 AreaDescriptionPicker 屏幕,但您可以决定如何执行此操作。

    我真的不知道还能说什么。希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-06-19
      • 2015-05-01
      • 2017-12-31
      • 1970-01-01
      • 1970-01-01
      • 2016-07-18
      • 1970-01-01
      • 2020-04-28
      相关资源
      最近更新 更多