Image Tracker

The Image Tracker recognizes and tracks planar images. You can lay not only 3D objects but also videos(including transparent ones) on them.

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

Starting / Stopping the Tracker

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

>ImageTrackerActivity.java

@Override
protected void onResume() {
    ...
    TrackerManager.getInstance().startTracker(TrackerManager.TRACKER_TYPE_IMAGE);
    ...
}

@Override
protected void onPause() {
    ...
    TrackerManager.getInstance().stopTracker();
    ...
}

Using the Tracking Information

In the folder where SDK is installed, go to 'assets > ImageTarget' folder, and there is sample target image. Print the image.

If you use the sample code, the following content will be augmented for each image.

  • Blocks.jpg: The alpha video is augmented.
  • Lego.jpg: The normal video is augmented.
  • Glacier.jpg: The cube with the texture is augmented.

To apply tracking results to augmented objects, refer to the following code.

>ImageTrackerRenderer.java

public void onDrawFrame(GL10 unused) {
    ...
    TrackingState state = TrackerManager.GetInstance().UpdateTrackingState();
    TrackingResult trackingResult = state.GetTrackingResult(); 
    for (int i = 0; i < trackingResult.getCount(); i++) {
        Trackable trackable = trackingResult.getTrackable(i);
        if (trackable.getName().equals("Lego")) {
            ...
            videoQuad.draw();
        } else if (trackable.getName().equals("Blocks")) {
            ...
            chromaKeyVideoQuad.draw();
        } else if (trackable.getName().equals("Glacier")) {
            ...
            texturedCube.draw();
        } else {
            coloredCube.setProjectionMatrix(projectionMatrix);
            coloredCube.setTransform(trackable.getPoseMatrix());
            coloredCube.setScale(0.3f, 0.3f, 0.01f);
            coloredCube.draw();
        }
    }
    …
}

Setting a Target Image

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

>ImageTrackerActivity.java

onCreate() {
    ...    
    TrackerManager.getInstance().addTrackerData("ImageTarget/Blocks.2dmap", true);
    TrackerManager.getInstance().addTrackerData("ImageTarget/Glacier.2dmap", true);
    TrackerManager.getInstance().addTrackerData("ImageTarget/Lego.2dmap", true);
    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. Unzip the downloaded file and copy it to the desired path. The way to copy maps to the assets folder and to the external storage is different.

  • 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.
TrackerManager.getInstance().addTrackerData("ImageTarget/Blocks.2dmap", true);
  • If copying to external storage, enter the full path and set the second parameter to false.
TrackerManager.getInstance().addTrackerData(mapFile.getAbsolutePath(), false);

※ You must call loadTrackerData () after calling addTrackerData ().

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_TRACKING);
  • extended mode: This function is traceable even when the distance from the target image is far away.
TrackerManager.getInstance().setTrackingOption(TrackerManager.TrackingOption.EXTENDED_TRACKING);
  • 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_TRACKING);