# Ball Tracking Based on Multiscale Feature Enhancement and Cooperative Trajectory Matching
## 3 Methods
### Ball Tracking
#### 3.4.1 Multilevel Cooperative Matching  
Kalman filter matching. Use the latest box of the existing trajectory and Kalman filter to estimate the position of the next box; calculate the distance between the selected box and the estimated box in turn. According to the ball detection algorithm described above, multiple detection results can be obtained in the form of tiling in the image. Assume that each detection result object is \(D_{i}\), and a capacity of \(M\) can be maintained based on the confidence score of each detection. A small root heap is used to construct a candidate set \(\mathcal{D}\) that needs to be searched for potential detection objects as a continuation trajectory. The Kalman filter matching branch is the preferred method in the multilevel collaborative trajectory matching stage, that is, the appropriate observation object is first selected in the form of distance calculation and matching in \(\mathcal{D}\) as the output of the Kalman filter matching process. Different from the classic object tracking algorithm [30], in the process of calculating the distance, the original IoU distance is replaced by the distance between the center points of the detection objects. Assume that the trajectory frame at time \(k-1\) in the current trajectory is \(T_{k-1}\), calculate the distance between each candidate detection \(D_{i}\) and the estimated value \(T_{k}\) at the time of k by Equation (19). \[d^{(1)}_{(i,k)}=\alpha+\tanh(\lambda\|D_{i}-T_{k}\|)+\beta \tag{19}\]  
where \(\alpha\) and \(\beta\) are balance factors, with a value of 0.5, and \(\lambda\) is a scaling factor, with a value of 0.02. Linear motion matching. Based on the assumption that the ball moves in a straight line at a uniform speed, linear screening selects new candidate detections from \(\mathcal{D}\) by judging whether the object at different times complies with simple linear motion. Considering that different videos may have different frame rates, and even the movement speed of the ball at different times in the same video is very different, the linear model only considers the latest trajectory results \(k-1\) moments and the current detection \(D_{i}\) to be filtered. Assuming that the latest tracking \(T_{k-1}\) in the trajectory is valid, the rate is \(v_{k-1}\), and its position is \(S_{k-1}\), then the current i-th detection is based on a simple linear model. The prediction of the location can be expressed as Equation (20). \[S_{k}=S_{k-1}+v_{k-1}+\delta \tag{20}\]  
Equation (20) needs to always calculate the speed corresponding to the last valid detection. This process can also be simplified according to the characteristics of the ball scene, that is, ignoring the motion direction information, calculating the speed of each valid detection in the sum \(\mathcal{D}\) Distance, and finding the one with the minimum distance; if it is less than the threshold, it can be used as a new detection to continue the trajectory, then add the trajectory result set and update to end the linear filtering process. \(\delta\) is the fluctuation bias constant, which generally takes the side length of the last detected ball boundary box. If the position of the candidate detection \(D_{i}\) is \(S_{i}\), then the linear motion matching distance is shown in Equation (21). \[d^{(2)}_{(i,k)}=\|S_{k}-S_{i}\|_{2} \tag{21}\]  
Appearance features match. Feature matching uses the appearance features of the ball set in advance to match the most likely detection in \(\mathcal{D}\) after both Kalman filtering and linear motion matching fail or multiple detection frames are matched. By constructing the appearance feature set of the ball in advance, the single confidence level in the detection model is supplemented by calculating the degree to which the new detection matches the extracted features, thereby reducing the probability of false detection in the detection set.