# Multi-Object Tracking with Grayscale Spatial-Temporal Features
## 3 Method
### Matching and Feature Extraction  
The ID matching and feature extraction process is shown in Figure 5. The green box represents the continuously detected target. The blue box represents the re-detected target and new target. After obtaining the matching results of these two spatial-temporal features, we can judge whether a target is detected in both the current frame and the previous frame according to \(\mathbf{Ps_{t,i}^{k}}\):  
\(\mathbf{Ps_{t,i}^{k}},k>0\), re-detected target or new target,  
\(\mathbf{Ps_{t,i}^{k}},k=0\), continuously detected target. For the continuously detected target, we input it into the first matching module for priority matching. For the continuously detected target, the target does not need to be matched with all targets in the previous frame. We can quickly obtain the ID set \(\mathbf{Id_{t,i}^{k}}\) that the target needs to match using Equation (5):  
\[\mathbf{ps_{t,i+1}^{k}},\mathbf{k>0},\mathbf{Id_{t,i}^{k}}=\mathbf{Pcld_{t-1}^{p_{t,i+1}^{k}-1}} \tag{5}\]  
\(\mathbf{Pcld_{t}^{i}}\) records the ID for each target \(\mathbf{P_{t}^{i}}\) in the t frame, and the gray value of the target-STF of each target \(\mathbf{p_{t}^{j}}\) is \(j+1\) in frame \(t\). Therefore, when we know the \(\mathbf{ps_{t,i+1}^{k}}\) and \(\mathbf{Pcld_{t-1}^{i}}\), we can quickly obtain the ID set \(\mathbf{Id_{t,j}^{k}}\) that the target needs to match. According to \(\mathbf{Id_{t,i}^{k}}\), prioritize matching with \(k\) values equal to 1 during matching. We only need to calculate the IoU without calculating the appearance features and motion features when matching the ID for a continuously detected target. The probability \(\mathbf{p}\) can be obtained by Equation (6):  
\[\mathbf{p}=\mathbf{Max}\left(\mathbf{U}\left(\mathbf{p_{t}^{i}},\mathbf{Id_{t,i}^{k}}\right)\right) \tag{6}\]  
\(U\left(\mathbf{P_{t}^{i}},\mathbf{Id_{t,i}^{k}}\right)\) is a function to obtain the IoU. If the \(\mathbf{p}\) is greater than the set threshold, the match is successful, and then, we update the trajectory of the target and record the ID for target \(\mathbf{P_{t}^{i}}\) and region using \(\mathbf{Pcld_{t}^{i}}\) and \(\mathbf{Rcld_{t,i}^{k}}\). If the \(\mathbf{p}\) is less than the threshold, then put this target into the second stage of matching. According to the different videos, we can choose a different threshold. For re-detected targets, new targets, and continuously detected targets that failed to match in the first stage, we input them into the S matching and feature extraction module  
Figure 5: The ID matching process. The red box represents the detected target. The green box represents the continuously detected target. The blue box represents re-detected target or new target. for second matching. We need to use appearance features and motion features in this module. The ID set \(\mathbf{Id}^{\mathbf{k}}_{\mathbf{t},i}\) that the target needs to match can be obtained by Equation (7):  
\[\mathbf{Id}^{\mathbf{k}}_{\mathbf{t},i}=\mathbf{RID}^{\mathbf{k}}_{\mathbf{t}-\mathbf{1},\mathbf{R} \mathbf{s}_{\mathbf{t}}}\mathbf{n}_{\mathbf{t},i}\cup\mathbf{RcID}^{\mathbf{k}}_{\mathbf{t}-\mathbf{1},\mathbf{R} \mathbf{s}_{\mathbf{t}}^{\mathbf{R}\mathbf{s}_{\mathbf{t},i}}} \tag{7}\]  
We find the region where the target belongs in the previous frame according to the region-STF matching results: \(\mathbf{R}\mathbf{s}_{\mathbf{t},i}\) and \(\mathbf{R}\mathbf{s}_{\mathbf{t}}^{\mathbf{t}}\). According to \(\mathbf{Id}^{\mathbf{k}}_{\mathbf{t},i}\), if \(k=0\), the target \(\mathbf{p}_{\mathbf{t}}^{i}\) does not belong to the region in the previous frame, so put this target \(\mathbf{p}_{\mathbf{t}}^{i}\) into the next stage for matching. After we obtain \(\mathbf{Id}^{\mathbf{k}}_{\mathbf{t},i}\), we can do ID matching based on appearance features and motion features. The probability \(\mathbf{p}\) can be obtained by Equation (8):  
\[\mathbf{p}=\mathbf{Max}\left(