# MLWorldCameraFrame.camera\_pose to Unity mapping

**URL:** <https://forum.magicleap.cloud/t/mlworldcameraframe-camera-pose-to-unity-mapping/4830>\
**Category:** Native Development\
**Tags:** unity\
**Created:** [December 18, 2024, 3:49pm UTC](https://forum.magicleap.cloud/t/mlworldcameraframe-camera-pose-to-unity-mapping/4830 "2024-12-18T15:49:41Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![LeapFrog](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/leapfrog/32/2247_2.png) [@LeapFrog](https://forum.magicleap.cloud/u/LeapFrog)\
**Post date:** [December 18, 2024, 3:49pm UTC](https://forum.magicleap.cloud/t/mlworldcameraframe-camera-pose-to-unity-mapping/4830/1 "2024-12-18T15:49:41Z")

</div>

Hola,

**ML2 OS version** : 1.10.0  
**MLSDK version** : 1.10.0  
**Host OS** : Win

We use the World Camera images to reconstruct poses of our custom marker in the world camera frame. The mapping from the camera frame to the world frame using the [MLWorldCameraFrame.camera\_pose](https://developer-docs.magicleap.cloud/docs/api-ref/api/Modules/group ___pixel_sensors/group___ w_cam/struct_m_l_world_camera_frame/#mltransform-camera-pose) seems to work fine: When i walk around the marker its pose remains almost constant.

From within Unity we access the custom marker poses via an android AAR plugin. This all works but how do i convert from the "world co-ordinate system" referenced in the [MLWorldCameraFrame](https://developer-docs.magicleap.cloud/docs/api-ref/api/Modules/group ___pixel_sensors/group___ w_cam/struct_m_l_world_camera_frame/) docs to the respective Unity coordinate system ? I there any [Magic Leap Native SDK (C API)](https://developer-docs.magicleap.cloud/docs/api-ref/api/indexpage/) function we can use for that ?

Btw. i have Zero (-0) Unity experience 😉

Cheers

---

<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:** [December 18, 2024, 5:44pm UTC](https://forum.magicleap.cloud/t/mlworldcameraframe-camera-pose-to-unity-mapping/4830/2 "2024-12-18T17:44:02Z")

</div>

If you are using Magic Leap SDK instead of the OpenXR plugin - you can try the following in Unity:

1. Select the Main camera under the Magic Leap Rig in Unity.
2. Make sure the XR Rig component does not have any offsets applied in the hierarchy or inspector.
3. Look for the Magic Leap Camera Component in the Inspector.
4. Disable the Recenter XR Origin on Start option.
5. Then test the App again and see if the poses align properly.

---

<div class="post-metadata">

**Author:** ![filo.cino](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/filo.cino/32/2307_2.png) [@filo.cino](https://forum.magicleap.cloud/u/filo.cino)\
**Post date:** [December 19, 2024, 8:19am UTC](https://forum.magicleap.cloud/t/mlworldcameraframe-camera-pose-to-unity-mapping/4830/3 "2024-12-19T08:19:46Z")

</div>

Hi,  
we are currently on a MRTK OpenXR project. The XR Rig is _MRTK XR Rig - MagicLeap - OpenXR_, which has no offset. There's a 1.6 camera offset on Y (the default one).  
If I navigate to _Magic Leap Camera Script_ (which seems to be deprecated) on the Main Camera, the _Recenter XR Origin at Start_ is already set false.

What I did was to Camera.main.transform.TransformPoint() the real-world pose and then add a manual offset to fix the misalignment camera-\>eye lens center...

Is there a better (and more precise) way to do it?

Thanks

---

<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:** [December 19, 2024, 8:31pm UTC](https://forum.magicleap.cloud/t/mlworldcameraframe-camera-pose-to-unity-mapping/4830/4 "2024-12-19T20:31:55Z")

</div>

What type of offset are you seeing when you transform the point?

If you are using the MLSDK in conjunction with OpenXR you will need to make sure your application has the origin set to Unbounded Space to have the same origin as the Legacy MLSDK:

> **[Additional Features | MagicLeap Developer Documentation](https://developer-docs.magicleap.cloud/docs/guides/unity-openxr/additional-features/#using-mlsdk-perception-pose-data)**
>
> Overview

---

<div class="post-metadata">

**Author:** ![filo.cino](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/filo.cino/32/2307_2.png) [@filo.cino](https://forum.magicleap.cloud/u/filo.cino)\
**Post date:** [December 20, 2024, 7:58am UTC](https://forum.magicleap.cloud/t/mlworldcameraframe-camera-pose-to-unity-mapping/4830/5 "2024-12-20T07:58:52Z")

</div>

I'm measuring around:  
x: 5mm to the right  
y: 27.5mm up  
z: 38mm forward

---

<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:** [December 20, 2024, 6:25pm UTC](https://forum.magicleap.cloud/t/mlworldcameraframe-camera-pose-to-unity-mapping/4830/6 "2024-12-20T18:25:33Z")

</div>

Do you feel like it roughly matches the pose of the sensor relative to the center of the two displays? Have you tried the unbounded space?

---

<div class="post-metadata">

**Author:** ![filo.cino](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/filo.cino/32/2307_2.png) [@filo.cino](https://forum.magicleap.cloud/u/filo.cino)\
**Post date:** [December 23, 2024, 8:37am UTC](https://forum.magicleap.cloud/t/mlworldcameraframe-camera-pose-to-unity-mapping/4830/7 "2024-12-23T08:37:28Z")

</div>

Not really,  
And yes, I've tried Unbounded Spaces but nothing seems to change

---

<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:** [December 26, 2024, 8:15pm UTC](https://forum.magicleap.cloud/t/mlworldcameraframe-camera-pose-to-unity-mapping/4830/8 "2024-12-26T20:15:37Z")

</div>

A couple of things you could try:

Option 1: Pixel Sensor API (Recommended)  
Have you looked into using the OpenXR Pixel Sensor API? It's the preferred way to access sensor data these days and plays nicely with OpenXR.

Option 2: Legacy MLSDK  
If you're sticking with the older way, you may want to try using the legacy MLSDK workflow.

* * *

Testing if Unbounded Space is being set properly in Unity

To test if the unbounded space is being set properly in Unity, follow these steps:

1. Create a new scene.
2. Go to the Package Manager and import the XR Rig package from the Magic Leap SDK.
3. In the inspector, set the XR Origin to "device".
4. Place a 3D cube into your Unity scene, so that it can be viewed by the main camera
5. Run the application and see if the virtual content shifts when you switch the tracking to unbounded.

Note: Both Perception Snapshots setting and the Reference Space feature need to be enabled in your Project's OpenXR Settings.

* * *

Some background information based on the MLCamera:

The `MLCVCameraGetFramePose` gives you the position of the camera in `world origin` coordinate system which is not a concept in OpenXR. However it happens to align with our implementation of `msft_unbounded_ref_space` so we take advantage of that to allow developers to express the position of the pose in OpenXR as they choose.

---

<div class="post-metadata">

**Author:** ![idanc](https://avatars.discourse-cdn.com/v4/letter/i/a698b9/32.png) [@idanc](https://forum.magicleap.cloud/u/idanc)\
**Post date:** [January 9, 2025, 4:51pm UTC](https://forum.magicleap.cloud/t/mlworldcameraframe-camera-pose-to-unity-mapping/4830/9 "2025-01-09T16:51:16Z")

</div>

I have similar issue.  
I'm using the legacy MLSDK default configurations:

- Under the XR Rig game object the session origin tracking mode origin set to Device
- In the Main Camera game object, Recenter XR Origin At Start is disabled
- I configure the inputSubsystem tracking origin mode to unbound and called to `TryRecenter` as defined in the Unity (OpenXR) MLCamera documentations ([link](https://developer-docs.magicleap.cloud/docs/guides/unity-openxr/ml-camera/#using-mlsdk-perception-pose-data))

But when I call to `MLCVCamera.GetFramePose(extras.VCamTimestamp, out var outTransform)` I get the transformation between the frame and the origin where the magic leap powered up and not where my application started.

I tried to set the subsystem tracking mode to Device, but the outTransform was the same.

I don't know what else can be done

---

<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:** [January 9, 2025, 4:53pm UTC](https://forum.magicleap.cloud/t/mlworldcameraframe-camera-pose-to-unity-mapping/4830/10 "2025-01-09T16:53:20Z")

</div>

Do you mind creating a new post with the issue that you are experiencing and include the MLSDK and OS version you are using along with additional information about which XR Plugin-in provider you are using (OpenXR vs legacy XR Magic Leap )
