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

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

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

问题

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

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();

  1. ----环境\
  2. Android Studio:版本4.0.1\
  3. ARCore SDK:版本1.18.1\
  4. 设备:ASUS_A002
  5. 在接下来的页面中,我能够获得平移向量,但无法获得旋转向量。
  6. 旋转向量的值始终为0
  7. https://developers.google.com/ar/reference/java/com/google/ar/core/Pose
  8. 如何在帧上使用getRotationQuaternion()方法?\
  9. 感谢您的帮助。
英文:

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;

  1. private Session session;
  2. Frame frame = session.update();
  3. Pose pose = frame.getAndroidSensorPose();
  4. float[] t = new float[3];
  5. float[] r = new float[4];
  6. Pose rhspose = new Pose(t,r);
  7. Pose thispose;
  8. thispose = pose.compose(rhspose);
  9. float translation[] = thispose.getTranslation();
  10. 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

我解决了我的问题。

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

谢谢。

英文:

I solved my question.

  1. thispose = pose.extractTranslation();
  2. float translation[] = thispose.getTranslation();
  3. thispose = pose.extractRotation();
  4. 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:

确定