Matching phone orientation with camera (Android)

Hi everybody.

I understand you could do this using xrManager, but for my current project I can’t use it as the device is not compatible.

Gyroscope gives Euler angles, and AbsoluteOrientationSensor would give a quaternion.

Using Gyroscope with setFromEulerAngles gives an extremly shaky result.

AbsoluteOrientationSensor is smooth, but I don’t understand how to match the quaternion you get with what the camera.setRotation expects. It is a math problem.

Thanks in advance.

Do you have a public project for people to look at how you’ve implemented the ‘AbsoluteOrientationSensor’ method?

Hi yaustar, thanks for your fast reply.

I wrote my question because I was tired of trying, but after sleeping I figured it out.

It turns out, the orientation you get from the device changes when you use the landscape mode, therefore it doesn’t work.

The solution is to swap a couple of axis and invert one of them in each case.

Hope this helps someone else.

Have a nice day.

1 Like