## 3 Improved ORB-Based Matching Method for Pose Estimation
### Improved RANSAC Algorithm  
The main purpose of the pose estimation is to calculate the rotation matrix \(R\) and the translation vector \(T\), given a set of 3D world points and 2D projections. This is so called PnP problem, which assumes the camera is calibrated. To solve this problem, there are many iterative solutions [23; 24] and non-iterative solutions [13; 25; 26]. In this paper, an improved random sample consensus (RANSAC) algorithm based on spatial consistency is proposed to solve this problem. The RANSAC [27] algorithm categorizes all the corresponding keypoints into inliers and outliers. The inliers can be explained by the pinhole camera model and the outliers do not fit to this model. Spatial relations are used here to remove some incorrect correspondence so as to increase the inlier percentage, which can be considered as a preprocessing step for RANSAC algorithm.  
Since the matched keypoints are obtained with spatial consistency, the process of the proposed method is composed of three steps: (1) Determining the most reliable corresponding keypoints, (2) Building the spatial evaluation model by obtaining the distance between normal keypoints and most reliable keypoints, (3) Removing the outliers to increase the inlier percentage according to spatial consistency. The evaluation model is built by using the most reliable correspondence, also called the base-points.  
It is not very hard to find the base-points, the smaller hamming distance of the descriptor means more reliable matches. However, it is impossible every chosen base-point is 100% reliable, therefore we should choose more than one base-point. Sixteen matched keypoints with the minimum hamming distance are chosen as the candidate-points, as shown in Figure 6a. The candidate-points are sorted by the distances between two candidate-points in scene image and reference image. Eight candidate-points with closer value to the median distance are chosen as the base-points, as is shown in Figure 6b, and the battery of an electric automobile is shown in Figure 6c.  
After obtaining the base-points, the hypothesis is generated to categorize the correspondences into inliers and outliers. Suppose that \(P_{s}\) and \(P_{r}\) are a pair of corresponding keypoints in scene image and reference image, \(B_{s}^{i}\) and \(B_{r}^{i}\) donate \(i^{th}\) corresponding base-points in scene image and reference image. The distance in scene image between every undetermined keypoints to a base-point can be determined by \(\sqrt[2]{\left(x(P_{s})-x(B_{s}^{i})\right)^{2}+\left(y(P_{s})-y(B_{s}^{i}) \right)^{2}}\), and the distance in reference image  
Figure 6: Most reliable matched keypoints (**a**) Sixteen candidate-points (**b**) Eight base-points (**c**) Battery of electric automobile.  
is \(\sqrt[2]{\left(x(P_{r})-x(B_{r}^{i})\right)^{2}+\left(y(P_{r})-y(B_{r}^{i})\right)^ {2}}\). With n base-points, the sum of distance ratios \(Sr\) for an undetermined keypoint is given by:  
\[Sr=\sum_{i=0}^{n}\frac{\sqrt[2]{\left(x(P_{s})-x(B_{s}^{i})\right)^{2}+\left(y (P_{s})-y(B_{s}^{i})\right)^{2}}}{\sqrt[2]{\left(x(P_{r})-x(B_{r}^{i})\right)^ {2}+\left(y(P_{r})-y(B_{r}^{i})\right)^{2}}} \tag{14}\]  
the value \(Sr\) is used as the criterion to determine the outliers. The sum of distance ratio for every inlier is close to a certain value, therefore the process of finding outliers is similar with that of finding base-points. The undetermined keypoints are sorted by the sum of distance ratios \(S_{r}\). Top 80% corresponding keypoints with closer value to the median value of \(S_{r}\) are chosen as the inliers, with the remaining 20% keypoints as outliers. The overall flow chart of improved RANSAC method is illustrated in Figure 7. The corresponding 3D coordinates of the chosen non-collinear points is given by the reference model, which is introduced in next subsection.