Hello,
I have 2 images made by the calibrated drone. So I have all camera parameters.
Manually I select the same points on both images and pass this information to the function.
CameraMatrix1[0, 0] = f;
CameraMatrix1[0, 1] = 0.0;
CameraMatrix1[0, 2] = cx;
CameraMatrix1[1, 0] = 0.0;
CameraMatrix1[1, 1] = f * ar;
CameraMatrix1[1, 2] = cy;
CameraMatrix1[2, 0] = 0.0;
CameraMatrix1[2, 1] = 0.0;
CameraMatrix1[2, 2] = 1.0;
EMatrix = CvInvoke.FindEssentialMat(ImagePoints1, ImagePoints2, CameraMatrix1);
Then I try to process the Essential matrix to receive the Projection matrix.
Matrix<double> D = new Matrix<double>(3, 3);
Matrix<double> U = new Matrix<double>(3, 3);
Matrix<double> Vt = new Matrix<double>(3, 3);
CvInvoke.SVDecomp(EMatrix, D, U, Vt,0);
if (U.Det<0) {
U *= -1.0;
}
if (Vt.Det < 0) {
Vt *= -1.0;
}
Matrix<double> W = new Matrix<double>(3, 3); //<< 0, 1, 0,
// -1, 0, 0,
// 0, 0, 1);
W[0, 0] = 0.0;
W[0, 1] = 1.0;
W[0, 2] = 0.0;
W[1, 0] = -1.0;
W[1, 1] = 0.0;
W[1, 2] = 0.0;
W[2, 0] = 0.0;
W[2, 1] = 0.0;
W[2, 2] = 1.0;
Matrix<double> Wt = new Matrix<double>(3, 3); //<< 0, -1, 0,
// 1, 0, 0,
// 0, 0, 1);
Wt[0, 0] = 0.0;
Wt[0, 1] = -1.0;
Wt[0, 2] = 0.0;
Wt[1, 0] = 1.0;
Wt[1, 1] = 0.0;
Wt[1, 2] = 0.0;
Wt[2, 0] = 0.0;
Wt[2, 1] = 0.0;
Wt[2, 2] = 1.0;
R1 = U * W * Vt;
R2 = U * Wt * Vt;
t = U.GetCol(2) * 1.0;
Matrix<double> P1n = new Matrix<double>(3, 4); //projection matrices in the new (rectified) coordinate systems for Camera 1.
Matrix<double> P2s1 = new Matrix<double>(3, 4);
Matrix<double> P2s2 = new Matrix<double>(3, 4);
Matrix<double> P2s3 = new Matrix<double>(3, 4);
Matrix<double> P2s4 = new Matrix<double>(3, 4);
CvInvoke.HConcat(CameraMatrix1 * R1, CameraMatrix1 * t, P2s1);
CvInvoke.HConcat(CameraMatrix1 * R1, -1*CameraMatrix1 * t, P2s2);
CvInvoke.HConcat(CameraMatrix1 * R2, CameraMatrix1 * t, P2s3);
CvInvoke.HConcat(CameraMatrix1 * R2, -1 * CameraMatrix1 * t, P2s4);
But the result is completely useless. Please tell me - should I use only points on the flat surface for FindEssentialMat? What can be the reason for the wrong Essential Matrix?