# Application of Augmented Reality in Waterway Traffic Management Using Sparse Spatiotemporal Data
## 4 Methodology
### Multi-Source Data Fusion
#### 4.4.3 AIS and Video Data Matching Method  
In the pixel coordinate system of the video data, the vessel's position and motion trajectory are obtained in real time through object detection and tracking. By using the vessel's current pixel coordinates \((x,y)\), the specific region Vi in which the vessel is located can be identified.  
Within the actual camera view region set, the vessel's latitude and longitude from historical AIS data are first predicted using a prediction model to obtain the latitude and longitude coordinates \((\lambda,\varphi)\) synchronized with the video timestamp. These coordinates are then converted into polar coordinates \((r_{i},\phi_{i})\) using the camera's installation position \((\lambda_{0},\varphi_{0})\) and azimuth angle, \(\phi\). Finally, the set number, \(P_{i}\), of the region in which the vessel is located, is determined based on the polar coordinates. The specific conversion formula is as follows:  
\[r_{i}=\sqrt{\left(\lambda-\lambda_{0}\right)^{2}+\left(\varphi-\varphi_{0} \right)^{2}},\phi_{i}\ =\arctan\left(\frac{\varphi-\varphi_{0}}{\lambda-\lambda_{0}}\right) \tag{33}\]  
If a region set contains multiple vessels simultaneously, the angle-first matching rule can effectively prioritize vessel targets, ensuring more accurate matching between AIS and video data. Initially, vessels are prioritized based on the baseline priority of the vessel targets and the region set to which they belong, sorted from nearest to farthest, with the closest vessel matched first.  
Suppose that there are N detected vessel targets in a region set, \(P_{i}\), denoted as \(\{S_{1},S_{2},\ldots S_{\mathrm{N}}\}\). The baseline angle of each target in the region set \(P_{i}\) is \(\theta_{0}+i\cdot\Delta\theta\), where the calculation formula for each target relative to the baseline is as follows:  
\[\phi_{j}=\phi_{i}\ -(\theta_{0}+i\cdot\Delta\theta)j=1,2,\ldots,\mathrm{N} \tag{34}\]According to the angle-first matching principle, we sort the features of all target vessels \(\rm v_{i}^{(P_{i})}\) in the region set \(\rm P_{i}\) by the angle interval \(\rm\phi_{j}\) in ascending order, denoted as follows:  
\[\rm v_{1}^{(P_{i})}\leq\rm v_{2}^{(P_{i})}\leq\ \ldots\ \leq\rm v_{N}^{(P_{i})} \tag{35}\]  
Here, \(\rm v_{j}^{(P_{i})}\) represents the AIS feature of the j-th vessel in the region set \(\rm P_{i}\), sorted by the angle interval in increasing order relative to the baseline angle. Starting from the baseline \(\rm V_{0}+i\cdot\Delta V\) of the pixel interval in the pixel coordinate system, vessel feature matching is performed from left to right. The first vessel pixel coordinate encountered is matched with the first vessel feature, \(\rm v_{i}^{(P_{i})}\), in the distance-sorted list, and this process continues for all vessels in the region.  
This study validates the matching through the distance between the vessel and the camera. First, multiple vessels within the same region set are sorted in ascending order based on their distances from the camera position. The distances between these targets and the camera are denoted as \(\rm r_{i}^{(P_{i})}\). Following the distance-prioritized matching principle, the features, \(\rm S_{i}^{(P_{i})}\), of all target vessels are sorted in ascending order of their distance intervals \(\rm r_{i}^{(P_{i})}\), denoted as follows:  
\[\rm S_{1}^{(P_{i})}\leq\rm S_{2}^{(P_{i})}\leq\ \ldots\ \leq\rm S_{N}^{(P_{i})} \tag{36}\]  
Next, starting from the baseline in the pixel coordinates, vessel feature matching is performed from bottom to top. The first vessel pixel coordinate encountered is matched with the first vessel feature, \(\rm S_{1}^{(P_{i})}\), from the distance-sorted list, and the process continues accordingly. Finally, the vessel features \(\rm v_{i}^{(P_{i})}\) matched based on the angle-prioritized principle and the vessel features \(\rm S_{i}^{(P_{i})}\) matched based on the distance-prioritized principle are compared. If they correspond to the same vessel, the match is considered successful.