如何在ARcore中获取我安卓设备的旋转四元数?

huangapple go评论78阅读模式
英文:

How to get Rotation Quaternion of my android device in ARcore?

问题

我正在开发一个增强现实(AR)项目,正在开发ARCore应用程序。
我想使用当前帧获取旋转和平移信息。
当前的实现和我的环境如下:

private Session session;

Frame frame = session.update();
Pose pose = frame.getAndroidSensorPose();

float[] t = new float[3];
float[] r = new float[4];
Pose rhspose = new Pose(t,r);
Pose thispose;

thispose = pose.compose(rhspose);

float translation[] = thispose.getTranslation();

float orientation[] = thispose.getRotationQuaternion();


----环境\
Android Studio:版本4.0.1\
ARCore SDK:版本1.18.1\
设备:ASUS_A002

在接下来的页面中,我能够获得平移向量,但无法获得旋转向量。
旋转向量的值始终为0。
https://developers.google.com/ar/reference/java/com/google/ar/core/Pose

如何在帧上使用getRotationQuaternion()方法?\
感谢您的帮助。
英文:

I am working on an AR project, and developping ARCorea application.
I want to use the current frame and get a rotation and translation.
Current implementation and my environment is below;

private Session session;

Frame frame = session.update();
Pose pose = frame.getAndroidSensorPose();

float[] t = new float[3];
float[] r = new float[4];
Pose rhspose = new Pose(t,r);
Pose thispose;

thispose = pose.compose(rhspose);

float translation[] = thispose.getTranslation();

float orientation[] = thispose.getRotationQuaternion();

----environment
Android Studio:Ver.4.0.1
ARCore SDK:Ver.1.18.1
Device:ASUS_A002

Following the next page, I could get collect translation vector, but not rotation vector.
The rotation vector values are always 0.
https://developers.google.com/ar/reference/java/com/google/ar/core/Pose

How do I use getRotationQuaternion() for a frame?
Thanks for your helping.

答案1

得分: 2

我解决了我的问题。

thispose = pose.extractTranslation();
float translation[] = thispose.getTranslation();
thispose = pose.extractRotation();
float orientation[] = thispose.getRotationQuaternion();

谢谢。

英文:

I solved my question.

thispose = pose.extractTranslation();
float translation[] = thispose.getTranslation();
thispose = pose.extractRotation();
float orientation[] = thispose.getRotationQuaternion();

Thanks.

huangapple
  • 本文由 发表于 2020年10月7日 17:33:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/64241215.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定