QR / Barcode Reader

1. Definition
2. Video See-Through
2.1. Make QR / Barcode Scene
2.2. Start / Stop Reader
2.3. Use Reading Information
3. Optical See-Through
3.1. Make QR / Barcode Scene


1. Definition

It recognizes QR / Barcode.

2. Video See-Through

2.1. Make QR / Barcode Scene

  1. Install MAXST AR SDK for Unity.

  2. Create the new scene.

  3. Delete the Main Camera that exists by default and add 'Assets > MaxstAR > Prefabs > ARCamera' to the scene.

    codePrefab

    ※ If you build an application, you must add a License Key to ARCamera.

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

    codeSample

  5. Add a button and two Texts. And then drag and drop those elements into the GameObject's Insepctor window.

    codeText

  6. Set the StartCodeScan () function in the Click event of the Button.

    codeBtn

  7. When you press the 'play' button and scan the QRcode/Barcode with the camera, the value of the code is augmented on the screen in the Text position.

  8. Connect the smart glasses to the PC to build, Select ARCamera > Configuration > Wearable Type to None and build.

    SmartGlasses_Unity_SetupGuide7_.png

2.2. Start / Stop Reader

To start / stop Reader, refer to the following code.

>CodeScanSample.cs

void Update()
{
    ...
    TrackerManager.GetInstance().StartTracker(TrackerManager.TRACKER_TYPE_CODE_SCANNER);
    ...
}

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

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

2.3. Use Reading Information

When you point the camera to QR / Barcode, the code name will be displayed on the screen. Refer to the following code to use the Reading information.

>CodeScanSample.cs

void Update()
{
    ...
    IntPtr codeScanResultPtr = TrackerManager.GetInstance().GetCodeScanResult();
    if (codeScanResultPtr == IntPtr.Zero)
    {
        return;
    }
    string strCode = Marshal.PtrToStringAnsi(codeScanResultPtr);
    if (strCode != null && strCode.Length > 0)
    {
        targetText.text = strCode;
    }
}

3. Optical See-Through

When developing with Optical See-Through, the process is the same as developing with Video See-Through if you select the Wearable Type as Optical See-Through. See below for details.

3.1. Make QR / Barcode Scene

  1. Connect the smart glasses to the PC to build, Select ARCamera > Configuration > Wearable Type to Optical See Through and build.

    SmartGlasses_Unity_SetupGuide6_.png