# Visual-Based Localization Using Pictorial Planar Objects in Indoor Environment
## 5 PicPose: A Picture-Based Pose Method
### PicPose Pose Calculation  
The pose of a planar object can be produced by the positional transformation between a planar object detected from a camera and the original model. Homography algorithm is employed in this work to calculate the transition matrix.  
The input data for the homography calculation are matched feature point pairs discussed in the last section. The matched pairs are saved in two coordinate matrices, one is matrix \(M_{o}\) with the points on the original picture and the other is \(M_{t}\) that has the corresponding points on the captured picture in the camera view:  
\[M_{o}=[x_{oi},y_{oi},1]^{\mathrm{T}},M_{t}=[x_{ti},y_{ti},1]^{\mathrm{T}}\]  
The homography matrix \(\mathrm{H}\) is to define the mapping from \(M_{o}\) to \(M_{t}\):  
\[M_{t}=HM_{o}\]  
Figure 11: Matching Examples.  
However, transformation errors may occur due to the matching error and picture scale difference. To minimize the transformation error, we use a robust regression method LMedS [41] which is designed to minimize the median of squared residuals. Points are divided into two classes, inliers and outliers, according to their transformation errors in LMedS. The transformation errors of points in the inliers class need to be small enough to produce a stable matrix H. LMedS will identify outlier points, by finding those points severely deviated from the current transformation. LMedS will produce a feasible result as long as the ratio of outliers is smaller than 50%.  
The homography matrix can only solve the 2D-2D pose transformation problem. However, our goal is to get the camer's 3D position relative to the picture so that a reference system transformation solution is required.In PicPose, the RPP (Robust Planar Pose) [42] algorithm is applied to estimate the pose transferred from the detected picture. RPP uses a minimum of four coplanar but not collinear points on the target planar object to determine the pose of a camera uniquely. We will use a set of feature points of the planar object from inliers pairs produced by LMedS on the homography calculation step as the input data set for RPP. If there are at least 4 good non-colinear matching pairs in the inliers set, the camera's pose can be found by RPP. However, matching error is unavoidable in practice although we use a 2-layer filter (in Section 5.3). The more inliers points are used the more stable the result will be produced. Therefore, we feed all points in the inliers class into RPP to improve the reliability and robustness of the camera pose calculation.  
The goal of RPP is to calculate the 6 DoF(Degrees of Freedom) of a camera's pose. There are 2 kinds of pose information in 6 DoF, translation and rotation. Each of them contains 3 DoF parameters. RPP can generate two vector, translation vector T and rotation vector R, using the homography matrix and the parameters of the camera.The pose projection is shown in Figure 12. The original picture model is on the left side, \(P_{oi}\) is the original feature point represented in scene coordinate system. The target picture on camera view is between original picture and camera. \(P_{ti}\) is \(P_{oi}\)'s corresponding matching point on target picture, which is represented in camera reference system. \(C_{c}\) is the center point of the camera, and it is also the origin in the camera reference system. The projection between \(P_{ti}\) and \(P_{oi}\) can be defined by:  
\[P_{ti}=RP_{oi}+T\]  
Since we know the real-world scale of the original picture, \(P_{oi}\) can be represented using the coordinates with a 3D real distance. \(P_{ti}\) is also able to be represented by a 3D real distance. In this way, the origin \(C_{c}\)'s real-worlds 6 DoF pose can be produced.