Eight-point algorithm
The eight-point algorithm is an algorithm used in computer vision to estimate the essential matrix or the fundamental matrix related to a stereo camera pair from a set of corresponding image points. It was introduced by Christopher Longuet-Higgins in 1981 for the case of the essential matrix. In theory, this algorithm can be used also for the fundamental matrix, but in practice the normalized eight-point algorithm, described by Richard Hartley in 1997, is better suited for this case. The algorithm's name derives from the fact that it estimates the essential matrix or the fundamental matrix from a set of eight (or more) corresponding image points. However, variations of the algorithm can be used for fewer than eight points.
Coplanarity constraint
One may express the epipolar geometry of two cameras and a point in space with an algebraic equation. Observe that, no matter where the point [math]\displaystyle{ P }[/math] is in space, the vectors [math]\displaystyle{ \overline{O_L P} }[/math], [math]\displaystyle{ \overline{O_R P} }[/math] and [math]\displaystyle{ \overline{O_R O_L} }[/math] belong to the same plane. Call [math]\displaystyle{ X_L }[/math] the coordinates of point [math]\displaystyle{ P }[/math] in the left eye's reference frame and call [math]\displaystyle{ X_R }[/math] the coordinates of [math]\displaystyle{ P }[/math] in the right eye's reference frame and call [math]\displaystyle{ R, T }[/math] the rotation and translation between the two reference frames s.t. [math]\displaystyle{ X_R = R (X_L-T) }[/math] is the relationship between the coordinates of [math]\displaystyle{ P }[/math] in the two reference frames. The following equation always holds because the vector generated from [math]\displaystyle{ T \wedge X_L }[/math] is orthogonal to both [math]\displaystyle{ T }[/math] and [math]\displaystyle{ X_L }[/math] :
- [math]\displaystyle{ X_L^T T \wedge X_L - T^T T \wedge X_L = (X_L-T)^T T \wedge X_L = 0 }[/math]
Because [math]\displaystyle{ I = R^T R }[/math], we get
- [math]\displaystyle{ (X_L-T)^T R^T R T \wedge X_L = 0 }[/math].
Replacing [math]\displaystyle{ (X_L-T)^TR^T }[/math] with [math]\displaystyle{ X_R^T }[/math], we get
- [math]\displaystyle{ X_R^T R T \wedge X_L = X_R^T R S X_L = X_R^T E X_L = 0 }[/math]
Observe that [math]\displaystyle{ T \wedge }[/math] may be thought of as a matrix; Longuet-Higgins used the symbol [math]\displaystyle{ S }[/math] to denote it. The product [math]\displaystyle{ R T \wedge = R S }[/math] is often called essential matrix and denoted with [math]\displaystyle{ E }[/math].
The vectors [math]\displaystyle{ \overline{O_L p_L}, \overline{O_R p_R} }[/math] are parallel to the vectors [math]\displaystyle{ \overline{O_L P}, \overline{O_R P} }[/math] and therefore the coplanarity constraint holds if we substitute these vectors. If we call [math]\displaystyle{ y, y' }[/math] the coordinates of the projections of [math]\displaystyle{ P }[/math] onto the left and right image planes, then the coplanarity constraint may be written as
- [math]\displaystyle{ y'^T \mathbf{E} y = 0 }[/math]
Basic algorithm
The basic eight-point algorithm is here described for the case of estimating the essential matrix [math]\displaystyle{ \mathbf{E} }[/math]. It consists of three steps. First, it formulates a homogeneous linear equation, where the solution is directly related to [math]\displaystyle{ \mathbf{E} }[/math], and then solves the equation, taking into account that it may not have an exact solution. Finally, the internal constraints of the resulting matrix are managed. The first step is described in Longuet-Higgins' paper, the second and third steps are standard approaches in estimation theory.
The constraint defined by the essential matrix [math]\displaystyle{ \mathbf{E} }[/math] is
- [math]\displaystyle{ (\mathbf{y}')^{T} \, \mathbf{E} \, \mathbf{y} = 0 }[/math]
for corresponding image points represented in normalized image coordinates [math]\displaystyle{ \mathbf{y}, \mathbf{y}' }[/math]. The problem which the algorithm solves is to determine [math]\displaystyle{ \mathbf{E} }[/math] for a set of matching image points. In practice, the image coordinates of the image points are affected by noise and the solution may also be over-determined which means that it may not be possible to find [math]\displaystyle{ \mathbf{E} }[/math] which satisfies the above constraint exactly for all points. This issue is addressed in the second step of the algorithm.
Step 1: Formulating a homogeneous linear equation
With
- [math]\displaystyle{ \mathbf{y} = \begin{pmatrix} y_{1} \\ y_{2} \\ 1 \end{pmatrix} }[/math] and [math]\displaystyle{ \mathbf{y}' = \begin{pmatrix} y'_{1} \\ y'_{2} \\ 1 \end{pmatrix} }[/math] and [math]\displaystyle{ \mathbf{E} = \begin{pmatrix} e_{11} & e_{12} & e_{13} \\ e_{21} & e_{22} & e_{23} \\ e_{31} & e_{32} & e_{33} \end{pmatrix} }[/math]
the constraint can also be rewritten as
- [math]\displaystyle{ y'_1 y_1 e_{11} + y'_1 y_2 e_{12} + y'_1 e_{13} + y'_2 y_1 e_{21} + y'_2 y_2 e_{22} + y'_2 e_{23} + y_1 e_{31} + y_2 e_{32} + e_{33} = 0 \, }[/math]
or
- [math]\displaystyle{ \mathbf{e} \cdot \tilde{\mathbf{y}} = 0 }[/math]
where
- [math]\displaystyle{ \tilde{\mathbf{y}} = \begin{pmatrix} y'_1 y_1 \\ y'_1 y_2 \\ y'_1 \\ y'_2 y_1 \\ y'_2 y_2 \\ y'_2 \\ y_1 \\ y_2 \\ 1 \end{pmatrix} }[/math] and [math]\displaystyle{ \mathbf{e} = \begin{pmatrix} e_{11} \\ e_{12} \\ e_{13} \\ e_{21} \\ e_{22} \\ e_{23} \\ e_{31} \\ e_{32} \\ e_{33} \end{pmatrix} }[/math]
that is, [math]\displaystyle{ \mathbf{e} }[/math] represents the essential matrix in the form of a 9-dimensional vector and this vector must be orthogonal to the vector [math]\displaystyle{ \tilde{\mathbf{y}} }[/math] which can be seen as a vector representation of the [math]\displaystyle{ 3 \times 3 }[/math] matrix [math]\displaystyle{ \mathbf{y}' \, \mathbf{y}^{T} }[/math].
Each pair of corresponding image points produces a vector [math]\displaystyle{ \tilde{\mathbf{y}} }[/math]. Given a set of 3D points [math]\displaystyle{ \mathbf{P}_k }[/math] this corresponds to a set of vectors [math]\displaystyle{ \tilde{\mathbf{y}}_{k} }[/math] and all of them must satisfy
- [math]\displaystyle{ \mathbf{e} \cdot \tilde{\mathbf{y}}_{k} = 0 }[/math]
for the vector [math]\displaystyle{ \mathbf{e} }[/math]. Given sufficiently many (at least eight) linearly independent vectors [math]\displaystyle{ \tilde{\mathbf{y}}_{k} }[/math] it is possible to determine [math]\displaystyle{ \mathbf{e} }[/math] in a straightforward way. Collect all vectors [math]\displaystyle{ \tilde{\mathbf{y}}_{k} }[/math] as the columns of a matrix [math]\displaystyle{ \mathbf{Y} }[/math] and it must then be the case that
- [math]\displaystyle{ \mathbf{e}^{T} \, \mathbf{Y} = \mathbf{0} }[/math]
This means that [math]\displaystyle{ \mathbf{e} }[/math] is the solution to a homogeneous linear equation.
Step 2: Solving the equation
A standard approach to solving this equation implies that [math]\displaystyle{ \mathbf{e} }[/math] is a right singular vector of [math]\displaystyle{ \mathbf{Y} }[/math] corresponding to a singular value that equals zero. Provided that at least eight linearly independent vectors [math]\displaystyle{ \tilde{\mathbf{y}}_{k} }[/math] are used to construct [math]\displaystyle{ \mathbf{Y} }[/math] it follows that this singular vector is unique (disregarding scalar multiplication) and, consequently, [math]\displaystyle{ \mathbf{e} }[/math] and then [math]\displaystyle{ \mathbf{E} }[/math] can be determined.
In the case that more than eight corresponding points are used to construct [math]\displaystyle{ \mathbf{Y} }[/math] it is possible that it does not have any singular value equal to zero. This case occurs in practice when the image coordinates are affected by various types of noise. A common approach to deal with this situation is to describe it as a total least squares problem; find [math]\displaystyle{ \mathbf{e} }[/math] which minimizes
- [math]\displaystyle{ \| \mathbf{e}^{T} \, \mathbf{Y} \| }[/math]
when [math]\displaystyle{ \| \mathbf{e} \| = 1 }[/math]. The solution is to choose [math]\displaystyle{ \mathbf{e} }[/math] as the left singular vector corresponding to the smallest singular value of [math]\displaystyle{ \mathbf{Y} }[/math]. A reordering of this [math]\displaystyle{ \mathbf{e} }[/math] back into a [math]\displaystyle{ 3 \times 3 }[/math] matrix gives the result of this step, here referred to as [math]\displaystyle{ \mathbf{E}_{\rm est} }[/math].
Step 3: Enforcing the internal constraint
Another consequence of dealing with noisy image coordinates is that the resulting matrix may not satisfy the internal constraint of the essential matrix, that is, two of its singular values are equal and nonzero and the other is zero. Depending on the application, smaller or larger deviations from the internal constraint may or may not be a problem. If it is critical that the estimated matrix satisfies the internal constraints, this can be accomplished by finding the matrix [math]\displaystyle{ \mathbf{E}' }[/math] of rank 2 which minimizes
- [math]\displaystyle{ \| \mathbf{E}' - \mathbf{E}_{\rm est} \| }[/math]
where [math]\displaystyle{ \mathbf{E}_{\rm est} }[/math] is the resulting matrix from Step 2 and the Frobenius matrix norm is used. The solution to the problem is given by first computing a singular value decomposition of [math]\displaystyle{ \mathbf{E}_{\rm est} }[/math]:
- [math]\displaystyle{ \mathbf{E}_{\rm est} = \mathbf{U} \, \mathbf{S} \, \mathbf{V}^{T} }[/math]
where [math]\displaystyle{ \mathbf{U}, \mathbf{V} }[/math] are orthogonal matrices and [math]\displaystyle{ \mathbf{S} }[/math] is a diagonal matrix which contains the singular values of [math]\displaystyle{ \mathbf{E}_{\rm est} }[/math]. In the ideal case, one of the diagonal elements of [math]\displaystyle{ \mathbf{S} }[/math] should be zero, or at least small compared to the other two which should be equal. In any case, set
- [math]\displaystyle{ \mathbf{S}' = \begin{pmatrix} s_1 & 0 & 0 \\ 0 & s_2 & 0 \\ 0 & 0 & 0 \end{pmatrix} , }[/math]
where [math]\displaystyle{ s_1, s_2 }[/math] are the largest and second largest singular values in [math]\displaystyle{ \mathbf{S} }[/math] respectively. Finally, [math]\displaystyle{ \mathbf{E}' }[/math] is given by
- [math]\displaystyle{ \mathbf{E}' = \mathbf{U} \, \mathbf{S}' \, \mathbf{V}^{T} }[/math]
The matrix [math]\displaystyle{ \mathbf{E}' }[/math] is the resulting estimate of the essential matrix provided by the algorithm.
Normalized algorithm
The basic eight-point algorithm can in principle be used also for estimating the fundamental matrix [math]\displaystyle{ \mathbf{F} }[/math]. The defining constraint for [math]\displaystyle{ \mathbf{F} }[/math] is
- [math]\displaystyle{ (\mathbf{y}')^{T} \, \mathbf{F} \, \mathbf{y} = 0 }[/math]
where [math]\displaystyle{ \mathbf{y}, \mathbf{y}' }[/math] are the homogeneous representations of corresponding image coordinates (not necessary normalized). This means that it is possible to form a matrix [math]\displaystyle{ \mathbf{Y} }[/math] in a similar way as for the essential matrix and solve the equation
- [math]\displaystyle{ \mathbf{f}^{T} \, \mathbf{Y} = \mathbf{0} }[/math]
for [math]\displaystyle{ \mathbf{f} }[/math] which is a reshaped version of [math]\displaystyle{ \mathbf{F} }[/math]. By following the procedure outlined above, it is then possible to determine [math]\displaystyle{ \mathbf{F} }[/math] from a set of eight matching points. In practice, however, the resulting fundamental matrix may not be useful for determining epipolar constraints.
Difficulty
The problem is that the resulting [math]\displaystyle{ \mathbf{Y} }[/math] often is ill-conditioned. In theory, [math]\displaystyle{ \mathbf{Y} }[/math] should have one singular value equal to zero and the rest are non-zero. In practice, however, some of the non-zero singular values can become small relative to the larger ones. If more than eight corresponding points are used to construct [math]\displaystyle{ \mathbf{Y} }[/math], where the coordinates are only approximately correct, there may not be a well-defined singular value which can be identified as approximately zero. Consequently, the solution of the homogeneous linear system of equations may not be sufficiently accurate to be useful.
Cause
Hartley addressed this estimation problem in his 1997 article. His analysis of the problem shows that the problem is caused by the poor distribution of the homogeneous image coordinates in their space, [math]\displaystyle{ \mathbb{R}^{3} }[/math]. A typical homogeneous representation of the 2D image coordinate [math]\displaystyle{ (y_{1}, y_{2}) \, }[/math] is
- [math]\displaystyle{ \mathbf{y} = \begin{pmatrix} y_{1} \\ y_{2} \\ 1 \end{pmatrix} }[/math]
where both [math]\displaystyle{ y_{1}, y_{2} \, }[/math] lie in the range 0 to 1000–2000 for a modern digital camera. This means that the first two coordinates in [math]\displaystyle{ \mathbf{y} }[/math] vary over a much larger range than the third coordinate. Furthermore, if the image points which are used to construct [math]\displaystyle{ \mathbf{Y} }[/math] lie in a relatively small region of the image, for example at [math]\displaystyle{ (700,700) \pm (100,100) \, }[/math], again the vector [math]\displaystyle{ \mathbf{y} }[/math] points in more or less the same direction for all points. As a consequence, [math]\displaystyle{ \mathbf{Y} }[/math] will have one large singular value and the remaining are small.
Solution
As a solution to this problem, Hartley proposed that the coordinate system of each of the two images should be transformed, independently, into a new coordinate system according to the following principle.
- The origin of the new coordinate system should be centered (have its origin) at the centroid (center of gravity) of the image points. This is accomplished by a translation of the original origin to the new one.
- After the translation the coordinates are uniformly scaled so that the mean of distances from the origin to the points equals [math]\displaystyle{ \sqrt{2} }[/math].
This principle results, normally, in a distinct coordinate transformation for each of the two images. As a result, new homogeneous image coordinates [math]\displaystyle{ \mathbf{\bar y}, \mathbf{\bar y}' }[/math] are given by
- [math]\displaystyle{ \mathbf{\bar y} = \mathbf{T} \, \mathbf{y} }[/math]
- [math]\displaystyle{ \mathbf{\bar y}' = \mathbf{T}' \, \mathbf{y}' }[/math]
where [math]\displaystyle{ \mathbf{T}, \mathbf{T}' }[/math] are the transformations (translation and scaling) from the old to the new normalized image coordinates. This normalization is only dependent on the image points which are used in a single image and is, in general, distinct from normalized image coordinates produced by a normalized camera.
The epipolar constraint based on the fundamental matrix can now be rewritten as
- [math]\displaystyle{ 0 = (\mathbf{\bar y}')^{T} \, ((\mathbf{T}')^{T})^{-1} \, \mathbf{F} \, \mathbf{T}^{-1}\, \mathbf{\bar y} = (\mathbf{\bar y}')^{T} \, \mathbf{\bar F} \, \mathbf{\bar y} }[/math]
where [math]\displaystyle{ \mathbf{\bar F} = ((\mathbf{T}')^{T})^{-1} \, \mathbf{F} \, \mathbf{T}^{-1} }[/math]. This means that it is possible to use the normalized homogeneous image coordinates [math]\displaystyle{ \mathbf{\bar y}, \mathbf{\bar y}' }[/math] to estimate the transformed fundamental matrix [math]\displaystyle{ \mathbf{\bar F} }[/math] using the basic eight-point algorithm described above.
The purpose of the normalization transformations is that the matrix [math]\displaystyle{ \mathbf{\bar Y} }[/math], constructed from the normalized image coordinates, in general, has a better condition number than [math]\displaystyle{ \mathbf{Y} }[/math] has. This means that the solution [math]\displaystyle{ \mathbf{\bar f} }[/math] is more well-defined as a solution of the homogeneous equation [math]\displaystyle{ \mathbf{\bar Y} \, \mathbf{\bar f} }[/math] than [math]\displaystyle{ \mathbf{f} }[/math] is relative to [math]\displaystyle{ \mathbf{Y} }[/math]. Once [math]\displaystyle{ \mathbf{\bar f} }[/math] has been determined and reshaped into [math]\displaystyle{ \mathbf{\bar F} }[/math] the latter can be de-normalized to give [math]\displaystyle{ \mathbf{F} }[/math] according to
- [math]\displaystyle{ \mathbf{F} = (\mathbf{T}')^{T} \, \mathbf{\bar F} \, \mathbf{T} }[/math]
In general, this estimate of the fundamental matrix is a better one than would have been obtained by estimating from the un-normalized coordinates.
Using fewer than eight points
Each point pair contributes with one constraining equation on the element in [math]\displaystyle{ \mathbf{E} }[/math]. Since [math]\displaystyle{ \mathbf{E} }[/math] has five degrees of freedom it should therefore be sufficient with only five point pairs to determine [math]\displaystyle{ \mathbf{E} }[/math]. David Nister proposed an efficient solution to estimate the essential matrix from set of five paired points, known as the five-point algorithm.[1] Hartley et. al. later proposed a modified and more stable five-point algorithm based on Nister's algorithm.[2]
See also
References
- ↑ Nister, David (2004). "An efficient solution to the five-point relative pose problem". IEEE Transactions on Pattern Analysis and Machine Intelligence 26 (6): 756–770. doi:10.1109/TPAMI.2004.17. PMID 18579936. https://ieeexplore.ieee.org/document/1288525.
- ↑ Li, Hongdong (2006). "Five-Point Motion Estimation Made Easy". 18th International Conference on Pattern Recognition (ICPR'06). pp. 630–633. doi:10.1109/ICPR.2006.579. ISBN 0-7695-2521-0. https://ieeexplore.ieee.org/document/1698971.
Further reading
- Richard I. Hartley (June 1997). "In Defense of the Eight-Point Algorithm". IEEE Transactions on Pattern Recognition and Machine Intelligence 19 (6): 580–593. doi:10.1109/34.601246.
- Richard Hartley and Andrew Zisserman (2003). Multiple View Geometry in computer vision. Cambridge University Press. ISBN 978-0-521-54051-3.
- H. Christopher Longuet-Higgins (September 1981). "A computer algorithm for reconstructing a scene from two projections". Nature 293 (5828): 133–135. doi:10.1038/293133a0. Bibcode: 1981Natur.293..133L.
Original source: https://en.wikipedia.org/wiki/Eight-point algorithm.
Read more |