1

我一直在尝试分析 Apple 的 pARk(增强现实示例应用程序),在那里我遇到了以下功能,

带有以下参数的方法调用:

createProjectionMatrix(projectionTransform, 60.0f*DEGREES_TO_RADIANS, self.bounds.size.width*1.0f / self.bounds.size.height, 0.25f, 1000.0f);
void createProjectionMatrix(mat4f_t mout, float fovy, float aspect, float zNear, float zFar)
{
    float f = 1.0f / tanf(fovy/2.0f);

    mout[0] = f / aspect;
    mout[1] = 0.0f;
    mout[2] = 0.0f;
    mout[3] = 0.0f;

    mout[4] = 0.0f;
    mout[5] = f;
    mout[6] = 0.0f;
    mout[7] = 0.0f;

    mout[8] = 0.0f;
    mout[9] = 0.0f;
    mout[10] = (zFar+zNear) / (zNear-zFar);
    mout[11] = -1.0f;

    mout[12] = 0.0f;
    mout[13] = 0.0f;
    mout[14] = 2 * zFar * zNear /  (zNear-zFar);
    mout[15] = 0.0f;
}

我看到这projection matrix是乘以rotation matrix(由 motionManager.deviceMotion API 获得)。投影矩阵有什么用?为什么要和旋转矩阵相乘?

multiplyMatrixAndMatrix(projectionCameraTransform, projectionTransform, cameraTransform);

为什么结果矩阵必须再次与 PointOfInterest 向量坐标相乘?

multiplyMatrixAndVector(v, projectionCameraTransform, placesOfInterestCoordinates[i]);

感谢这里的任何帮助。

示例代码链接在这里

4

1 回答 1

2

在计算机视觉和机器人技术中,一个典型的任务是识别图像中的特定对象,并确定每个对象相对于某个坐标系的位置和方向(或平移和旋转)。

在增强现实中,我们通常会计算检测到的物体的姿势,然后在其上增加一个虚拟模型。如果我们知道检测到的物体的姿势,我们可以更真实地投影虚拟模型。

联合旋转平移矩阵 [R|t] 称为外参数矩阵。它用于描述静态场景周围的摄像机运动,反之亦然,描述静止摄像机前物体的刚性运动。也就是说,[R|t] 将点 (X, Y, Z) 的坐标转换为相对于相机固定的坐标系。这为您提供了移动 AR 所需的 6DOF 姿势(3 个旋转和 3 个平移)。

如果您想阅读更多内容,请阅读http://games.ianterrell.com/learn-the-basics-of-opengl-with-glkit-in-ios-5/

抱歉,我只使用 Android AR。希望这可以帮助 :)

于 2014-01-08T14:10:35.913 回答