Hello everyone.

The Mixed Reality Forums here are no longer being used or maintained.

There are a few other places we would like to direct you to for support, both from Microsoft and from the community.

The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.

For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.

If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.

And always feel free to hit us up on Twitter @MxdRealityDev.

Extracting camera position, direction and up from HolographicStereoTransform


I'm trying to extract cameras information of each eye from HolographicStereoTransform

The following code works inside the emulator, but doesn't with the real hololens.
Do you have an idea of what's wrong ?

HolographicStereoTransform cameraProjectionTransform = cameraPose.ProjectionTransform;

HolographicStereoTransform? viewTransformContainer = cameraPose.TryGetViewTransform(coordinateSystem);

if (viewTransformContainer.HasValue)
    HolographicStereoTransform viewTransform = viewTransformContainer.Value;

    Matrix4x4 ReversedMatrix;
    if(Matrix4x4.Invert(viewTransform, out ReversedMatrix))
        Camera.Position.X   =   ReversedMatrix.M41;
        Camera.Position.Y   =   ReversedMatrix.M42;
        Camera.Position.Z   =   ReversedMatrix.M43;

        Camera.Direction.X  =   -ReversedMatrix.M31;
        Camera.Direction.Y  =   -ReversedMatrix.M32;
        Camera.Direction.Z  =   -ReversedMatrix.M33;

        Camera.Up.X     =   -ReversedMatrix.M21;
        Camera.Up.Y     =   -ReversedMatrix.M22;
        Camera.Up.Z     =   -ReversedMatrix.M23;

    const float Rad2Deg =   57.295779f;     // 180/PI
    float E             =   cameraProjectionTransform.M22;
    Camera.FieldOfView  =   ((float)Math.Atan(1/E) * 2) * Rad2Deg;

Best Answer


Sign In or Register to comment.