Recall from the lectures that we can estimate a homography between two images from point correspondences using the Direct Linear Transform:
We can often achieve a better result if we perform the estimation on normalized point correspondences, using the Normalized DLT:
Lets take a look at how we have implemented all this math! First, study the class declaration and documentation in homography_estimator.h. Then go to homography_estimator.cpp:
- Look at
HomographyEstimator::dltEstimator
:- Try to identify steps 1-4 in the DLT above.
- Look at
HomographyEstimator::normalizedDltEstimator
:- Try to identify steps 1-3 in the normalized DLT above.
- What does the normalizing similarity do?
- Look at
HomographyEstimator::ransacEstimator
:- How many point correspondences do we sample each iteration of the RANSAC loop? Why?
- Which homography estimation algorithm do we use in the RANSAC loop? DLT or normalized DLT? Why not the other one?
- This method returns a
PointSelection
. What is that? (Hint: Check homography_estimator.h).
- Look at
HomographyEstimator::estimate
:- This method returns a
HomographyEstimate
. What is that? (Hint: Check homography_estimator.h)
- This method returns a
To make the homography estimator work, we need to finish HomographyEstimator::computeReprojectionError
in order to compute the reprojection error in the RANSAC inlier test.
In this context, reprojection error is a measure of how well a homography fits with a correspondence ui ↔ ui`:
Here, H maps pixels from one image to the other according to
and H-1 is its inverse:
In HomographyEstimator::computeReprojectionError
you need to compute the reprojection error for a point correspondence.
Hint: Use Eigen::Matrixbase::homogeneous()
, Eigen::Matrixbase::hnormalized()
and Eigen::Matrixbase::norm()
.
When you are happy with your implementation, compile and run the program. Choose a reference and perform matching by pressing . Use debugging tools or printouts to the console to check that your implementation computes reasonable results.
You definitely want to compile and run the program in release mode (see lab-corners) when you are finished debugging.
Now, lets use the computed homography to combine the current frame with the reference in an image mosaic! Please continue to the next step.