There are many posts about 3D reconstruction from stereo views of known internal calibration, some of which are excellent. I have read a lot of them, and based on what I have read I am trying to compute my own 3D scene reconstruction with the below pipeline / algorithm. I'll set out the method then ask specific questions at the bottom.
0. Calibrate your cameras:
CalibrateCamera()
and checkerboard routines, but this functionality is also included in the Matlab Camera Calibration toolbox. The OpenCV routines seem to work nicely.1. Fundamental Matrix F:
findFundamentalMat()
to get F, which provides a number of options method wise (8-point algorithm, RANSAC, LMEDS).x'Fx = 0
where x' and x are the raw image point correspondences (x, y)
in homogeneous coordinates (x, y, 1)
and one of the three-vectors is transposed so that the multiplication makes sense. The nearer to zero for each correspondence, the better F is obeying it's relation. This is equivalent to checking how well the derived F actually maps from one image plane to another. I get an average deflection of ~2px using the 8-point algorithm.2. Essential Matrix E:
3. Internal Constraint upon E:
USV.t
then it's singular values should be = a, a, 0
. The first two diagonal elements of S should be equal, and the third zero.E_new = U * diag(1,1,0) * V.t
which is of course guaranteed to obey the constraint. You have essentially set S = (100,010,000) artificially.4. Full Camera Projection Matrices:
x = PX
relation. Also, P = K[R|t]
and therefore K_inv.P = [R|t]
(where the camera calibration has been removed).[I|0]
then P2 (excluding K) is R|t
U*W*V.t
and U*W.t*V.t
) and two ways to calculate t (±third column of U), which means that there are four combinations of Rt
, only one of which is valid.5. Triangulate in 3D
QUESTIONS:
x'Ex = 0
using normalised image correspondences the typical error in that mapping is >100% of the normalised coordinates themselves. Is testing E against xEx = 0
valid, and if so where is that jump in error coming from?The error in my fundamental matr1ix estimation is significantly worse when using RANSAC than the 8pt algorithm, ±50px in the mapping between x and x'. This deeply concerns me.
Using the 8pt algorithm does not exclude using the RANSAC principle. When using the 8pt algorithm directly which points do you use? You have to choose 8 (good) points by yourself.
In theory you can compute a fundamental matrix from any point correspondences and you often get a degenerated fundamental matrix because the linear equations are not independend. Another point is that the 8pt algorithm uses a overdetermined system of linear equations so that one single outlier will destroy the fundamental matrix.
Have you tried to use the RANSAC result? I bet it represents one of the correct solutions for F.
My F matrix is apparently accurate (0.22% deflection in the mapping compared to typical coordinate values), but when testing E against x'Ex = 0 using normalised image correspondences the typical error in that mapping is >100% of the normalised coordinates themselves. Is testing E against xEx = 0 valid, and if so where is that jump in error coming from?
Again, if F is degenerated, x'Fx = 0 can be for every point correspondence.
Another reason for you incorrect E may be the switch of the cameras (K1T * E * K2 instead of K2T * E * K1). Remember to check: x'Ex = 0
'Enforcing the internal constraint' still sits very weirdly with me - how can it be valid to just manufacture a new Essential matrix from part of the decomposition of the original?
It is explained in 'Multiple View Geometry in Computer Vision' from Hartley and Zisserman. As far as I know it has to do with the minimization of the Frobenius norm of F.
You can Google it and there are pdf resources.
Is there a more efficient way of determining which combo of R and t to use than calculating P and triangulating some of the normalised coordinates?
No as far as I know.
My final re-projection error is hundreds of pixels in 720p images. Am I likely looking at problems in the calibration, determination of P-matrices or the triangulation?
Your rigid body transformation P2 is incorrect because E is incorrect.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With