Try MAXST AR Fusion Tracker Now ✨

Instant Fusion Tracker

Related documentations
Tracker Coordinate System

The Instant Tracker instantly scans the planar surface in the camera frame and recognizes the space with sensors. You can find the rendered 3D object on the space.
After target recognition and initial poses are acquired through the MAXST SDK, use 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 Instant Tracker is that the existing Instant 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. Instant 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
Create Instant Target Data

Create Instants

>InstantTrackerViewController.swift

var cameraDevice:MasCameraDevice = MasCameraDevice()
var sensorDevice:MasSensorDevice = MasSensorDevice()
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, refer to the following code.

>InstantTrackerViewController.swift

func startEngine() {
        ...
            trackingManager.start(.TRACKER_TYPE_INSTANT_FUSION)
        ...
    }

@objc func pauseAR()
{
    ...
    trackingManager.start(. TRACKER_TYPE_INSTANT_FUSION)
}

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

Use Tracking Information

To augment an object using Tracking results, refer to the following code.

>InstantTrackerViewController.swift

func renderer(_ renderer: SCNSceneRenderer, willRenderScene scene: SCNScene, atTime time: TimeInterval) {
    if backgroundCameraQuad == nil {
        backgroundCameraQuad = BackgroundCameraQuad(device: renderer.device, pixelFormat: renderer.colorPixelFormat)
    }
    
    let commandEncoder:MTLRenderCommandEncoder = renderer.currentRenderCommandEncoder!

    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 {
        if(backgroundImage.getData() != nil) {
            cameraQuad.setProjectionMatrix(projectionMatrix: backgroundProjectionMatrix)
            cameraQuad.draw(commandEncoder: commandEncoder, image: backgroundImage)
        }
    }
    
    let trackingCount:Int32 = result.getCount()
            
    if trackingCount > 0 && fusionState == 1 {
        let trackable:MasTrackable = result.getTrackable(0)
        let poseMatrix:matrix_float4x4 = trackable.getPose()
        textureCube!.setProjectionMatrix(projectionMatrix: projectionMatrix)
        textureCube!.setPoseMatrix(poseMatrix: poseMatrix)
        textureCube!.setTranslation(x: panTranslateX, y:0.0 , z: panTranslateY)
        textureCube!.setScale(x: 0.1, y:  0.1, z: 0.00001)
        textureCube!.draw(commandEncoder: commandEncoder)
    }
}

Create Instant Target Data

You can create new data only when it is not in Tracking state. Refer to the following code.

>InstantFusionViewController.swift

@IBAction func clickStartButton(_ sender: Any) {
    let button:UIButton = sender as! UIButton
    
    if button.titleLabel?.text == "START" {
        
        trackingManager.findSurface()
        button.setTitle("STOP", for: .normal)
    } else if button.titleLabel?.text == "STOP"{
        trackingManager.quitFindingSurface()
        button.setTitle("START", for: .normal)
    }
}