Marker Tracker iOS Tutorial

1. Overview
2. iOS Development
2.1 Create Instants
2.2 Start / Stop Tracker
2.3 Use Tracking Information
2.4 Set Target Marker
2.5 Change Tracking Mode
3. Reference
3.1 API Reference
3.2 Sample


1. Overview

Start developing MAXST ARSDK Marker Tracker on iOS Platform. Refer to Marker Tracker Introduction for detailed information.

By recognizing and tracking the provided markers, you can augment images, 3D objects or videos especially when there are plenty of targets. 8,192 Markers will be provided which were developed by MAXST itself.

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

Prerequisites
Marker Tracker Introduction
Marker
Tracker Coordinate System


2. iOS Development

Start developing on xCode using Objective-C. Refer to Requirements & Supports to find out which devices are supported.

ARSDK has to properly integrate on iOS UIViewController. Refer to Life Cycle documents for detail.


2.1 Create Instants

MarkerTrackerViewController.mm

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

2.2 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

MarkerTrackerViewController.mm

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

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

2.3 Use Tracking Information

You can get marker information in 'MasTrackable'. Marker Number is setted function 'getId' in 'MasTrackable'.

※ startTracker() should be called before

MarkerTrackerViewController.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]];

    matrix_float4x4 projectionMatrix = [cameraDevice getProjectionMatrix];
    int trackingCount = [result getCount];
    
    if(trackingCount > 0)
    {
        for (int i = 0; i < trackingCount; i++)
        {
            MasTrackable *trackable = [result getTrackable:i];
            
            recognizeID = [[NSString alloc] initWithFormat:@"%@ %@,", recognizeID, [trackable getId]];
            
            [texturedCube setProjectionMatrix:projectionMatrix];
            [texturedCube setPoseMatrix:[trackable getPose]];
            [texturedCube setTranslation:0.0f y:0.0f z:-0.05f];
            [texturedCube setScale:1.0f y:1.0f z:0.1f];
            [texturedCube draw];
            ...
        }
    }
    ...
}

2.4 Set Target Marker

Once you enter the target marker size (m) and call the addTrackerData, you can track the marker in real scale. Refer to the following code to set a target marker.

MarkerTrackerViewController.mm

- (void)startEngine
{
    ...
    [trackingManager startTracker:TRACKER_TYPE_MARKER];
    [trackingManager addTrackerData:@"{"marker":"set_scale","id":"0", "scale":0.042}"];
    [trackingManager loadTrackerData];
}


2.5 Change Tracking Mode

4 Tracking Modes of Marker Tracker:

  • NORMAL_TRACKING
  • ENHANCED_TRACKING
  • JITTER_REDUCTION_ACTIVATION
  • JITTER_REDUCTION_DEACTIVATION
  • NORMAL_TRACKING: Default Setting. Traceable multiple target image.
[trackingManager setTrackingOption:NORMAL_TRACKING];
  • ENHANCED_TRACKING: This feature tracks the marker intensively that recognizes the first.
[trackingManager setTrackingOption:ENHANCED_TRACKING];
  • JITTER_REDUCTION_ACTIVATION: Jitter reduction.
[trackingManager setTrackingOption: JITTER_REDUCTION_ACTIVATION];
  • JITTER_REDUCTION_DEACTIVATION: Disable the jitter reduction option.

3. References

These are additional references to develop Marker Tracker


3.1 API Reference

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

MaxstAR Class

TrackerManager Class

CameraDevice Class


3.2 Sample

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

MarkerTrackerViewController.mm