Luckypon
Luckypon

Reputation: 31

Hololens 2 & Unity - How can I get the CameraToWorld and Projection Matrices?

I'm using the Hololens 2 with Unity 2019.3.14. With the PhotoCaptureFrame class, I'm taking a picture, analyzing it to find a specific marker and then I create an hologram where the marker is. My code is working well with a webcam in the Unity Editor. But on the hololens, there is an offset between the hologram and the marker.

I tried to correct it with cameraToWorld matrix and the projection matrix, but it's not working (I always get the identity matrix). I thing it's related to this issue : https://issuetracker.unity3d.com/issues/photocaptureframe-fails-to-provide-camera-matrices-on-hololens-2

photoCaptureFrame.TryGetCameraToWorldMatrix(out Matrix4x4 c2wMatrix);
photoCaptureFrame.TryGetProjectionMatrix(out Matrix4x4 projMatrix);

Some code the in the documentation that looks like mine : https://docs.unity3d.com/2018.3/Documentation/Manual/windowsholographic-photocapture.html

My question is : Do you know of any alternative I could use to correct this offset ? I'm really stuck :/

Thanks in advance !

Upvotes: 0

Views: 1161

Answers (2)

Luckypon
Luckypon

Reputation: 31

The bug was resolved with the Unity 2019.4.6 version

Upvotes: 1

Travis Rothbloom
Travis Rothbloom

Reputation: 1

Those two methods return bools as well as outputting the the matrices (if found), are they returning true for you? I haven't had any issues with the TryGetCameraToWorldMatrix method (don't think I've ever had it return false on me).

I know that you're only able to get to this point if OnCapturedPhotoToMemory is reached, but have you confirmed that the photo was taken and saved successfully?

Upvotes: 0

Related Questions