---
title: "Comment by Hubert (Sathaporn) Hu on \"QR Code tracking in the HoloLens\" | Hashnode"
description: "Thanks Shayne, this code saved my project. The code is outdated though if you are using OpenXR. There&#39;s now a better way to compute the QR Code&#39;s pose."
url: "https://hashnode.com/posts/qr-code-tracking-in-the-hololens/604a7f27ad1cac7d577dfa06/comment/61d9d782cda0d0294b696c38"
---

[Discussion](https://hashnode.com/posts/qr-code-tracking-in-the-hololens/604a7f27ad1cac7d577dfa06)

Comment [QR Code tracking in the HoloLens](https://hashnode.com/posts/qr-code-tracking-in-the-hololens/604a7f27ad1cac7d577dfa06)

[Hubert (Sathaporn) Hu](https://hashnode.com/@shubertkai)

[Jan 8, 2022](https://hashnode.com/posts/qr-code-tracking-in-the-hololens/604a7f27ad1cac7d577dfa06/comment/61d9d782cda0d0294b696c38)

Thanks Shayne, this code saved my project.

The code is outdated though if you are using OpenXR. There's now a better way to compute the QR Code's pose. For QRCodeInformation, I'm adding another field called "SpatialGraphNodeID":

```
public class QRCodeInformation
{
    public string Data { get; set; }
    public float Length { get; set; }
#if WINDOWS_UWP
    public SpatialCoordinateSystem QRSpatialCoordinateSystem { get; set; }
    public Guid SpatialGraphNodeID { get; set; } 
    public QRCodeInformation(string data, SpatialCoordinateSystem qrSpatialCoordinateSystem, float length, Guid spatialGraphNodeID)
    {
        Data = data;
        Length = length;
        QRSpatialCoordinateSystem = qrSpatialCoordinateSystem;
        SpatialGraphNodeID = spatialGraphNodeID;
    }
#endif
    public QRCodeInformation() { }
}
```

I had to change some code to match the new constructor's signature.

Then, to find the pose, I use this code instead:

```
SpatialGraphNode node = SpatialGraphNode.FromStaticNodeId(SpatialGraphNodeID);
        Pose pose;
        if (node != null && node.TryLocate(FrameTime.OnUpdate, out pose))
        {
            if (CameraCache.Main.transform.parent != null)
            {
                pose = pose.GetTransformedBy(CameraCache.Main.transform.parent);
            }
            marker.transform.SetPositionAndRotation(pose.position, pose.rotation);
        }
```

This snippet is from: [Microsoft' QR Source Code](https://github.com/yl-msft/QRTracking/blob/main/SampleQRCodes/Assets/Scripts/SpatialGraphNodeTracker.cs)

I hate making public posts very much. However, I think this would be a very good PSA for anyone who's about to go Kylo Ren on their equipment.

PS: I could clean up your code to remove any WinRT reference too, but I just have no fight left at the moment.

[Shayne Kiekebosch](https://hashnode.com/@ShayneK)

[Jan 12, 2022](https://hashnode.com/posts/qr-code-tracking-in-the-hololens/604a7f27ad1cac7d577dfa06/comment/61d9d782cda0d0294b696c38#reply-61df52746bf5f0642b8f1347)

Oh cool thanks [Hubert (Sathaporn) Hu](https://hashnode.com/@shubertkai). I have moved on from HoloLens development so I don't have access to any of my old code. I'll edit the post for OpenXR to come look at your comment.

[Hubert (Sathaporn) Hu](https://hashnode.com/@shubertkai)

[Jan 12, 2022](https://hashnode.com/posts/qr-code-tracking-in-the-hololens/604a7f27ad1cac7d577dfa06/comment/61d9d782cda0d0294b696c38#reply-61df5d976bf5f0642b8f1452)

[Shayne Kiekebosch](https://hashnode.com/@ShayneK), I found out that the pose still needs to be transformed though - so the matrix conversion is still useful.
