Try MAXST AR Fusion Tracker Now ✨

Object Tracker Uwp Tutorial

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


1. Overview

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

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

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.

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


2. Uwp 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

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

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

ObjectTrackerActivity.Java

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

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

2.2 Use Tracking Information

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

※ startTracker() should be called before

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

ObjectTrackerActivity.Java

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

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 ("").


2.5 Change Tracking Mode

2 Tracking Modes of Object Tracker:

  • NORMAL_TRACKING
  • EXTENDED_TRACKING
  • EXTENDED_TRACKING: Default Setting. Track surrounded environment beyond a trained object.
TrackerManager.getInstance().setTrackingOption(TrackerManager.TrackingOption.EXTENDED_TRACKING);
  • NORMAL_TRACKING: Track only a trained object.
TrackerManager.getInstance().setTrackingOption(TrackerManager.TrackingOption.NORMAL_TRACKING);

3. References

These are additional references to develop Object Tracker


3.1 API Reference

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

MaxstAR Class

TrackerManager Class

CameraDevice Class


3.2 Sample

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

ObjectTrackerActivity.Java

ObjectTrackerRenderer.Java