## 3 Methodology
### Single-Region Video Trajectory Extraction  
Many challenges are involved in extracting vehicle trajectories from visual sensors. The videos of visual sensors used in this experiment have problems such as insufficient video pixels, video jitter, and mutual occlusion between vehicles. To obtain more accurate single-region video trajectory data, we adjusted the videos for deshaking and color contrast to stabilize their vehicle trajectory data. Aiming for the occlusion between vehicles, we  
Figure 1: The framework for continuous vehicle trajectory reconstruction based on video data.  
used the DeepSORT multi-target tracking model in this module [28]. When the vehicle is temporarily occluded in the video, it can still be recognized and tracked by the model. Figure 2 shows the model structure.  
Firstly, the model uses the YOLOv5 algorithm to extract the vehicle position information from the current frame in the video; it then uses Kalman filtering to predict the position of each vehicle in the next frame. The model then reuses YOLOv5 to extract the vehicle position information from the next frame. The model then uses the Hungarian algorithm to perform positional and visual data association of detected and predicted vehicle positions, determining the matching relationship between vehicles in the preceding and following video frames. After the matching is completed, the model updates the tracked vehicle position box. The model continuously loops to track the vehicle trajectory in the video.  
The vehicle trajectory obtained from the video is in the pixel coordinate system, but the required trajectory coordinates should be in the world coordinate system. It is necessary to convert the coordinate system of the vehicle trajectory. The conversion of the pixel coordinate system to the world coordinate system usually conforms to the following Equation (1):  
\[\begin{pmatrix}u\\ v\\ 1\end{pmatrix}=\frac{1}{2}H\begin{pmatrix}U\\ V\\ 1\end{pmatrix}=\frac{1}{2}\begin{bmatrix}H_{11}&H_{12}&H_{13}\\ H_{21}&H_{22}&H_{23}\\ H_{31}&H_{32}&H_{33}\end{pmatrix}\begin{pmatrix}U\\ V\\ 1\end{pmatrix} \tag{1}\]  
In Equation (1), \(H\) is the homography matrix, which is obtained by multiplying the internal and external parameters of the camera. Here, \(A\) represents the intrinsic parameters of the camera, \(R_{1}\) represents the first column of the rotation matrix, \(R_{2}\) represents the second column of the rotation matrix, and \(T\) represents the translation vector. \(Z\) represents the scale factor, \(u\) and \(v\) represent pixel coordinates, and \(U\) and \(V\) represent the corresponding world coordinates.  
According to the design standard, we can obtain a priori information on the relative positions of the lane lines in space (in China, the longitudinal length of lane lines along the lane direction is 6 m, the longitudinal distance between lane lines along the lane direction  
Figure 2: The structure of the single-region video trajectory extraction module.  
is 9 m, and the lane width is 3-4 m.) [55]. We can select four points located on the lane line from the video image. The distance between these four points in the world coordinate system should satisfy the prior information on the lane lines. We choose one of the points as the origin and use the prior information to obtain the coordinates of the other three points in the world coordinate system. \(H\) and \(Z\) can be calculated by inserting the pixel coordinate system coordinates and world coordinate system coordinates of these points into the formula. The transformation matrix can then be used to convert the pixel coordinates to world coordinates for the video. Figure 3 shows the matrix calibration process.