Instant Fusion Tracker Android Tutorial

1. Overview
2. Android Development
2.1 Hardware Requirements for Android
2.2 Start / Stop Tracker
2.3 Use Tracking Information
2.4 Create Instant Target Data
3. Reference
3.1 API Reference
3.2 Sample


1. Overview

Start developing MAXST ARSDK Instant Fusion Tracker on Android Platform. Refer to Instant Tracker Introduction for detailed information.

Refer to Tracker Coordinate System to better understand 3D coordinate system of Instant Fusion Tracker.

After target recognition and initial poses are acquired through the MAXST SDK, use ARCore for tracking.

※To use the AR Core, you must enter the actual size. (See Start / Stop Tracker)

Prerequisite
Instant Tracker Introduction
Tracker Coordinate System

2. Android Development

Start developing on Android Studio using Java. Please refer to Requirements & Supports to find out which devices are supported.

ARSDK has to properly integrate on Android Activity. Refer to Life Cycle documents for details.


2.1 Hardware Requirements for Android

ARCore needs to support the device to use Instant Fusion Tracker of MAXST AR SDK.

Find ARCore supported devices


2.2 Start / Stop Tracker

TrackerManager.getInstance(). isFusionSupported ()
This function checks whether or not your device supports Fusion.
Return value is bool type. If true, it supports the device in use. If it is false, it does not support the device.

TrackerManager.getInstance().getFusionTrackingState ()
Pass the tracking status of the current Fusion.
The return value is an int of -1, which means that tracking isn't working properly, and 1 means that it's working properly.

To start / stop the tracker, refer to the following code.

※ To change Tracker, destroyTracker() should be called before

InstantFusionTrackerActivity.java

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

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

InstantFusionTrackerRenderer.java

@Override
Public void onSurfaceCreated(…){
   …
   …
   CameraDevice.getInstance().setARCoreTexture();
}

The setARCoreTexture () function call must be made from glThread.
setARCoreTexture () must be executed. If the function is not executed, no screen is displayed.


2.3 Use Tracking Information

To augment an object using Tracking results, refer to the following code.

※ startTracker() should be called before

InstantFusionTrackerRenderer.java

public void onDrawFrame(GL10 unused) {
    ...
    
    TrackingState state = TrackerManager.GetInstance().UpdateTrackingState();
    TrackingResult trackingResult = state.GetTrackingResult(); 
    ...
    
    if (trackingResult.getCount() == 0) {
        return;
    }
    ...
    
    Trackable trackable = trackingResult.getTrackable(0);
    
    GLES20.glEnable(GLES20.GL_DEPTH_TEST);
    
    texturedCube.setTransform(trackable.getPoseMatrix());
    texturedCube.setTranslate(posX, posY, -0.05f);
    texturedCube.setProjectionMatrix(projectionMatrix);
    texturedCube.draw();
}

2.4 Create Instant Target Data

You can create new data only when it is not in Tracking state. Refer to the following code.

InstantFusionTrackerActivity.java

@Override
public void onClick(View v) {
    switch (v.getId()) {
        case R.id.start_tracking:
            String text = startTrackingButton.getText().toString();
            if (text.equals(getResources().getString(R.string.start_tracking))) {
                TrackerManager.getInstance().findSurface();
                instantImageTargetRenderer.resetPosition();
                startTrackingButton.setText(getResources().getString(R.string.stop_tracking));
            } else {
                TrackerManager.getInstance().quitFindingSurface();
                startTrackingButton.setText(getResources().getString(R.string.start_tracking));
            }
            break;
    }
}

3. References

These are additional references to develop Instant Fusion Tracker


3.1 API Reference

Following documents explain classes and functions used to run Instant Fusion Tracker.

MaxstAR Class

TrackerManager Class

CameraDevice Class


3.2 Sample

For information regarding sample build and run of Instant Fusion Tracker, refer to Sample

InstantFusionTrackerActivity.java

InstantFusionTrackerRenderer.java