QR Code Fusion Tracker

Related documentations
Tracker Coordinate System in Unity

By recognizing / tracking QR Code, you can augment various contents. You can augment the information of QR Code used in real life, the URL link button using this information, the 3D model, or image. QR Code Model 2 or higher is supported. After target recognition and initial poses are acquired through the MAXST SDK, use ARCore/ARKit for tracking.
※To use the AR Core / AR Kit, you must enter the actual size. (See Start / Stop Tracker)

The biggest difference from the existing QR Code Tracker is that the existing QR Code 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. QR Code Fusion Tracker, on the other hand, tracks through the AR Core/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.

Make QR Code Fusion Tracker Scene
Set QR Code Category
Start / Stop Tracker
Use Tracking Information
Change Tracking Mode

Make QR Code Fusion Tracker Scene

  1. Install the MAXST AR SDK for Unity.

  2. Create the new scene.

  3. Delete the Main Camera(default) and add QrCodeTrackable at ‘Project Tab > Assets > MaxstAR > Prefabs > ARCamera, QrCodeTrackable’ to the Scene.

    arcamera_qrcode.jpg

  4. Create an empty object and add 'Assets > MaxstARSamples > Scripts > QRCodeFusionTrackerSample’ as a component.

    Gameobject.jpg

  5. In Real Size, enter the actual size of one side of the QR code.

    QRCodeFusion.png

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

  7. After clicking 'Play' button, the content will be augmented once you point the camera to the target QR Code.

Set QR Code Searching words

If you want to augment all of the recognized QR Codes in the same way, please leave the QR Code searching words blank. On the other hand, if you want to augment the QR Code in different ways, add QRCodeTrackable to the scene and enter the special keywords in the QR Code internal information into the QR Code searching words section. Please place another content in new QRCodeTrackable under this Scene. The newly added content will be augmented if you highlight the QR Code containing the keyword.

※ Please make sure that one QRCodeTrackable added to the scene matches one category keyword with 1:1, and the special keywords to be entered into the category should be unique in one QR Code.

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 setting the QR Code categories, refer to the following code to start / stop the tracker.
>QrCodeTrackerSample.cs


    void Start()
    {
        …

CameraDevice.GetInstance().SetARCoreTexture();
TrackerManager.GetInstance().StartTracker(TrackerManager.TRACKER_TYPE_QR_FUSION);
AddTrackerData();
        …
    }
    private void AddTrackerData()
    {
        TrackerManager.GetInstance().AddTrackerData("{\"qr_fusion\":\"set_scale\",\"content\":\"wikipedia\", \"scale\":0.14}", false);
        TrackerManager.GetInstance().LoadTrackerData();
    }
    void OnApplicationPause(bool pause)
    {
        …
        TrackerManager.GetInstance().StopTracker();
        …
    }
    void OnDestroy()
    {
        …
        TrackerManager.GetInstance().StopTracker();
        TrackerManager.GetInstance().DestroyTracker();
        …
    }

You need to pass the exact actual size as a parameter of scale via addTrackerData. (Unit: m)
Content is a phrase included in the information of the QR code. SetScale is the actual size of the QR code. The shape of the QR code is square.
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.

>QRCodeTrackerSample.cs


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

        for (int i = 0; i < trackingResult.GetCount(); i++)
        {
            Trackable trackable = trackingResult.GetTrackable(i);

            bool isNotFound = true;

            foreach (var key in QrCodeTrackablesMap.Keys)
            {
                if (key.Length < 1) continue;

                if (trackable.GetName().Contains(key))
                {
                    foreach (var qrCodeTrackable in QrCodeTrackablesMap[key])
                    {
                        qrCodeTrackable.OnTrackSuccess("", trackable.GetName(), trackable.GetPose());
                    }

                    isNotFound = false;
                    break;
                }
            }

            if (isNotFound && QrCodeTrackablesMap.ContainsKey(defaultCategoryName))
            {
                foreach (var qrCodeTrackable in QrCodeTrackablesMap[defaultCategoryName])
                {
                    qrCodeTrackable.OnTrackSuccess("", trackable.GetName(), trackable.GetPose());
                }
            }
        }
    }