Instant Tracker

The Instant Tracker instantly scans the planar surface in the camera frame and recognizes the space with sensors. You can find the rendered 3D object on the space.

Starting / Stopping the Tracker
Using the Tracking Information
Creating the Instant Target Data

Starting / Stopping the Tracker

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

>InstantTrackerActivity.java

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

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

Using the Tracking Information

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

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

Creating the 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;
    }
}