Image Tracker

Prerequisites
Target Manager
Recommended Conditions for Target Images
Tracker Coordinate System in Unity

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

Make Image Tracker Scene
Set Target Image
Add / Replace Target Image
Train Target Image Instantly
Start / Stop Tracker
Use Tracking Information
Change Tracking Mode
GitHub Unity Scene Example

Definition

MAXST’s computer vision based 2D image tracking engine empowers your app to track image targets robustly even under challenging conditions like fast camera movement or partial covering of targets. In Extended Tracking Mode, the camera can track as far as it can see. Also, you can track up to 3 images at the same time in Multi Tracking Mode.

1-1.PNG

Make 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 an application, you must add a 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.

Set 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();
}

Add / Replace Target Image

  1. Create a map file refer to Target Manager.

  2. Download the file you created.

  3. Import the downloaded file.

  4. Set a target image.

Train Target Image Instantly

If you want to use a raw image file as an image target without an offline training process via Target Manager, enter a JSON object as the first parameter of AddTrackerData().
A sample JSON format is like below.

{
    "image":"add_image",
    "image_path":"ImageTarget/Blocks.png",
    "image_width":0.26,
}

The "image":"add_image" pair should be located at first. The value of "image_path" is an image path and the value of "image_width" is a real width (meter unit) of an image target.
A sample code is like below.

TrackerManager.GetInstance().AddTrackerData("{\"image\":\"add_image\",\"image_path\":\"ImageTarget/Blocks.png\",\"image_width\":0.26}", true);

When copying to the assets folder, set the second parameter to true to indicate that it is a relative path and a file in the assets folder. If copying to external storage, enter the full path and set the second parameter to false. The instant training permits only jpg and png formats. An image width as a pixel size should be more than 320 and the best is 640.
※ Instant training of an image takes twice as much time as loading a 2dmap.
※ You must call LoadTrackerData () after calling AddTrackerData ().

Start / Stop Tracker

After loading the map, refer to the following code to start / stop the tracker.

>ImageTrackerSample.cs

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

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

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

Use Tracking Information

Refer to the following code to use the tracking information.

>ImageTrackerSample.cs

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

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

Change Tracking Mode

5 Tracking Modes of Image Tracker:

NORMAL_TRACKING, EXTENDED_TRACKING, MULTI_TRACKING, JITTER_REDUCTION_ACTIVATION, JITTER_REDUCTION_DEACTIVATION

  • NORMAL_TRACKING: Default Setting. Traceable one target image.
TrackerManager.GetInstance().SetTrackingOption(TrackerManager.TrackingOption.NORMAL_TRACKING);
  • EXTENDED_TRACKING: Extend and track the learned image in real time beyond the learned image. Even when the current camera frame does not have enough features of the target image, the surrounding environment can estimate the position of the target image.
TrackerManager.GetInstance().SetTrackingOption(TrackerManager.TrackingOption.EXTEND_TRACKING);
  • MULTI_TRACKING: Possible to recognize and track up to three target images at the same time.
TrackerManager.GetInstance().SetTrackingOption(TrackerManager.TrackingOption.MULTI_TRACKING);
  • JITTER_REDUCTION_ACTIVATION: Calibrate the JITTER using the Kalman filter. When moving the camera or target sharply, the movement of the augmented content may appear to have a slight delay.
TrackerManager.GetInstance().SetTrackingOption(TrackerManager.TrackingOption.JITTER_REDUCTION_ACTIVATION);
  • JITTER_REDUCTION_DEACTIVATION: Disable the jitter reduction option.
TrackerManager.GetInstance().SetTrackingOption(TrackerManager.TrackingOption.JITTER_REDUCTION_DEACTIVATION);

GitHub Unity Scene Example

GitHub Unity Scene Example: https://github.com/maxstdev/MaxstARSDK_Unity_Sample.git

More

  • ExtraImageTrackerKnight
  • ExtraImageTrackerMultiTarget