如何使用 Vuforia 4x4 矩阵检索区域目标的位置?

问题描述 投票:0回答:1

我目前正在开发一个利用 Vuforia 的应用程序,我需要从区域目标的 4x4 变换矩阵中提取位置坐标(x、y、z)。

这是我用来访问位置值的方法 VuMatrix44F,我从 AreaTargetObservation 获取如下:

VuMatrix44F poseMatrix = poseInfo.pose;
   float x = poseMatrix.data[12];
   float y = poseMatrix.data[13];
   float z = poseMatrix.data[14];

但是,从矩阵中提取的坐标(x,y,z)似乎与区域目标的大小和位置不太吻合

我的问题是:

  1. 这种方法对于在 Vuforia 中使用 4x4 矩阵准确确定区域目标的位置是否正确?
  2. 我还应该考虑其他方法或建议来确保坐标更准确地反映区域目标的物理位置和大小吗?

谢谢你。

ios arrays xcode unity-game-engine vuforia
1个回答
0
投票

Vuforia目标观察姿势相当于OpenGL中的模型矩阵(参见此处https://www.opengl-tutorial.org/beginners-tutorials/tutorial-3-matrices/#the-model-matrix)。

您使用的坐标(x,y,z)是Vuforia世界坐标系中区域目标原点的位置。

如果你想计算设备在 AreaTarget 坐标系中的位置,你必须将该姿势与设备跟踪器姿势结合起来

VuRenderState renderState;
vuStateGetRenderState(state, &renderState);
// combine the view matrix with the model matrix
auto modelView = vuMatrix44FMultiplyMatrix(renderState.viewMatrix, poseInfo.pose);

该矩阵现在包含设备坐标系中 AreaTarget 原点的位置。要获取设备在 AreaTarget 中的位置,您必须使用以下方法反转该矩阵:

auto deviceMatrix = SampleMath.vuMatrix44FInverse(modelView);
© www.soinside.com 2019 - 2024. All rights reserved.