# Bisector-Based Tracking of In Plane Subpixel Translations and Rotations
## 3 Methods  
We have developed an algorithm that allows an investigator to compute the location vector (\(x_{c}\), \(y_{c}\), \(\beta\)) from a video sequence of a moving object using a function minimization algorithm. Next, we describe the algorithm step by step. The first step consists of image processing to obtain edge binary images. The particular method followed in this stage may vary depending on the video sequence, although the result must be an edge binary image. After this, it is necessary to select by hand two masks that contain the two digitized nonparallel segments, \(s_{1}\) and \(s_{2}\). Inside each mask, the coordinates of the activated pixels \(\big{(}\mathbf{X}_{i,j},\mathbf{Y}_{i,j}\big{)}\) define both segments in the initial Cartesian coordinates reference system, with the axes aligned with the rows and columns of the support matrix. The objective is to find (\(x_{c}\), \(y_{c}\), \(\beta\)) that transforms \(\big{(}\mathbf{X}_{i,j},\mathbf{Y}_{i,j}\big{)}\) to \(\big{(}\mathbf{X}^{\prime}_{i,j},\mathbf{Y}^{\prime}_{i,j}\big{)}\), which describes the coordinates in one Cartesian system with the axes aligned with the bisectors between the two segments. Such a geometrical transformation changes the set of coordinates following:  
\[ \begin{split}\mathbf{X}^{\prime}_{i,j}&=\big{(} \mathbf{X}_{i,j}-x_{c}\big{)}\cos(\beta)-\big{(}\mathbf{Y}_{i,j}-y_{c}\big{)} \sin(\beta),\\ \mathbf{Y}^{\prime}_{i,j}&=\big{(}\mathbf{X}_{i,j}-x _{c}\big{)}\sin(\beta)+\big{(}\mathbf{Y}_{i,j}-y_{c}\big{)}\cos(\beta),\end{split}  \tag{3}\]  
where \(i=1\), \(2\) stands for the number of the segment and \(j=1\),..., \(N_{i}\), being \(N_{i}\) the number of pixels that form each segment. It is just a composition of a geometrical translation and rotation, i.e., \(\mathbb{R}(\beta)\cdot\mathbb{T}(-x_{c},-y_{c})\), where \(\mathbb{R}\) and \(\mathbb{T}\) are the rotation and translation matrices. On the other hand, let us remember that in the Cartesian system formed by the bisectors, the data set that comprises the coordinates from one segment (\(s_{2}\) in the above example) and those from the reflection with respect to one axis of the other one (e.g., \(\hat{s_{1}}\)) will lie on the same straight line. According to Figure 2, the Equation of the straight line that contains one segment, and the reflected version of the other with respect to one axis of the reference system (X\({}^{\prime}\), Y\({}^{\prime}\)), can be expressed as:  
Figure 2: Cartesian coordinates system formed by bisectors centred at the intersection. \[y^{\prime}=\tan\left(\frac{\pi-\theta_{1}+\theta_{2}}{2}\right)x^{\prime}\equiv m^ {\prime}x^{\prime}. \tag{4}\]  
We estimated the slope of Equation (4) from the result of separately fitting the coordinates of the segments to straight lines by solving the linear least-squares problem, described by:  
\[\mathbf{Y}_{i,j}=\tan(\theta_{i})\mathbf{X}_{i,j}+b_{i}\equiv m_{i}\mathbf{X} _{i,j}+b_{i}. \tag{5}\]  
Notice that, from Equation (5), we could have estimated the value of the location vector \((x_{c},y_{c},\)\(\beta)\), provided that \(\beta=(\theta_{1}+\theta_{2})/2\). In that case, as we claimed above, we would not take into account that the shape of the object does not change, and the result would be affected by the noise of two different fittings. Alternatively, we geometrically transform the coordinates of the segments using different location vectors \((x_{d},y_{d},\)\(\phi)\), i.e., \((\mathbf{X}^{\prime}_{i,j},\mathbf{Y}^{\prime}_{i,j})=\mathbb{R}(\phi)\cdot \mathbb{T}(-x_{d},-y_{d})\cdot\left(\mathbf{X}_{i,j},\mathbf{Y}_{i,j}\right)\), until the mean squared error (MSE) between the transformed data and the straight line obtained from (4) is minimized.