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)
 {
     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):

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.

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.

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.