Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I had to suspend this part for a while but i came up with the following solution:

1) Compute Projection Matrix for each camera

cv::Mat rotMat(3, 3, CV_64F), rotTransMat(3, 4, CV_64F);
//Convert rotation vector into rotation matrix 
cv::Rodrigues(rotVec.at(0), rotMat);
//Append translation vector to rotation matrix
cv::hconcat(rotMat, transVec.at(0), rotTransMat);
//Compute projection matrix by multiplying intrinsic parameter 
//matrix (A) with 3 x 4 rotation and translation pose matrix (RT).
//Formula: Projection Matrix = A * RT;
return (camMat * rotTransMat);

2) Out of the 2 projection matrizes we can compute the fundamental matrix

cv::Mat_<double> X[3];
cv::vconcat(P1.row(1), P1.row(2), X[0]);
cv::vconcat(P1.row(2), P1.row(0), X[1]);
cv::vconcat(P1.row(0), P1.row(1), X[2]);

cv::Mat_<double> Y[3];
cv::vconcat(P2.row(1), P2.row(2), Y[0]);
cv::vconcat(P2.row(2), P2.row(0), Y[1]);
cv::vconcat(P2.row(0), P2.row(1), Y[2]);

cv::Mat_<double> XY;
for (unsigned int i = 0; i < 3; ++i)
{
    for (unsigned int j = 0; j < 3; ++j)
    {
        cv::vconcat(X[j], Y[i], XY);
        F.at<double>(i, j) = cv::determinant(XY);
    }
}

Solution is taken from here. Maybe this is helpfull for ppl coming from google.

I had to suspend this part for a while but i came up with the following solution:

1) Compute Projection Matrix for each camera

cv::Mat rotMat(3, 3, CV_64F), rotTransMat(3, 4, CV_64F);
//Convert rotation vector into rotation matrix 
cv::Rodrigues(rotVec.at(0), rotMat);
//Append translation vector to rotation matrix
cv::hconcat(rotMat, transVec.at(0), rotTransMat);
//Compute projection matrix by multiplying intrinsic parameter 
//matrix (A) with 3 x 4 rotation and translation pose matrix (RT).
//Formula: Projection Matrix = A * RT;
return (camMat * rotTransMat);

2) Out of the 2 projection matrizes we can compute the fundamental matrixmatrix (P1/P2 are the earlier calculated projection marizes)

cv::Mat_<double> X[3];
cv::vconcat(P1.row(1), P1.row(2), X[0]);
cv::vconcat(P1.row(2), P1.row(0), X[1]);
cv::vconcat(P1.row(0), P1.row(1), X[2]);

cv::Mat_<double> Y[3];
cv::vconcat(P2.row(1), P2.row(2), Y[0]);
cv::vconcat(P2.row(2), P2.row(0), Y[1]);
cv::vconcat(P2.row(0), P2.row(1), Y[2]);

cv::Mat_<double> XY;
for (unsigned int i = 0; i < 3; ++i)
{
    for (unsigned int j = 0; j < 3; ++j)
    {
        cv::vconcat(X[j], Y[i], XY);
        F.at<double>(i, j) = cv::determinant(XY);
    }
}

Solution is taken from here. Maybe this is helpfull for ppl coming from google.