Try MAXST AR Fusion Tracker Now ✨

Marker Fusion Tracker

Related documentations
Marker
Tracker Coordinate System

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 AR Core/AR Kit for tracking.
※To use the AR Kit, you must enter the actual size. (See Start / Stop Tracker)

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 AR Kit, 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.

Create Instants
Start / Stop Tracker
Use Tracking Information
Change Tracking Mode

Create Instants

>MarkerFusionTrackerViewController.swift

    var trackingManager:MasTrackerManager = MasTrackerManager()

Start / Stop Tracker

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

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

>MarkerFusionTrackerViewController.swift


    func startEngine() {self.trackingManager.start(.TRACKER_TYPE_MARKER_FUSION)
            self.trackingManager.addTrackerData("{\"marker\":\"set_scale\",\"id\":\"0\", \"scale\":0.042}");
            self.trackingManager.loadTrackerData()
    }

@objc func resumeAR() {
        trackingManager.start(.TRACKER_TYPE_MARKER_FUSION)
}

@objc func pauseAR() {
        trackingManager.stopTracker()
}

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

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

>MarkerFusionTrackerViewController.swift

func draw(in view: MTKView) {
    ...
    let trackingState:MasTrackingState = trackingManager.updateTrackingState()
    let result:MasTrackingResult = trackingState.getTrackingResult()
    
    let backgroundImage:MasTrackedImage = trackingState.getImage()
    var backgroundProjectionMatrix:matrix_float4x4 = cameraDevice.getBackgroundPlaneProjectionMatrix()
    
    let projectionMatrix:matrix_float4x4 = cameraDevice.getProjectionMatrix()
    
    if let cameraQuad = backgroundCameraQuad {
        cameraQuad.setProjectionMatrix(projectionMatrix: backgroundProjectionMatrix)
        cameraQuad.draw(commandEncoder: commandEncoder, image: backgroundImage)
    }
    
    let trackingCount:Int32 = result.getCount()
    
    var recogMarkerID:String = "Recognized Marker ID : "
    if trackingCount > 0 {
        for i in stride(from: 0, to: trackingCount, by: 1) {
            let trackable:MasTrackable = result.getTrackable(i)
            let poseMatrix:matrix_float4x4 = trackable.getPose()
            
            recogMarkerID = recogMarkerID + trackable.getId() + ", "
            textureCube!.setProjectionMatrix(projectionMatrix: projectionMatrix)
            textureCube!.setPoseMatrix(poseMatrix: poseMatrix)
            textureCube!.setTranslation(x: 0.0, y: 0.0, z: -0.05)
            textureCube!.setScale(x: 1.0, y: 1.0, z: 0.1)
            textureCube!.draw(commandEncoder: commandEncoder)
        }
    }
    ...
}

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.

>MarkerFusionTrackerViewController.swift

func startEngine() {
...
        self.trackingManager.start(.TRACKER_TYPE_MARKER_FUSION)
        self.trackingManager.setTrackingOption(.ENHANCED_TRACKING)
        self.trackingManager.addTrackerData("{\"marker\":\"scale\",\"all\":1.3, \"id0\" : 0.5, \"id1\" : 0.5, \"id3\" : 0.4, \"id10\" : 1.5}");
        self.trackingManager.loadTrackerData()
    }