0

我一直在試圖分析蘋果公園(增強現實示例應用程序),我碰到下面的函數哪裏傳來,投影矩陣的用途是什麼?

方法調用與以下參數:

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

欣賞這裏的任何幫助。

示例代碼link here

回答

1

在計算機視覺和在機器人技術,典型的任務是識別圖像中的特定對象,並確定每個物體的位置和方向(或平移和旋轉)相對於一些座標系。

在增強現實中,我們通常會計算檢測到的物體的姿態,然後在其上增加一個虛擬模型。如果我們知道檢測到的物體的姿態,我們可以更真實地投影虛擬模型。

聯合旋轉 - 平移矩陣[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工作。希望這有助於:)