最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin3浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论