Epipolar lines on Mt Rushmore
The first part of this project was to compute the projection matrix given 2d and 3d coordinates. The second part was to compute the fundamental matrix of a camera given 2d coordinates from 2 different images. The 3rd part used SIFT features, RANSAC, and the method from part 2 to compute the fundamental matrix of the camera and draw epipolar lines on 2 images.
The first part of the project took a set of 2d points and corresponding 2d points to compute the projection matrix from x = k[R t]X. I first set up a homogenous system of equations as described in the project and then used linear least squared to solve for the projection matrix. I also tried out solving using svd. Both results were the same. I ended up with a residual of 0.0445 and a camera center of <-1.5126, -2.3517, 0.2827>.
Projection matrix vs actual points
The second part of the project took two corresponding sets of points from 2 images and computed the fundamental matrix from them. The following steps were taken:
Epipolar lines using Fundamental Matrix
The third part used SIFT features, RANSAC, and estimate_fundamental_matrix to draw epipolar lines. We were given 2 sets of images from which to extract SIFT features and run RANSAC. The following steps were taken.
The RANSAC loop is shown below
% The RANSAC loop
for i=1:1000
corr = randperm(n,8); % Choose 8 points
Points_A = matches_a(corr, :);
Points_B = matches_b(corr, :);
F_matrix = estimate_fundamental_matrix(Points_A, Points_B); % Compute fundamental matrix for these 8 points
% x'*F*xT = 0
% Compute Inliers
threshold = 0.02;
in_a = [];
in_b = [];
for i=1:n
if (abs([matches_b(i, :) 1]*F_matrix*[matches_a(i,:) 1]') < threshold) % Get to as close as zero as possible
in_a = [in_a; matches_a(i,:)];
in_b = [in_b; matches_b(i,:)];
end
end
% Choose max outlier code and prob code below ...
Epipolar lines using RANSAC for Mt Rushmore
This set of images (Mt Rushmore) was relatively easy to find epipolar lines for. This is because most of the initial matches are correct.
Epipolar lines using RANSAC for Notre Dame
This set of images (Notre) was harder but still not bad. Keypoints were on the same plane for this pair. The fundamental matrix did a decent job of filtering out incorrect matches.
Epipolar lines using RANSAC for Episcopal Gaudi
This set of images (Episcopal Gaudi) was hard. Almost no correct matches were found.