Can I serialize a spatial anchor to a byte array in some way?

Hi,

On HoloLens 2, you can serialize anchors using XRAnchorTransferBatch if you use the Microsoft.MixedReality.OpenXR package. We utilize this possibility to build a kind of custom 'Azure Spatial Anchors'. Is there a possibility to do this with some kind of API on Magic Leap 2? The idea is to transfer them between devices using a custom mechanism

Currently using:

  • Unity 2022.3.40f1
  • SDK 2.5.0-pre.R14.240821.127115.fb54a58
  • ML MRKT 1.2.0
  • OS 1.9.0

Hey @localjoost,

You currently cannot serialize Magic Leap Spatial Anchors.
But there are ways to transfer Spatial Anchors between devices!
Specifically, you can export a Localization Map from one device, import it on another device, and query the map origin to ensure that the content aligns properly between both devices.

Unlike Azure Anchors, Magic Leap Spatial Anchors are part of a larger and mostly static Localization Map and are imported and exported along with the Map when using the Localization Map API.

Note, the Localization Map API also allows you to query the Map Origin, which can be used as a reference point across multiple devices! You can use this to ensure your content is aligned properly on multiple devices using the same map.

We do not localize the anchors individually and instead localize into a rigid map. The Magic Leap 2 localizes and adjusts the localization map automatically as the user moves around the space. Multiple Spatial Anchors can be of help when pinning content across a large area (ie: a space mapped across multiple sessions via AR Cloud), if the model is slightly larger/smaller than the physical space, or if the device drifts during the initial mapping process. However, unlike Azure Anchors, multiple anchors are not required.

I hope this helps!