EnoxSoftware / HoloLensWithOpenCVForUnityExample

HoloLens With OpenCVforUnity Example (Support for Hololens1 and Hololens2)
MIT License
262 stars 50 forks source link

GetNativeISpatialCoordinateSystemPtr() obsolete in 2021 #32

Closed A00107408 closed 3 years ago

A00107408 commented 3 years ago

https://docs.unity3d.com/ScriptReference/XR.WSA.WorldManager.GetNativeISpatialCoordinateSystemPtr.html says that

UnityEngine.XR.WSA.WorldManager.GetNativeISpatialCoordinateSystemPtr() is obsolete.

It is used on line 421 of HololensCameraStreamToMatHelper.cs.

I cannot find the new alternative for this, and it is the only thing preventing me from running this project after following all of the setup instructions.

What is the new up to date alternative for this line of code?

EnoxSoftware commented 3 years ago

I hope you understand that I have just learned about this problem and cannot immediately provide a correct solution.

I did find some information in the code of camnewnham's HoloLensCameraStream repository that may be a solution to the problem. https://github.com/camnewnham/HoloLensCameraStream/blob/353ddd309d8093f0c39903dd46796865edf5dd68/HoloLensCameraStream/Plugin%20Project/VideoCapture.cs#L132

I haven't tried it on an actual device yet, but I think it can be used in combination with this utility class from the same developer. https://gist.github.com/camnewnham/b0f450b37d7fcf77ebede0d710eb40f8#file-hololenscoordinatesystem

zhimin-wang commented 2 years ago

Hello. I also met this problem. @A00107408 Did you solve this problem? I try to map this address, but it failed.

spatialCoordinateSystemPtr = & (Windows.Perception.Spatial.SpatialLocator.GetDefault().CreateStationaryFrameOfReferenceAtCurrentLocation().CoordinateSystem);

I really appreciate any help you can provide.

zhimin-wang commented 2 years ago

I solved it by this:

Marshal.StructureToPtr(Windows.Perception.Spatial.SpatialLocator.GetDefault().CreateStationaryFrameOfReferenceAtCurrentLocation().CoordinateSystem, spatialCoordinateSystemPtr, false);