On a very high level, my pose estimation pipeline looks somewhat like this:
- Find features in image_1 and image_2 (let's say
cv::ORB
) - Match the features (let's say using the
BruteForce-Hamming
descriptor matcher) - Calculate Essential Matrix (using
cv::findEssentialMat
) - Decompose it to get the proper rotation matrix and translation unit vector (using
cv::recoverPose
) - Repeat
I noticed that at some point, the yaw angle (calculated using the output rotation matrix R
of cv::recoverPose
) suddenly jumps by more than 150 degrees. For that particular frame, the number of inliers is 0
(the return value of cv::recoverPose
). So, to understand what exactly that means and what's going on, I asked this question on SO.
As per the answer to my question:
So, if the number of inliers is 0, then something went very wrong. Either your E is wrong, or the point matches are wrong, or both. In this case you simply cannot estimate the camera motion from those two images.
For that particular image pair, based on the visualization and from my understanding, matches look good:
The next step in the pipeline is finding the Essential Matrix. So, now, how can I check whether the calculated Essential Matrix is correct or not without decomposing it i.e. without calculating Roll Pitch Yaw angles (which can be done by finding the rotation matrix via cv::recoverPose
)?
Basically, I want to double-check whether my Essential Matrix is correct or not before I move on to the next component (which is cv::recoverPose
) in the pipeline!
The essential matrix maps each point
p
in image 1 to its epipolar line in image 2. The pointq
in image 2 that corresponds top
must be very close to the line. You can plot the epipolar lines and the matching points to see if they make sense. Remember that E is defined in normalized image coordinates, not in pixels. To get the epipolar lines in pixel coordinates, you would need to convert E to F (the fundamental matrix).The epipolar lines must all intersect in one point, called the epipole. The epipole is the projection of the other camera's center in your image. You can find the epipole by computing the nullspace of F.
If you know something about the camera motion, then you can determine where the epipole should be. For example, if the camera is mounted on a vehicle that is moving directly forward, and you know the pitch and roll angles of the camera relative to the ground, then you can calculate exactly where the epipole will be. If the vehicle can turn in-plane, then you can find the horizontal line on which the epipole must lie.
You can get the epipole from F, and see if it is where it is supposed to be.