QR Code 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.

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

Make QR Code 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 > MarkerTrackerSample’ as a component.

    Gameobject.jpg

  5. Enter -1 for the Real Size.

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

After setting the QR Code categories, refer to the following code to start / stop the tracker.
>QrCodeTrackerSample.cs


    void Start()
    {
        …
        TrackerManager.GetInstance().StartTracker(TrackerManager.TRACKER_TYPE_QR_TRACKER);
        …
    }
    void OnApplicationPause(bool pause)
    {
        …
        TrackerManager.GetInstance().StopTracker();
        …
    }
    void OnDestroy()
    {
        …
        TrackerManager.GetInstance().StopTracker();
        TrackerManager.GetInstance().DestroyTracker();
        …
    }

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());
                }
            }
        }
    }

Change Tracking Mode

2 Tracking Modes of QR Code Tracker:

JITTER_REDUCTION_ACTIVATION, JITTER_REDUCTION_DEACTIVATION

-JITTER_REDUCTION_ACTIVATION: Default setting. Calibrate the jitter using Kalman filter when tracking. When moving the camera or target sharply, the movement of the augmented content may appear to have a slight delay.

TrackerManager.GetInstance().SetTrackingOption(TrackerManager.TrackingOption.JITTER_REDUCTION_ACTIVATION);
  • JITTER_REDUCTION_DEACTIVATION: Disable the jitter reduction option.
TrackerManager.GetInstance().SetTrackingOption(TrackerManager.TrackingOption.JITTER_REDUCTION_DEACTIVATION);