2012-09-30 16 views
5

我从相同的两个相机拍摄的两幅图像相距一定距离,捕捉相同的场景。我想计算两台相机之间的真实世界旋转和平移。为了达到这个目的,我首先提取了两幅图像的SIFT特征并匹配它们。多视图几何

我现在有基本矩阵以及单应矩阵。但无法进一步进行,很多困惑。谁能帮我估计旋转和翻译在两个摄像头之间?

我使用OpenCV进行特征提取和匹配单应计算。

回答

5

如果你有Homography,那么你也有轮换。一旦你有单应性,很容易获得旋转和平移矩阵。

例如,如果正在使用的OpenCV C++:

param[in] H 
param[out] pose 
void cameraPoseFromHomography(const Mat& H, Mat& pose) 
{ 
    pose = Mat::eye(3, 4, CV_32FC1);  // 3x4 matrix, the camera pose 
    float norm1 = (float)norm(H.col(0)); 
    float norm2 = (float)norm(H.col(1)); 
    float tnorm = (norm1 + norm2)/2.0f; // Normalization value 

    Mat p1 = H.col(0);  // Pointer to first column of H 
    Mat p2 = pose.col(0); // Pointer to first column of pose (empty) 

    cv::normalize(p1, p2); // Normalize the rotation, and copies the column to pose 

    p1 = H.col(1);   // Pointer to second column of H 
    p2 = pose.col(1);  // Pointer to second column of pose (empty) 

    cv::normalize(p1, p2); // Normalize the rotation and copies the column to pose 

    p1 = pose.col(0); 
    p2 = pose.col(1); 

    Mat p3 = p1.cross(p2); // Computes the cross-product of p1 and p2 
    Mat c2 = pose.col(2); // Pointer to third column of pose 
    p3.copyTo(c2);  // Third column is the crossproduct of columns one and two 

    pose.col(3) = H.col(2)/tnorm; //vector t [R|t] is the last column of pose 
} 

此函数计算德照相机从单应性姿势,其中转动被含有。欲了解更多理论信息,请点击这里thread

+0

谢谢@Jav_Rock,你的回答帮助我估计姿势。然而,对于任何图像集,姿势矩阵都是相同的,前三列形成一个单位矩阵,最后一列是空的。你有什么想法吗? – Aarambh

+0

我也通过使用warpAffine来确认单应矩阵,它正确地将图像的视图映射到另一个。 – Aarambh

+0

@ user1709317:'H'和'pose'需要具有相同的格式。如果更改'CV_32FC1'->'CV_64FC1',您可能会得到期望的结果。 – bjoernz