我目前正在开发一个利用 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)似乎与区域目标的大小和位置不太吻合
我的问题是:
谢谢你。
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);