Tag objects with google tango area learning

189 Views Asked by At

After area learning is done and the data is stored in an ADF file, is there any way in which we can tag the objects in the ADF file. E.g., Let's say that the application learns an area containing a coffee machine.

Can I tag that coffee machine with some text "Coffee Machine", so that next time when the area is recognized/localized, I can see the tag "Coffee Machine"

2

There are 2 best solutions below

0
On

What you can do is use the Area Learning functionality in the Unity samples from the SDK, to place markers on a loaded ADF. These markers are saved in an XML file, where you can check the coordinates of that marker. These coordinates are saved in the Unity Coordinate System. (see [here][1] - y and z inversed compared to Tango Coordinates)

So, for your example, if you place a marker on the coffee machine you can take the coordinates and place a label at those coordinates.

The coordinates are the values in meters on the three axes from the starting point of the ADF. This starting point (0,0,0) is the position of the device when you pressed Learn to create a new ADF.

Aside from that, there is no easy way to do dynamic object recognition right now, that's an interesting problem for 2018.

1
On

First you should tell if you are using Unity, C++ or Java. Under Unity, from AreaLearningInGameController in the Tango examples, at the very end of the file you can see the Data Structure they are saving in the XML file. The saved structure only needs to be serializable, and a string is serializable, so in your case, you can just do something like :

/// <summary>
/// Data container for Objects.
/// 
/// Used for serializing/deserializing objects to xml.
/// </summary>
[System.Serializable]
public class ObjectData
{
    [XmlElement("tag")]
    public string m_tag;

    [XmlElement("position")]
    public Vector3 m_position;

    [XmlElement("orientation")]
    public Quaternion m_orientation;
}

Then all you have to do, is save and load your objects with their associated tags. The way to do this is pretty clear in the example I linked.