## 3 Methodology
### Vehicle Trajectory Completion  
Due to the insufficient coverage region of the video sensor, gaps exist in the obtained continuous vehicle trajectories, so the missing trajectories must be completed. In this module, we refer to the STGAT model proposed by [PERSON] et al. [57]. Considering the mutual interaction of vehicles, we add the graph attention mechanism to the Seq2 Seq architecture. This model combines the temporal features and the spatial interaction features between vehicles and improves the accuracy of vehicle trajectory completion. Figure 5 shows the bidirectional LSTM vehicle trajectory completion model based on graph attention.  
We propose a double-stream mechanism. The two trajectories before and after the missing trajectory are input into the encoder module to obtain the temporal features. Then the combination of temporal features is input into the decoder module to obtain the final completed trajectory. In our model, two completed vehicle trajectories are generated from the two ends of the missing trajectory towards the middle, respectively. When the Euclidean distance between the two trajectories is less than \(Distance_{low}\) or the maximum number of completion frames is reached (set to \(Frame_{max}\)), the completion is stopped.  
The encoding module consists of an LSTM module and a GAT module. Considering the vehicle's temporal characteristics, we use the LSTM module in the encoder to extract the timing characteristics of the trajectory sequence, focusing on the motion mode of each vehicle. The preliminary encoding results are shown as Equation (4):  
\[m_{i}^{t}=LSTM\left(m_{i}^{t-1},e_{i}^{t};W_{m}\right) \tag{4}\]  
In Equation (4), \(m_{i}^{t}\) is the eigenvector in the network corresponding to vehicle \(i\) at time \(t\), \(e_{i}^{t}\) is the embedded coding result of the position coordinate of vehicle \(i\) at time \(t\), and \(W_{m}\) represents the weight of the model.  
Figure 4: The structure of the vehicle re-identification model.  
For vehicle interaction characteristics, this model uses the graph attention model in the encoder. The model takes all vehicles as nodes and assigns importance to aggregate neighbor vehicle information. The preliminary temporal encoding results are input into the graph attention model, and the output is  
\[\hat{m}_{i}^{t}=\sigma(\sum_{j\in N_{i}}GAT(m_{i}^{t},m_{j}^{t})W_{j}m_{j}^{t}) \tag{5}\]  
\[GAT\Big{(}m_{i}^{t},m_{j}^{t}\Big{)}=\frac{\exp(LeakyReLU(a^{T}[W_{i}m_{i}] \big{|}W_{j}m_{j}]))}{\sum_{k\in N_{i}}\exp(LeakyReLU(a^{T}[W_{i}m_{i}]\big{|}W _{k}m_{k}]))} \tag{6}\]  
In Equations (5) and (6), \(GAT\Big{(}m_{i}^{t},m_{j}^{t}\Big{)}\) is the graph attention coefficient at time t of node pair (i,j), \(\mathbf{W}\) is the dimension mapping matrix, \(N_{i}\) is the set of neighbor nodes of node \(i\), and \(\sigma\) is a nonlinear activation function.  
The decoder module is proposed to aggregate temporal and spatial features and then generate the final completed trajectory. At the time point \(t\) of node \(i\), these characteristics are combined as the input of the LSTM module: the initial coding result \(\overline{m}_{i}=\delta_{1}\big{(}m_{i}^{t}\big{)}\) and the output \(\overline{g}_{i}=\delta_{2}\big{(}g_{i}^{t}\big{)}\) after the graph attention and LSTM coding. Based on this spatiotemporal information, the missing trajectory can be completed.