Try MAXST AR Fusion Tracker Now ✨

Instant 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 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 Tracker.

Prerequisites
Instant Tracker Introduction
Tracker Coordinate System

2.Android Development

Start developing on Android Studio using Java. 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 detail.


2.1 Hardware Requirements for Android

MAXST AR SDK's Instant Tracker uses internally Android Rotation Vector related to both gyro and compass sensors.

If your target device has no gyro or compass sensor, the engine can not find the initial pose. If there is no sensor value, our engine assumes the front scene as a ground plane.

If you want to check whether the current device support Android Rotation Vector, please refer to the following codes.

 
SensorManager mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
List<Sensor> sensors = mSensorManager.getSensorList(TYPE_ROTATION_VECTOR);
Log.i(TAG, "# sensor : " + sensors.size());
for(int i=0; i<sensors.size(); i++)
{
   Log.i(TAG, sensors.get(i).getName());
}
if(sensors.isEmpty())
{
   Log.i(TAG,"There is no Rotaion Vector");
}

※Devices that do not support the Android Rotation Vector

  • Samsung Galaxy J5
  • Moto G5 Plus
  • Moto G4 Plus
  • Iball Andi 5U
  • Geonee S +

2.2 Start / Stop Tracker

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

※ To change the tracker, destroyTracker() should be called before

InstantTrackerActivity.Java

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

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

2.3 Use Tracking Information

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

※ startTracker() should be called before

InstantTrackerRenderer.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.

InstantTrackerActivity.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 Tracker


3.1 API Reference

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

MaxstAR Class

TrackerManager Class

CameraDevice Class


3.2 Sample

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

InstantTrackerActivity.Java

InstantTrackerRenderer.Java