# Object-Tracking Algorithm Combining Motion Direction and Time Series
## 3 Methods
### Loss Function with Directional Guidance  
Given the assumption of minor changes in the target's position and appearance across consecutive frames, the direction vector from the predicted target position to the actual target position in the current frame, expressed as \(\overset{\rightarrow}{R}\), approximates the direction toward the actual target position in the subsequent frame. The direction vector \(\overset{\rightarrow}{R}\) can be utilized by the tracker to forecast the position of the target in the subsequent frame. Inspired by the SloU [31], an additional constraint is built during the training process, designed to facilitate the model's exploitation of commonalities associated with target motion. The SIoU loss function integrates data pertaining to angle, distance, aspect ratio, and IoU to offer directional guidance throughout the training process. In accordance with Figure 2, the direction vector is visualized as the line connecting the centroids of the prediction box \(\hat{B}\) and the actual box B, with the centroid distance serving as the magnitude of the direction vector. Angle information is provided by the angle between the centroid line and the coordinate axis. The angular measure, denoted as \(\eta\)[31], is specified by the following equation:  
\[\eta=1-2\times\sin^{2}\Bigl{(}\arcsin(\xi)-\frac{\pi}{4}\Bigr{)}, \tag{1}\]  
Figure 1: The framework of our object-tracking algorithm. The TRSM module assumes the responsibility of identifying high-quality tracking results for template updates. The loss function with direction contributes to guiding the model in capturing commonalities associated with the target’s motion. Figure 2: Illustration of angular quantity calculation. when \(\alpha<\frac{\pi}{4}\), we have \(\xi=\frac{C_{\rm h}}{d}=\sin(\alpha)\), and when \(\alpha\geq\frac{\pi}{4}\), then \(\xi=\frac{C_{\rm w}}{d}=\sin(\frac{\pi}{2}-\alpha)\). \(C_{\rm h}\) and \(C_{\rm w}\) denote the distances in the height and width directions, respectively, between the center points of \(\hat{B}\) and \(B\). Consider prediction box \(\hat{B}=\left(\hat{c}_{x},\hat{c}_{y},\hat{w},\hat{h}\right)\) and actual box \(B=\left(c_{x},c_{y},w,h\right)\), with the four dimensions indicating the x and y coordinates of the center point and the width and height of the rectangular box. The distance between \(\hat{B}\) and \(B\) is divided into two directions along the x and y axes and is incorporated with angle information to define the distance loss \(L_{\rm Distance}\)[31] as follows:  
\[L_{\rm Distance}=\sum_{i=x,y}\left(1-e^{-\lambda\rho_{i}}\right), \tag{2}\]  
where \(\rho_{x}=\left(\frac{c_{x}-\hat{c}_{x}}{W_{\rm closure}}\right)^{2}\), \(\rho_{y}=\left(\frac{c_{y}-\hat{c}_{y}}{H_{\rm closure}}\right)^{2}\), and \(\lambda=2-\eta\). Furthermore, \(W_{\rm closure}\) and \(H_{\rm closure}\) denote the width and height of the closed region of \(\hat{B}\) and \(B\), respectively. Define the aspect ratio loss \(L_{\rm Shape}\)[31] as follows:  
\[L_{\rm Shape}=\sum_{i=w,h}\left(1-e^{-\alpha_{i}}\right)^{\epsilon}, \tag{3}\]  
where \(\omega_{w}=\frac{|w-\hat{w}|}{max(w,\hat{a})}\) and \(\omega_{h}=\frac{|h-\hat{h}|}{max(h,\hat{h})}\). Here, \(\epsilon\) is a hyperparameter that controls the weight of the aspect ratio loss in the overall loss. The IoU loss [31] refers to the measurement of the intersection over union of boxes \(\hat{B}\) and B:  
\[IoU=\frac{\left|B\cap\hat{B}\right|}{\left|B\cup\hat{B}\right|}, \tag{4}\]  
The SIoU loss function can be expressed as \(L_{\rm SIoU}\)[31]:  
\[L_{\rm SIoU}=1-IoU+\frac{1}{2}\left(L_{\rm Distance}+L_{\rm Shape}\right), \tag{5}\]  
The inclusion of angle information provides directional guidance in the x and y coordinate axes during distance calculation. This training process enables the model to approach the actual target position along the coordinate axes, thus learning the commonality of target motion information. It allows the algorithm to better capture the direction of target motion during inference and results in improved tracking accuracy.