# Fundamental Matrix Computing Based on 3D Metrical Distance
## 4 Computing \(F\) in Metric Space Based on Geometric Distance
### Optimization Based on Metric Geometric Distance  
Our optimization based on metric geometric distance is in the same framework as the gold standard method [6] but in a metrical space for \(X\) and \(P_{E},P_{E}^{{}^{\prime}}\), rather than the projective space described as Equation (8) in Section 3.3. In other words, we use a different method to compute projective matrix labeled as \(P_{E},\ P_{E}^{{}^{\prime}}\) which represents the metric scene in Euclidean coordinates.  
The input of our optimization is an initial \(F\), image size \([w,h]\), and matching feature points \([u,u^{\prime}]\). The initial \(F\) of the one images pair is computed by the eight-point method as described in Section 3.1 in the RANSAC framework based on the traditional distance from \([u,u^{\prime}]\) to epipolar line. The output is the final result of \(F\). Goal of the optimization is to minimize the Equation (11). The steps of this algorithm are listed as follows:  
1. Estimate \(E=K^{\prime T}FK\) with \(K\) in Equation (10).
2. Decompose \(E\) to \(P_{E},\ P_{E}^{{}^{\prime}}\) by the method in Section 3.2.
3. Normalize the matching points \([u,u^{\prime}]\) to \([\hat{u},\ \hat{u}^{\prime}]\) with respect to \(K\) and \([w,\ h]\). if \(u=[u_{1},\ u_{2},\ 1]^{T}\), then \(\hat{u}=K^{-1}\times[u_{1}-w/2,u_{2}-h/2,1]^{T}\).
4. With these correspondence \([\hat{u},\ \hat{u}^{\prime}]\) and \(P_{E},\ P_{E}^{{}^{\prime}}\), estimate \(X\) by the triangulation method [6].
5. Minimize energy function Equation (11) over \(X\), \(P_{E}\) and \(P_{E}^{{}^{\prime}}\). The cost is minimized using the Levenberg-Marquardt algorithm over \(3N+24\) variables: \(3N\) for \(N\) 3D points \(X_{i}\), and \(24\) for the camera matrix \(P_{E},P_{E}^{{}^{\prime}}\).
6. Retrieve \(F\) from the \(K,K^{\prime},P_{E},P_{E}^{\prime}\). At first, compute the epipole \(e^{\prime}\) of the second image by \(e^{\prime}=P_{E}^{{}^{\prime}}\times null(P_{E})\) where \(null(P_{E})\) is zero space of \(P_{E}\). Then return the final \(F=K^{-1}[e^{\prime}]_{\times}P_{E}^{{}^{\prime}}P_{E}^{-1}K^{-1}\).  
As mentioned above, the \(K\) is estimated through the constraints, but not a precisely measured one. Of course if the precisely measured \(K\) is applied to our algorithm, better result will be achieved. For most of the scenarios, the precise \(K\) could not be known in advance. Therefore, this estimated and feasible \(K\) is adopted in our optimization. In fact it works very well and always achieves a satisfying result.  
Compared with normalization in Section 3.1, our method uses a different normalization method for coordinates of features to compute final \(F\). In Section 3.1, its origin point is a centroid that lies at the barycenters of \(u\) or \(u^{\prime}\), and its average distance from \(u\) or \(u^{\prime}\) to the origin point is \(\sqrt{2}\) which is fixed. However, in our algorithm, origin point is at the center of the images, and the average distance from origin point is less than 1, which is not fixed. Our normalization is more efficient than the normalization in Section 3.1. Our normalization method is a linear operation that does not need to calculate the barycenter. Furthermore, our method can visualize metric 3D reconstruction of \(X\) as described in Section 5.3 but the other normalization methods cannot produce reasonable visualization of reconstruction directly.