最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

java - How can i get the Yaw Pitch and Roll values from the Camera Pose of the ARCore? - Stack Overflow

matteradmin4PV0评论

I have this Java code using the ARCore Pose :

private void updateCameraPose(Pose pose) {

        //float[] quaternion = new float[4];
        //pose.getRotationQuaternion(quaternion, 0);

        float x = pose.qx(); //quaternion[0];
        float y = pose.qy(); //quaternion[2];
        float z = pose.qz(); //quaternion[1];
        float w = pose.qw(); //quaternion[3];

        double yaw = atan2(2.0 * (w * y + x * z), 1.0 - 2.0 * (y * y + z * z));
        double pitch = asin(2.0 * (w * x - y * z));
        double roll = atan2(2.0 * (w * z + x * y), 1.0 - 2.0 * (x * x + z * z));

    }

When i try to validate these values by orientating the phone in each axis, it doesn't match at all the behavior that i can see here in the simulator.

I need to get the Yaw / Pitch and Roll values of my Android phone at any time and i am not sure either to get it correctly from the ARCore or calculate them correctly (with a correct mathematical formula).

I guess that the Rotation matrix from the ARCore doesn't especially match the one in the simulator in the first place, but that's fine i can map afterwards when orientating the phone (Maybe the ARCore Yaw is the Pitch in the simulator).

But to do that i need first to be sure the maths are correct.

Post a comment

comment list (0)

  1. No comments so far