# Object Offset while tracking the marker

**URL:** <https://forum.magicleap.cloud/t/object-offset-while-tracking-the-marker/3485>\
**Category:** Unity Development\
**Tags:** marker-tracker\
**Created:** [May 1, 2024, 3:47pm UTC](https://forum.magicleap.cloud/t/object-offset-while-tracking-the-marker/3485 "2024-05-01T15:47:25Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![darshak.sitapara.softwe](https://avatars.discourse-cdn.com/v4/letter/d/51bf81/32.png) [@darshak.sitapara.softwe](https://forum.magicleap.cloud/u/darshak.sitapara.softwe)\
**Post date:** [May 1, 2024, 3:47pm UTC](https://forum.magicleap.cloud/t/object-offset-while-tracking-the-marker/3485/1 "2024-05-01T15:47:25Z")

</div>

I have used a the code provided by magic leap for marker detection. the object is in world space, all the XR rig and main camera is at its origin or 0 position. It seems that selecting ArUco Dict does not help much either. I need the accurate position for the QR Code.  
I have also tried with vuforia and that is also not accurate in this case.  
here is the code

```auto
` private void OnTrackerResultsFound(MLMarkerTracker.MarkerData data)
 {
     Debug.Log($"{data.Type}===================dataType================");
     string id = "";
     float markerSize = .01f;

     switch (data.Type)
     {
         case MLMarkerTracker.MarkerType.Aruco_April:
             id = data.ArucoData.Id.ToString();
             markerSize = ArucoMarkerSize;
             break;

         case MLMarkerTracker.MarkerType.QR:
             id = _asciiEncoder.GetString(data.BinaryData.Data, 0, data.BinaryData.Data.Length);
             markerSize = QrCodeMarkerSize;
             break;
         case MLMarkerTracker.MarkerType.EAN_13:
         case MLMarkerTracker.MarkerType.UPC_A:
             id = _asciiEncoder.GetString(data.BinaryData.Data, 0, data.BinaryData.Data.Length);
             Debug.Log("No pose is given for marker type " + data.Type + " value is " + data.BinaryData.Data);
             break;
     }
     Debug.Log($"{id}===================dataType================");
     // GameObject marker = _markers[id];
     if (id == "TMF Center")
     {
         Debug.Log($"{data.ReprojectionError} Your reprojection error ===================");
         Debug.Log($"{data.Pose.position} Your reprojection error ===================");
         marker.transform.position = data.Pose.position;//-new Vector3(0.2f,0f,0f);
         marker.transform.rotation = data.Pose.rotation;
     }
    
 }`

```

**Unity Editor version** : 2022.3.7f1  
**ML2 OS version** :1.6.0  
**Unity SDK version** :1.4.0-dev2  
**Host OS** : Windows

**Error messages from logs** (syntax-highlighting is supported via Markdown):

---

<div class="post-metadata">

**Author:** ![kbabilinski](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/kbabilinski/32/19_2.png) [@kbabilinski](https://forum.magicleap.cloud/u/kbabilinski)\
**Post date:** [May 1, 2024, 6:12pm UTC](https://forum.magicleap.cloud/t/object-offset-while-tracking-the-marker/3485/2 "2024-05-01T18:12:44Z")

</div>

Do you mind providing more information? Do you see this offset in the Magic Leap Magic Leap Examples project?

Could you describe what happens when you try to detect markers? For example, how inaccurate is the position detection? Does it consistently happen with all types of markers (Aruco, QR, etc.)? How large is the marker in real-world dimensions? Can you provide a numerical estimate of the inaccuracy (distance in real-world units)

Are there specific environmental conditions under which the issue occurs or worsens, such as lighting conditions or physical space characteristics? Describe your lighting conditions (bright, dim, fluorescent, etc.). Are there reflective surfaces near the markers? Any unusual light sources?

---

<div class="post-metadata">

**Author:** ![darshak.sitapara.softwe](https://avatars.discourse-cdn.com/v4/letter/d/51bf81/32.png) [@darshak.sitapara.softwe](https://forum.magicleap.cloud/u/darshak.sitapara.softwe)\
**Post date:** [May 2, 2024, 4:32am UTC](https://forum.magicleap.cloud/t/object-offset-while-tracking-the-marker/3485/3 "2024-05-02T04:32:55Z")

</div>

Hi @kbabilinski  
Sure I don't mind 🙂, I am currently using MRTK 2.8.3 and setup project based on that.  
No I have not used Magic leap example project for QR Instead I followed the documentation [Marker Tracker Example](https://developer-docs.magicleap.cloud/docs/guides/unity/marker-tracking/marker-tracker-example/).

When I detect marker It is 10cm away from the marker in z also whenever I move and see it from any other place depending upon the movement it changes its position 10 cm near from the marker in z. also x and y position has 1 to 3 cm offsets.

Please also Note that My camera origins are ok and it is at zero position.

I am using QR only and also I have application where I will use this fix QR.  
Marker is around 10X10 cm^2

I have very Good Lighting(bright but not extremely bright) environment hence I don't think that is the issue.  
There is no reflective surface or any unusual light sources near the marker.

even the QR reader which is a Native application has almost same offset.

---

<div class="post-metadata">

**Author:** ![kbabilinski](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/kbabilinski/32/19_2.png) [@kbabilinski](https://forum.magicleap.cloud/u/kbabilinski)\
**Post date:** [May 2, 2024, 2:54pm UTC](https://forum.magicleap.cloud/t/object-offset-while-tracking-the-marker/3485/4 "2024-05-02T14:54:05Z")

</div>

Thank you for that information. Just a few more questions, when starting the Marker Tracker, did you specify the marker size? Does the specified size match the physical size of the markers? (Note: The non-openxr version of the marker tracker does not support size estimation.)

---

<div class="post-metadata">

**Author:** ![darshak.sitapara.softwe](https://avatars.discourse-cdn.com/v4/letter/d/51bf81/32.png) [@darshak.sitapara.softwe](https://forum.magicleap.cloud/u/darshak.sitapara.softwe)\
**Post date:** [May 3, 2024, 6:03am UTC](https://forum.magicleap.cloud/t/object-offset-while-tracking-the-marker/3485/5 "2024-05-03T06:03:46Z")

</div>

I am using the non-OpenXR version, I have already tried with different marker sizes which is available end result did not change.

> (Note: The non-openxr version of the marker tracker does not support size estimation.)  
> I don't know you are asking in which context?

- if you are asking about **ArUcoDict** it is

- **MLMarkerTracker.ArucoDictionaryName.DICT\_5X5\_100** and I have tried with different size

- if you are talking about **marker.transform.localScale = new Vector3(markerSize, markerSize, markerSize);** this than I don't need to use this one

---

<div class="post-metadata">

**Author:** ![kbabilinski](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/kbabilinski/32/19_2.png) [@kbabilinski](https://forum.magicleap.cloud/u/kbabilinski)\
**Post date:** [May 7, 2024, 3:56pm UTC](https://forum.magicleap.cloud/t/object-offset-while-tracking-the-marker/3485/6 "2024-05-07T15:56:48Z")

</div>

In the example linked above: [Marker Tracker Example | MagicLeap Developer Documentation](https://developer-docs.magicleap.cloud/docs/guides/unity/marker-tracking/marker-tracker-example/#simple-example)

The following values need to match the size of the physical markers (in meters)

```auto
 public float QrCodeMarkerSize = 0.1f;
 public float ArucoMarkerSize = 0.1f;

```

When you say:

> I have already tried with different marker sizes which is available end result did not change.

Does this mean the offset remains the same regardless how large or small the marker is? Or does the offset grow and shrink with the marker size?

---

<div class="post-metadata">

**Author:** ![darshak.sitapara.softwe](https://avatars.discourse-cdn.com/v4/letter/d/51bf81/32.png) [@darshak.sitapara.softwe](https://forum.magicleap.cloud/u/darshak.sitapara.softwe)\
**Post date:** [May 10, 2024, 12:24pm UTC](https://forum.magicleap.cloud/t/object-offset-while-tracking-the-marker/3485/7 "2024-05-10T12:24:21Z")

</div>

Hi Sorry for the late response I will try this on monday however 10cm =0.1m so i think tracking should be accurate but still I will try this as I have not changed this values.

---

<div class="post-metadata">

**Author:** ![darshak.sitapara.softwe](https://avatars.discourse-cdn.com/v4/letter/d/51bf81/32.png) [@darshak.sitapara.softwe](https://forum.magicleap.cloud/u/darshak.sitapara.softwe)\
**Post date:** [May 24, 2024, 4:16am UTC](https://forum.magicleap.cloud/t/object-offset-while-tracking-the-marker/3485/8 "2024-05-24T04:16:24Z")

</div>

Hi sorry other development process was in pipeline,  
I have tried the above solution the QR was 8 cm instead of 10 cm hence changed that value upon checking with this value QR was still offset hence I have manually tried to set the offset for now which is working little bit better according to my application.  
In my application I need 1second or so for tracking than script automatically turns off upon tracking QR. If the application is continuous tracking than there are issues with the offset. also when I place QR Horizontally parallel to ground the detection offset increases while vertically it gets more clear ouput.

---

<div class="post-metadata">

**Author:** ![kbabilinski](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/kbabilinski/32/19_2.png) [@kbabilinski](https://forum.magicleap.cloud/u/kbabilinski)\
**Post date:** [May 27, 2024, 5:59pm UTC](https://forum.magicleap.cloud/t/object-offset-while-tracking-the-marker/3485/9 "2024-05-27T17:59:20Z")

</div>

You will need to make sure to specify the physical size of the marker in the API for the offset to be reduced. I recommend tweaking the size until the offset is at a minimum.

If the virtual content appears further than the physical qr code, the size specified in the code is too large.

If the virtual content appears closer than the physical qr code, the size is too small.

I would also recommend testing with April tags as well and seeing if the quality changes. For QR codes we recommend using denser v2 data on QR codes that provide more points for tracking.

Also, when you detect the marker we also recommend minimizing the angle that the marker is scanned at. For example, asking the user to look at the marker head on and then pausing the tracker after sampling a few poses.

---

<div class="post-metadata">

**Author:** ![etucker](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/etucker/32/842_2.png) [@etucker](https://forum.magicleap.cloud/u/etucker)\
**Post date:** [July 26, 2024, 7:39pm UTC](https://forum.magicleap.cloud/t/object-offset-while-tracking-the-marker/3485/10 "2024-07-26T19:39:28Z")

</div>

Closed on July 26, 2024, 7:39pm UTC


