Object Fusion Tracker Android Tutorial

1. Overview
2. Android Development
2.1 Start / Stop Tracker
2.2 Use Tracking Information
2.3 Set Map
2.4 Add / Replace Map
3. Reference
3.1 API Reference
3.2 Sample


1. Overview

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

Generate 3D Mapfile of the target for Object Tracker via Visual SLAM Tool. The Object Tracker loads the map file and renders 3D object on it. Refer to Visual SLAM Learning Guide to create a map more precisely while scanning 3D space.

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

The Object Tracker loads the map file and renders 3D object on it.
After target recognition and initial poses are acquired through the MAXST SDK, use AR Core for tracking.

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

Prerequisites
Object Tracker Introduction
Visual SLAM Tool
Tracker Coordinate System
Visual SLAM Learning Guide


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


2.1 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 after loading the map, refer to the following code.

ObjectFusionTrackerActivity.Java

@Override
protected void onCreate() {
    ...    
TrackerManager.getInstance().startTracker(TrackerManager.TRACKER_TYPE_OBJECT_FUSION);
    TrackerManager.getInstance().addTrackerData("ObjectTarget/obj_190712_7.3dmap", true);
TrackerManager.getInstance().addTrackerData("{"object_fusion":"set_length","object_name
":"obj_190712_7", "length":0.53}", true);
    TrackerManager.getInstance().loadTrackerData();
    ...
}

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

On the first call to addTrackerData (), the parameter must be passed the path of the 3dmap.
The addTrackerData () in the second call is used to determine the actual size of the 3dmap. (Unit: m)
Object_name is the file name of the 3dmap.
Length is the actual size of the two anchors you marked last when creating the 3dmap. (Please refer to Visual SLAM Tool)
You must enter the actual size of the target. If you do not enter the correct actual size, the content will not be augmented properly.
It must be run in the following order: startTracker (), addTrackerData (), loadTrackerData ().

ObjectFusionTrackerRenderer.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.2 Use Tracking Information

To use the Tracking information, refer to the following code.

ObjectFusionTrackerRenderer.Java

@Override
public void onDrawFrame(GL10 gl) {
    ...
    TrackingState state = TrackerManager.GetInstance().UpdateTrackingState();
    TrackingResult trackingResult = state.GetTrackingResult(); 
    if (trackingResult.getCount() > 0) {
        Trackable trackable = trackingResult.getTrackable(0);
        texturedCube.setTransform(trackable.getPoseMatrix());
        texturedCube.setTranslate(0, 0, -0.1f);
        texturedCube.setScale(0.4f, 0.4f, 0.2f);
        texturedCube.setProjectionMatrix(projectionMatrix);
        texturedCube.draw();
    }
}

2.3 Set Map

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

ObjectFusionTrackerActivity.Java

@Override
protected void onCreate(Bundle savedInstanceState) {
    ...
    TrackerManager.getInstance().addTrackerData(mapFileName, false);
    TrackerManager.getInstance().loadTrackerData();
}

Note - Map Compatibility
Starting with Visual Slam Tool 5.1.0, the file format for 3dmaps has changed. 3dmaps created in Visual Slam Tool 5.1.0 or later are supported by AR SDK 6.1.x or later. If you want to continue using AR SDK 6.0.x or earlier, please use Visual Slam Tool 5.0.8 Android.
Also, you can only add 3dmaps from the same version to Object Tracker.


2.3.1 Set Package

If you are using multiple object maps, packaging them in a 3dpkg file will greatly improve map loading speed and recognition speed.
Create a 3dpkg with MapPackager, call AddTrackerData() to register the package file, and call loadTrackerData() to track the target object.


※ Object Package(3dpkg) is available from AR SDK 6.1.0.
※ Only 3dmaps created in Visual Slam Tool 5.1.0 or later can be packaged as 3dpkg.
※ Only one 3dpkg can be added to Object Tracker.

2.4 Add / Replace Map

※ You can add multiple 3D maps to recognize one of multiple objects. We recommend to add up to three maps.

  1. Create a map file refer to Visual SLAM Tool.

  2. Copy the received map file to the desired path. The way to load map file in the assets folder and 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("obj_02_26_10_11_06.3dmap", true);
  • If copying to external storage, enter the full path and set the second parameter to false.
TrackerManager.getInstance().addTrackerData(mapFile.getAbsolutePath(), false);
  1. You must call loadTrackerData () after calling addTrackerData ().

  2. If you have an existing map file, call addTrackerData () and loadTrackerData () after calling TrackerManager.getInstance (). RemoveTrackerData ("").


3. References

These are additional references to develop Object Fusion Tracker


3.1 API Reference

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

MaxstAR Class

TrackerManager Class

CameraDevice Class


3.2 Sample

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

ObjectFusionTrackerActivity.Java

ObjectFusionTrackerRenderer.Java