Marker Fusion Tracker

Related documentations
Marker
Tracker Coordinate System in Unity

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. After target recognition and initial poses are acquired through the MAXST SDK, use Nreal SLAM for tracking.

The biggest difference from the existing Marker Tracker is that the existing Marker Tracker tracks through the frame input from the RGB camera. Due to the nature of RGB cameras, tracking will be lost if the target deviates from the camera frame or if there are few feature points. Marker Fusion Tracker, on the other hand, tracks through the Nreal SLAM, which allows the target to deviate from the camera frame or keep the feature point at least without tracking, due to the nature of learning the environment in which the current target lies.

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

Make Marker Fusion Tracker Scene
Set Target Marker
Start / Stop Tracker
Use Tracking Information
[Change Tracking Mode]

Make Marker Fusion Tracker Scene

  1. Install MAXST AR SDK For Unity, MAXSTARSDK_FOR_NRSDK, and NRSDKForUnity_Release.

  2. Create a new scene.

  3. Delete the Main Camera that exists by default, then go to Assets > NRSDK > Prefabs > NRCameraRig, NRInput, Assets > MaxstAR > Prefabs >MarkerTrackable to your scene.

    Prefab MarkerPrefab

    ※ In the Project window, you need to add the license key to Assets > Resources > MaxstAR > Configuration.

  4. In the GameObject tab at the top, create an empty object and add the Assets > MaxstARSamples > Scripts >MarkerTrackerSampleForNreal script as a component.

    MarkerSample

  5. Go to 'MarkerGroup > Inspector > Marker Size' and input the size of the actual marker in meters. If the marker size is 10cm, enter 0.1(If the markers' size is various, uncheck 'Apply All' under Marker Size and enter each size at MarkerTrackable).

    MarkerCube

  6. Copy the MarkerTrackable to the MarkerGroup as many markers as it is used in the AR. Then enter the Marker ID(0~8191) for each MarkerTrackable.

  7. Create a content which will be augmented (eg. cube) as a child of ImageTrakable and adjust its size and position.

  8. After clicking 'Play' button, the content will be augmented once you point the camera to the target marker.

※ Target marker file is located at Marker.

Set Target Marker

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

>MarkerTrackerSampleForNreal.cs

private void AddTrackerData()
{
    foreach (var trackable in markerTrackableMap)
    {
        if (trackable.Value.TrackerDataFileName.Length == 0)
        {
            continue;
        }

    TrackerManager.GetInstance().AddTrackerData(trackable.Value.TrackerDataFileName);
    }

    TrackerManager.GetInstance().LoadTrackerData();
}

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.

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

>MarkerTrackerSampleForNreal.cs

void Start()
{
    ...
    CameraDevice.GetInstance().SetARCoreTexture();
    TrackerManager.GetInstance().StartTracker(TrackerManager.TRACKER_TYPE_MARKER_FUSION);
    AddTrackerData();
    ...
}

private void AddTrackerData()
{
   ...
   TrackerManager.GetInstance().AddTrackerData("{\"marker_fusion\":\"set_scale\",\"id\":\"0\", \"scale\":0.042}", false);
   TrackerManager.GetInstance().LoadTrackerData();
}

void OnApplicationPause(bool pause)
{
    ...
    TrackerManager.GetInstance().StopTracker();
    ...
}

void OnDestroy()
{
    ...
    TrackerManager.GetInstance().StopTracker();
    TrackerManager.GetInstance().DestroyTracker();
    ...
}

id is the unique number of the marker.
scale is the actual size of the marker.
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 ().

Use Tracking Information

Refer to the following code to use the tracking information.

>MarkerTrackerSampleForNreal.cs

void Update()
{
    ...
    TrackingResult trackingResult = state.GetTrackingResult();

    for (int i = 0; i < trackingResult.GetCount(); i++)
    {
        Trackable trackable = trackingResult.GetTrackable(i);
        int markerId = -1;
        if (int.TryParse(trackable.GetName(), out markerId)) 
        {
            if (markerTrackableMap.ContainsKey(markerId))
            {
                markerTrackableMap[markerId].OnTrackSuccess(trackable.GetId(), trackable.GetName(), trackable.GetNRealPose());
            }
        }
    }
}