Object Offset while tracking the marker

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

` private void OnTrackerResultsFound(MLMarkerTracker.MarkerData data)
     string id = "";
     float markerSize = .01f;

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

         case MLMarkerTracker.MarkerType.QR:
             id = _asciiEncoder.GetString(data.BinaryData.Data, 0, data.BinaryData.Data.Length);
             markerSize = QrCodeMarkerSize;
         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);
     // 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):

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?

Hi @kbabilinski
Sure I don't mind :slightly_smiling_face:, 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.

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.

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

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

In the example linked above: Marker Tracker Example | MagicLeap Developer Documentation

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

 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?

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.