## 3 Methodology
### Pattern Recognition and Camera Pose Estimation  
The homography matrix is linearly calculated by RANSAC, with the use of the best combination of four matches, without using all the inliers detected by the algorithm. Thus, the initial homography estimation, obtained by RANSAC, is refined using all the inliers, through nonlinear optimization using the Levenberg-Marquardt algorithm [50]. If a minimum number of 8 inliers is detected by RANSAC, pattern recognition takes place and the 3D model is rendered, superimposed on the camera frame. Otherwise, the scene is not augmented, as the pattern object cannot be recognized in the frame. The recognition of the pattern object in the camera frame takes place through calculation of the pixel coordinates of its four corners, using the estimated homography transformation and the pixel coordinates of the four corners of the pattern image. The estimation of the camera 6-degrees-of-freedom (6-DOF) pose for every camera frame is accomplished using the camera interior orientation parameters, the pixel coordinates of the corners of the planar pattern object in the camera frame and their corresponding coordinates in the world coordinate system. The results of the aforementioned computation are the translation of the origin of the world coordinate system into the projection center, which is the origin of the 3D Cartesian camera system, and the rotation of the world coordinate system into the camera system. The mathematical model used is the projection transformation, expressed by Equation (2):\[\lambda\left[ \begin{array}{c}x\\ y\\ 1\end{array} \right]=\left[ \begin{array}{cccc}c&0&x_{0}\\ 0&c&y_{0}\\ 0&0&1\end{array} \right]\left[ \begin{array}{cccc}r_{11}&r_{12}&r_{13}&t_{1}\\ r_{21}&r_{22}&r_{23}&t_{2}\\ r_{31}&r_{32}&r_{33}&t_{3}\end{array} \right]\left[ \begin{array}{c}X\\ Y\\ Z\\ 1\end{array} \right], \tag{2}\]  
where \(x\), \(y\) are the image coordinates of a point in the camera frame corrected by the effects of distortion; \(X\), \(Y\), \(Z\) are its real-world coordinates; \(c\) is the camera constant; \(x_{0}\), \(y_{0}\) are the coordinates of the principal point; \(r_{ij}\) are the elements of the rotation matrix \(R\); \(t_{i}\) are the elements of the translation vector \(t\); and \(\lambda\) is a scale factor. The elements of the joint rotation-translation matrix are computed linearly according to Equation (3), after undistortion of the image coordinates of the four corners of the pattern in the camera frame and computation of the 2D homography \(H\) that relates the \(X\), \(Y\) world coordinates of the pattern with the corresponding undistorted image coordinates:  
\[ \begin{array}{c}r_{1}=\lambda K^{-1}h_{1}\\ r_{2}=\lambda K^{-1}h_{2}\\ r_{3}=r_{1}\times r_{2}\\ t=\lambda K^{-1}h_{3}\end{array} \begin{array}{c}h_{1}=\left[ \begin{array}[] {cccc}h_{11}&h_{21}&h_{31}\\ h_{2}=\left[\begin{array}{cccc}h_{12}&h_{22}&h_{32}\\ h_{31}&h_{23}&h_{33}\\ r_{1}=\left[\begin{array}{cccc}r_{11}&r_{21}&r_{31}\\ r_{22}&r_{32}\\ r_{33}&r_{33}&\end{array}\right]^{T}\\ r_{3}=\left[\begin{array}{cccc}r_{13}&r_{23}&r_{33}\\ \end{array}\right]^{T}\end{array}\right]\end{array}  \tag{3}\]  
where \(h_{ij}\) are the elements of the \(3\times 3\) homography matrix. Due to noise in data, the computed rotation matrix \(R=\left[ \begin{array}{cccc}r_{1}&r_{2}&r_{3}\\ \end{array} \right]^{T}\) may not satisfy the properties of a rotation matrix. Thus, it is \"coerced\" to satisfy the orthogonality condition \(RR^{T}=R^{T}R=I\) by calculating its singular value decomposition (SVD), thus factoring it into two orthonormal matrices \(U\) and \(V\) and a middle matrix \(W\) with the singular values of \(R\) in its diagonal, as shown in Equation (4):  
\[R=UWV^{T}. \tag{4}\]  
The best approximating matrix is then given by Equation (5) [51]:  
\[\hat{R}=UV^{T}. \tag{5}\]  
Then, the rotation matrix is transformed to a 3D rotation vector, using the Rodrigues rotation formula [52]. This vector indicates the direction of the rotation axis with its magnitude being equal to the magnitude of the rotation.