地区描述:学习 [英] Local Area Description: Learning

查看:100
本文介绍了地区描述:学习的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I've just started learning something about Google Tango and i am having some troubles in understanding how to implement Local Area Description Learning. I have followed one of the How-to-guides from the documentation, the one with Placing Virtual Objects in AR and i wanted the app to remember the places where those kittens were placed. I will attach the Scene from Unity and a script where I've tried to enable SaveCurrent method for AreaDEscription. The scene from Unity and the following code is mainly the one from the How-To-Guide where i have tried to create another Thread for saving the current 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();
}

}

推荐答案

我没有足够的声誉点可以发表评论,所以我在这里发布了答案.您应该提供有关什么在工作,什么不在工作的更多详细信息.

I don't have enough reputation points to comment so I post my answer here. You should provide more details about what is working, and what is not.

首先,从此页面开始,因为您需要在您的应用中正确设置AreaLearning.然后,检查此代码和相应的AreaLearning场景示例,这就是您需要做的.

First, start with this page, because you need to set up AreaLearning properly in your App. Then, examine this code and the corresponding AreaLearning scene example, this is all you need to do want you want to do.

必须在"Tango AR摄像头"的"Tango AR姿势控制器"中检查使用区域描述",这是必需的,也不在代码中,要使其正常工作,这非常重要.预制件(如果您使用的是最新SDK的预制件,则为Tango Camera),否则将不会将对象放置在ADF基本框架上.

Something that is not in the turorial nor in the code, and that is very important to make it work is that you need to check "Use Area Description" in the "Tango AR Pose Controller" of the "Tango AR Camera" prefab (or Tango Camera, if you are using the latest SDK's prefab), otherwise your objects won't be placed regarding the ADF base frame.

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

If I had to sum it all up, the workflow is:

  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屏幕,但是由您决定如何执行此操作.

In the example, they reload the scene after they save, so they go back to the AreaDescriptionPicker screen but it is up to you to decide how you want to do this.

我真的不知道该说些什么.希望这会有所帮助.

I really don't know what more to say. Hope this helps.

这篇关于地区描述:学习的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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