Project 3 / Camera Calibration and Fundamental Matrix Estimation with RANSAC

Camera Calibration is used to estimate the parameters of a lens and image sensor of an image or video camera so as to account for correction of lens distortion, measure the size of an object in world units, or determine the location of the camera in the scene. The fundamental matrix is used to map 3D world coordinates to image coordinates. The goal of the project is to perform camera caliberation and estimate the fundamental matrix using RANSAC. Project consists of three parts

  1. Estimation of Projection Matrix
  2. Estimation of fundamental Matrix
  3. Estimation of fundamental matrix using unreliable SIFT matches with RANSAC

1. Estimation of Projection Matrix

The projection matrix is a 3x4 matrix that describes the mapping of a pinhole camera from 3D points in the world to 2D points in an image. The non homegenous method is used to determine the projection matrix. This projection matrix M can be divided into a matrix K of intrinsic parameters and a matrix [R/T] of extrinsic parameters. Camera centre is then determined as -(Q^-1)*m4; where m4 is the last column of M and Q is the first 3X3 elements of M. The following projection matrix was obtained

The projection matrix is :

0.7679 -0.4938 -0.0234 0.0067
-0.0852 -0.0915 -0.9065 -0.0878
0.1827 0.2988 -0.0742 1.0000

The total residual is: 0.0445.

The estimated location of camera is: -1.5126, -2.3517, 0.2827

2. Fundamental matrix estimation

The fundamental matrix F is used to obtain the epipolar geometry. The below equation shows that each matching pair of points between the two images provides a single linear constraint on F. This allows F to be estimated linearly (up to the usual arbitrary scale factor) from 8 independent correspondences - 8 point algorithm. The following fundamental matrix is obtained for the base image pair

-0.0000 0.0000 -0.0019
0.0000 0.0000 0.0172
-0.0009 -0.0264 0.9995

The linear squares estimate of F is full rank; however, the fundamental matrix is a rank 2 matrix. In order to reduce the rank, we can decompose F using singular value decomposition into the matrices U ΣV' = F. We can then estimate a rank 2 matrix by setting the smallest singular value in Σ to zero thus generating Σ2 . The fundamental matrix is then easily calculated as F = U Σ2 V'.

Normalization

The normalized 8 point algorithm is used to normalize the image points. The tranformation matrix is computed by determinng the scaling matrices and offset matrices for each image. The images points coordinates are then transformed using the tranformation matrix. The Fundamental matrix is computed using the Singular value decomposition. The obtained Fundamental matrix is scaled back to the image coordinates. The effect of the normalization can be seen on the epipolar lines in the below imgages

Without Normalization

With Normalization

As can be seen from the above comparision, when normalization is used the lines pass through the center of the corresponding matched points while without normalization the epipolar lines are not perfectly centered. Thus normalization helps in overcoming the poor numerical conditioning problem

3. Estimation of fundamental matrix using unreliable SIFT matches with RANSAC

The fundamental matrix is computed with unreliable point correspondences computed with SIFT. Least squares regression does not perform well becasue of the presence of multiple outliers. RANSAC which is robust to outliers is used in order to determine the fundamental matrix. 8 random corresponding matched points from two images are taken and the fundamental matrix is solved and determined. The number of inliers for this fundamental matrix is computed. To determine the points that correspond to inliers for a particular fundamental matrix, a distance measure or threshold is taken. Thus, a threshold is picked between the inliers and outliers and this threshold is varied in order to get better results.This process is iteratively done and the fundamental matrix with the highest number of inliers is taken as the final fundamental matrix.


Results for part 3

Mount Rushmore - Non Normalized - Threshold - 0.08

Mount Rushmore - Normalized - Threshold - 0.08

Mount Rushmore - Normalized - Threshold - 0.008

Notre Dame

Episcopal Gaudi

Woodruff Dorm

Conclusion

By using RANSAC to find the fundamental matrix with the most inliers, spurious matches can be filtered away and near perfect point to point matching can be acheived.