microsoft / OpenXR-MixedReality

OpenXR samples and preview headers for HoloLens and Windows Mixed Reality developers familiar with Visual Studio
https://aka.ms/openxr
MIT License
335 stars 95 forks source link

Spatial Anchor Import/Export extension #99

Closed Dakror closed 2 years ago

Dakror commented 2 years ago

In a previous preview runtime, an extension to import & export spatial anchors was present. This has however recently been removed from the repository.

Is there any chance it will make a return soon? For our application sharing spatial anchors between devices is a critical component and we would like to use the OpenXR extension.

yl-msft commented 2 years ago

@Dakror There are several group of WinRT anchor import export APIs, for example,

Your feedback didn't specify which anchor feature you were using for the "import & export". Since you mentioned a recently removed preview extensions, I assume you were referring to the "SpatialAnchorExporter" we've been reviewing for the past few months. This set of anchor API are used for Azure Spatial Anchor (a.k.a. ASA), and we recommend you to use ASA team's SDK instead of using the WinRT API directly.

Eitherway, if you do want to use the WinRT SpatialAnchor APIs as above, you can use this XR_MSFT_perception_anchor_interop extension to convert a XrSpatialAnchor to a WinRT SpatialAnchor object and reuse your existing winrt code.

Dakror commented 2 years ago

What we want to achieve is local synchronization of spatial anchors between devices, without the use of Azure spatial anchors, from OpenXR. From what i can tell, could I use the XR_MSFT_perception_anchor_interop extension to transform the OpenXR Spatial anchors into WinRT ones, transfer those between applications, and re-convert them? How easily could i integrate a minimal slice of the needed WinRT code into an existing C++ application stack?

Secondly, is the extension in question, that you have been reviewing, going to be released / standardized after all? Ideally this is what we would like to use to facilitate the requested functionality.

Dakror commented 2 years ago

@yl-msft I've been able to create a registration-free WinRT component next to my existing application stack.

However, I've only just now realized when trying to test it, that the Hololens 2 does not seem to support XR_MSFT_perception_anchor_interop via Holographic Remoting, which we need to use in order to deliver content to the device.

Am I correct in this assessment or is there something I'm missing? I've tried turning preview runtime off and on, with no change.

yl-msft commented 2 years ago

@Dakror the APIs to transfer anchors across HL2 devices was "SpatialAnchorTransferManager". This API has been deprecated and might not be supported in future HL2 releases. The future supported way to transfer anchors is to use Azure Spatial Anchor.

This SpatialAnchorTransferManager was never previewed in openxr preview extensions. the one we previewed and removed were related to SpatialAnchorStore, which can only save anchors at one HL2 device, and it cannot transfer anchor to another device.

But when you are mentioning "Holographic Remoting" here, i'm wondering if you are trying to share coordinate system from the PC remote app to the HL2 custom remoting player app? If this is what you are trying to do, you shouldn't use Anchor concept, you should instead use the XR_REMOTING_REFERENCE_SPACE_TYPE_USER_MSFT instead.

Dakror commented 2 years ago

@yl-msft From what I can tell from the removed preview extension, it had a mechanism to serialize a spatial anchor to a data stream and also to deserialize this datastream, with user-code transferring the raw data between devices. The SpatialAnchorStore is more alike the XR_MSFT_spatial_anchor_persistence extension from what I can tell.

Thanks for pointing me in a promising direction with the coordinate system synchronization.

EDIT: The approach of the synchronized coordinate system does not look like it can be used for our purposes, as it requires the custom player to render the content that is synchronized and does not facilitate the synchronization between multiple HL2 devices.

yl-msft commented 2 years ago

@Dakror I misspoke above about the removed preview extension. You are right it's the "XR_MSFT_spatial_anchor_export_preview" extension removed from 109 preview runtime. However, this is the extension related to SpatialAnchorExporter that only support exporting anchor neighborhood data stream. It can only be used to support Azure Spatial Anchor. It won't be helping export/import to another HL2 device.

The feature you were looking for is "SpatialAnchorTransferManager". This API has been deprecated long time ago and might be removed in future HL2 releases. It's only be available for OpenXR apps through "XR_MSFT_perception_anchor_interop" API converting openxr anchor to WinRT anchor. It won't be supported by remoting openxr runtime.

Dakror commented 2 years ago

Okay thank you for your assistance in this matter!