# Dynamic Collaborative Optimization Method for Real-Time Multi-Object Tracking
## 3 Method
### Cross-Frame Association Module  
The Cross-Frame Association Module (CFAM) constructs a global semantic association network and serves as the core component of the object tracking system. This module receives feature vectors outputted by the multi-scale feature enhancement module and is specifically designed to address the challenges of object matching in occluded and dense scenes. By ingeniously integrating temporal contextual information with a dynamic weight allocation mechanism, the CFAM achieves the following three key optimization objectives: establishing long-range dependencies, enhancing adaptive memory capabilities, and maintaining a lightweight computational architecture.  
As shown in Figure 3, the workflow of this module is as follows: First, it encodes the target features of the current frame and historical frames in a multi-modal manner, integrating spatial location asnd motion information. Then, it calculates the similarity matrix between targets using a grouped cross-attention mechanism. Finally, it employs a memory recall mechanism to handle feature associations in occluded scenes. This multi-level design ensures stable target identification and association, even in complex scenarios, and its detailed computational procedure is also provided in Algorithm 2.  
**Algorithm 2:** Cross-Frame Association Module (CFAM)  
**Input:** Current frame features \(\{f_{i}^{t}\}\), previous frame features \(\{f_{j}^{t-1}\}\), target bounding boxes \(\{(w_{i},h_{i})\}\), motion states \(\{(v_{j}^{x},y_{j}^{y})\}\), memory pool \(\mathcal{M}^{t-1}\)  
**Output:** Appearance similarity matrix \(S_{\text{app}}\), updated memory pool \(\mathcal{M}^{t}\)  
/* Step 1: Multimodal Feature Encoding */  
**foreach**_target \(i\) in current frame_**do**  
Compute position encoding: \(\text{PE}(w_{i},h_{i})=\sin\left(\frac{w_{i}}{W_{0}}\right)\oplus\cos\left( \frac{h_{i}}{H_{0}}\right)\);  
Encode query: \(Q_{i}=W_{Q}f_{i}^{t}+\text{PE}(w_{i},h_{i})\);  
**foreach**_target \(j\) in previous frame_**do**  
Compute velocities: \(v_{j}^{x}=\frac{x_{j}^{t-1}-x_{j}^{t-2}}{\Delta t}\), \(v_{j}^{y}=\frac{y_{j}^{t-1}-y_{j}^{t-2}}{\Delta t}\);  
Compute motion encoding: \(\text{PE}(v_{j}^{x},v_{j}^{y})=\sin\left(\frac{v_{j}^{x}}{V_{0}}\right)\oplus \cos\left(\frac{v_{j}^{y}}{V_{0}}\right)\);  
Encode key and value: \(K_{j}=W_{K}f_{j}^{t-1}+\text{PE}(v_{j}^{x},v_{j}^{y})\), \(V_{j}=W_{V}f_{j}^{t-1}\);  
/* Step 2: Grouped Cross-Attention Mechanism */ Split feature space into \(g=4\) groups: \(Q^{(k)},K^{(k)},V^{(k)}\) for \(k=1,\dots,4\);  
Initialize temporal mask \(M_{\text{temp}}\): \(M_{\text{temp}}(i,j)=1\) if target \(j\) exists at \(t-1\), else 0;  
**foreach**_group \(k=1\) to \(4\)_**do**  
Compute attention: \(\text{Attention}_{k}=\text{Softmax}\left(\frac{Q^{(k)}(K^{(k)})^{T}}{\sqrt{d_{k} }}\odot M_{\text{temp}}\right)V^{(k)}\);  
Concatenate and normalize:  
\(f_{\text{out}}^{t}=\text{LayerNorm}(\text{Concat}[\text{Attention}_{1}, \text{Attention}_{2},\text{Attention}_{3},\text{Attention}_{4}])\);  
Compute appearance similarity: \(S_{\text{app}}(i,j)=\text{CosSim}(f_{i}^{t},f_{\text{out},j}^{t})\);  
/* Step 3: Memory Recall Mechanism */  
**foreach**_tracked target \(j\)_**do**  
**if**_target \(j\) matched at frame \(t-1\)_**then**  
Update memory: \(\mathcal{M}_{j}^{t}=[f_{j}^{t-1},\mathcal{M}_{j}^{t-1}(1),\mathcal{M}_{j}^{t-1 }(2)]\);  
**else**  
Update memory: \(\mathcal{M}_{j}^{t}=[f_{j}^{t-1},\mathcal{M}_{j}^{t-1}(0),\mathcal{M}_{j}^{t-1 }(1)]\);  
**if**_target \(j\)