Image Tracker

The Image Tracker recognizes and tracks planar images. It can demonstrate not only 3D objects but also videos, even the transparent one.

Configuring the Image Tracker Scene
Setting a Target Image
Adding / Replacing a Target Image
Starting / Stopping the Tracker
Using the Tracking Information
Changing Tracking Mode

Configuring the Image Tracker Scene

  1. Install MAXST AR SDK for Unity.

  2. Create a new scene.

  3. Delete the Main Camera that exists by default and add 'Assets > MaxstAR > Prefabs > ARCamera, ImageTrackable' to the scene.

    imagePrefab

    ※ If you build, you should add License Key to ARCamera.

  4. Create an empty object and add 'Assets > MaxstARSamples > Scripts > ImageTrackerSample' as a component.

    imageSample

  5. Drag a Assets > StreamingAssets > MaxstAR > ImageTarget > sample map file to the Inspector of ImageTrackable to set the map.

  6. In the ImageTrackable's Inspector, drag and drop 'Assets > StreamingAssets > MaxstAR > Sample > Sample Map File'

    imageMap

  7. Create a cube as a child of ImageTrakable and adjust its size and position.

    imageCube

  8. The cube will be augmented by illuminating the target image to the camera after Play.

    ※ Target image file is located in 'Assets > Editor > MaxstAR > Textures > ImageTarget' folder.

Setting a Target Image

By calling addTrackerData () to register the map file and calling loadTrackerData (), target image can be tracked. To set a target image, refer to the following code.

ImageTrackerSample.cs

private void AddTrackerData()
{
    foreach (var trackable in imageTrackablesMap)
    {
        if (trackable.Value.TrackerDataFileName.Length == 0)
        {
            continue;
        }

        if (trackable.Value.StorageType == StorageType.AbsolutePath)
        {
            TrackerManager.GetInstance().AddTrackerData(trackable.Value.TrackerDataFileName);
        }
        else
        {
            if (Application.platform == RuntimePlatform.Android)
            {
                TrackerManager.GetInstance().AddTrackerData(trackable.Value.TrackerDataFileName, true);
            }
            else
            {
                TrackerManager.GetInstance().AddTrackerData(Application.streamingAssetsPath + "/" + trackable.Value.TrackerDataFileName);
            }
        }
    }

    TrackerManager.GetInstance().LoadTrackerData();
}

Adding / Replacing a Target Image

  1. Create a map file refer to Documentation > Target Manager.

  2. Download the file you created.

  3. Import the downloaded file.

  4. Set a target image.

Starting / Stopping the Tracker

To start / stop Tracker after loading the map, refer to the following code.

ImageTrackerSample.cs

void Update()
{
    ...
    TrackerManager.GetInstance().StartTracker(TrackerManager.TRACKER_TYPE_IMAGE);
    ...
}

void OnApplicationPause(bool pause)
{
    ...
    TrackerManager.GetInstance().StopTracker();
    ...
}

void OnDestroy()
{
    ...
    TrackerManager.GetInstance().StopTracker();
    TrackerManager.GetInstance().DestroyTracker();
}

Using the Tracking Information

To use the Tracking information, refer to the following code.

ImageTrackerSample.cs

void Update()
{
    ...
    TrackingResult trackingResult = TrackerManager.GetInstance().GetTrackingResult();

    for (int i = 0; i < trackingResult.GetCount(); i++)
    {
        Trackable trackable = trackingResult.GetTrackable(i);
        imageTrackablesMap[trackable.GetName()].OnTrackSuccess(trackable.GetId(), trackable.GetName(), trackable.GetPose());
    }
}

Changing Tracking Mode

Image Tracker has three Tracking modes : normal, extended, and multi.

The default setting is normal mode.

  • normal mode: This is the normal image tracker.
TrackerManager.GetInstance().SetTrackingOption(TrackerManager.TrackingOption.NORMAL_MODE);
  • extended mode: This function is traceable even when the distance from the target image is far away.
TrackerManager.GetInstance().SetTrackingOption(TrackerManager.TrackingOption.EXTEND_MODE);
  • multi mode: This function allows you to recognize and track up to three target images at the same time.
TrackerManager.GetInstance().SetTrackingOption(TrackerManager.TrackingOption.MULTI_MODE);