Try MAXST AR Fusion Tracker Now ✨

Object Tracker

Related documentations
Map Manager
Tracker Coordinate System
Visual SLAM Learning Guide

The Object Tracker loads the map file and renders 3D object on it.

Please refer Visual SLAM Learning Guide to create a map more precisely while scanning 3D space.

Create Instants
Start / Stop Tracker
Use Tracking Information
Set Map
Add / Replace Map
Change Tracking Mode

Create Instants

>ObjectTrackerViewController.mm

- (void)viewDidLoad
{
    ...
    trackingManager = [[MasTrackerManager alloc] init];
    cameraDevice = [[MasCameraDevice alloc] init];
}

Starting / Stopping the Tracker

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

>ObjectTrackerViewController.mm

- (void)resumeAR
{
    ...
    [trackingManager startTracker:TRACKER_TYPE_OBJECT];
}

- (void)pauseAR
{
    [trackingManager stopTracker];
    ...
}

Use Tracking Information

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

>ObjectTrackerViewController.mm

- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect
{
    ...
    MasTrackingState *trackingState = [trackingManager updateTrackingState];
    MasTrackingResult *result = [trackingState getTrackingResult];
    
   MasTrackedImage *trackedImage = [trackingState getImage];
    [backgroundCameraQuad draw:trackedImage projectionMatrix:[cameraDevice getBackgroundPlaneProjectionMatrix]];
    
    glEnable(GL_DEPTH_TEST);
    matrix_float4x4 projectionMatrix = [cameraDevice getProjectionMatrix];
    
    for (int i = 0; i < [result getCount]; i++)
    {
        MasTrackable *trackable = [result getTrackable:i];
        
        [texturedCube setProjectionMatrix:projectionMatrix];
        [texturedCube setPoseMatrix:[trackable getPose]];
        [texturedCube setTranslation:0.0f y:0.0f z:-0.0005f];
        [texturedCube setScale:0.4f y:0.4f z:0.001f];
        [texturedCube draw];
    }
    ...
}

Set Map

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

>ObjectTrackerViewController.mm

- (void)startEngine
{
    ...
    [trackingManager addTrackerData:objectTrackerMapPath];
    [trackingManager loadTrackerData];
}

Add / Replace Map

  1. Create a map file refer to Map Manager.

  2. Copy the received map file to the desired path.

  3. Set a map.

  4. If you have an existing map file, call function 'addTrackerData' and function 'loadTrackerData' after calling [trackingManager removeTrackerData]

Change Tracking Mode

2 Tracking Modes of Object Tracker:

JITTER_REDUCTION_ACTIVATION, JITTER_REDUCTION_DEACTIVATION

  • JITTER_REDUCTION_ACTIVATION: Default Setting. Jitter reduction.
[trackingManager setTrackingOption: JITTER_REDUCTION_ACTIVATION];
  • JITTER_REDUCTION_DEACTIVATION: Disable the jitter reduction option.
[trackingManager setTrackingOption: JITTER_REDUCTION_DEACTIVATION];