## 3 Methodology
### Epipolar Geometry-Based Object 3D Position Estimation with Error Correction  
In Section 3.3, \(R\) and \(t\) were derived using EPnP and the Rodrigues rotation formula. We derived straight lines on a per-frame basis, using \(R\), \(t\), and 2D coordinates corresponding to the center of the inventory QR code detected in the video frame. \[s \begin{bmatrix}x\\ y\\ 1\end{bmatrix} =KT_{pers}(1) \begin{bmatrix}K\\ Y\\ Z\\ 1\end{bmatrix} . \tag{2}\]where \(s\) is the scale, \([x,y,1]^{T}\) corresponds to the 2D coordinates, \(K\) is the camera-inherent parameter, \(T_{pers}(1)\) is the projection, \([R|t]\) is the ridge transformation composed of \(R\) and \(t\), and \([X,Y,Z,1]^{T}\) corresponds to the 3D coordinates of the inventory QR code. Thus, the formula for defining 3D coordinates of the inventory QR code was derived with (2) and the 2D coordinate \([x,y,1]^{T}\) of the inventory QR code. \(K\) can be derived through camera calibration, and \([R|t]\) is derived from the previous step. Thus, the matrix product of \(K\), \(T_{pers}(1)\), and \([R|t]\) is a constant \(P_{ij}\) matrix as follows:  
\[KT_{pers}(1)\big{[}R|t\big{]}= \begin{bmatrix}P_{11}P_{12}P_{13}P_{14}\\ P_{21}P_{22}P_{23}P_{24}\\ P_{31}P_{32}P_{33}P_{34}\end{bmatrix} . \tag{3}\]  
Using the 2D coordinate \([x,y,1]^{T}\) of the inventory QR code detected in the segmentation step, two planes \(P_{a},P_{b}\) in the 3D space can be derived as follows:  
\[s=P_{31}X+P_{32}Y+P_{33}Z+P_{34}. \tag{4}\]  
\[P_{a}(X,Y,Z)=P_{11}X+P_{12}Y+P_{13}Z+P_{14}-sx, \tag{5}\]  
\[P_{b}(X,Y,Z)=P_{21}X+P_{22}Y+P_{23}Z+P_{24}-sy.\]  
The intersection of the two planes is the straight line that passes through the inventory. Therefore, the inventory 3D position can be estimated by epipolar geometry using the set of straight lines that pass through the inventory. However, even though frames in which the drone's estimated 3D positions are determined to be outliers are removed, the two straight lines may not intersect, due to the direction vector noise of the derived straight lines. Therefore, we estimated the inventory 3D position as the center of coordinates on two straight lines with the minimum distance between the two straight lines. The inventory 3D position was estimated for all possible straight pairs. Only pairs of straight lines with mismatched direction vectors of straight lines and the drone's 3D positions estimated from two different frames were used to estimate the inventory 3D position. We corrected the estimated inventory 3D position by using the angle between the straight lines used to estimate the inventory 3D position as weights. The direction vector of the derived straight line may have an error with the actual direction vector, due to noise that may occur in the previous step. The error of the direction vector could potentially introduce additional errors into the final 3D position estimation. We propose the error correction method to minimize errors in 3D position estimation due to the error in direction vector. The range of the angle \(\theta\) between the combined straight lines is between 0 and \(\pi\). Figure 6 shows the positions \(A^{\prime},B^{\prime}\) of the inventory estimated from each other when the same level of direction vector error occurs for the straight pair for estimating the position of the inventory \(O^{\prime}\). The \(\theta_{b}\) is closer to \(\pi/2\) than \(\theta_{a}\), while \(\overline{O^{\prime}B^{\prime}}\) is smaller than \(\overline{O^{\prime}A^{\prime}}\). In other words, as \(\theta\) approaches \(\pi/2\), the error of the estimated 3D position at the same level of direction vector error decreases. Thus, the weighted average for \(\theta\) can correct the 3D position estimation results of the inventory. We used weights based on \(sin\theta\) to make the weights larger as \(\theta\) approaches \(\pi/2\), and smaller as it approaches 0 or \(\pi\). \[sin\theta_{ij}=\frac{\|u_{i}\times u_{j}\|}{\|u_{i}\|\|u_{j}\|}. \tag{6}\]  
where \(u_{i},u_{j}\) are the direction vector of lines to estimate the object 3D position.