# Research on Multi-Modal Pedestrian Detection and Tracking Algorithm Based on Deep Learning
## 3 Prediction Layer
### Determine the Anchor Frame  
To obtain anchor frame data that effectively represents the dataset, traditional methods like faster R-CNN often rely on the empirical judgment of researchers. In YOLOv2 and its subsequent iterations, researchers commonly utilize the k-means algorithm to determine suitable anchor frame data by clustering the centers of real bounding boxes from annotated information in the dataset. However, the conventional k-means algorithm, which relies on Euclidean distance, may not be ideal for clustering scenarios involving anchor frames. Hence, it becomes imperative to employ a suitable distance metric.  
Figure 7: Processing flow of prediction layer.  
The residual cross-merge area ratio (RCMAR) offers a robust measure of similarity between the shapes and sizes of two bounding boxes. A smaller output value signifies a higher similarity between two bounding boxes, effectively addressing the issue.  
Therefore, this article adopts RCMAR as the measurement method, with the expression as follows:  
\[\text{Dist}(w_{1},h_{1},w_{2},h_{2})=1-\frac{\min(w_{1},w_{2})\cdot\min(h_{1},h_{ 2})}{w_{1}\cdot h_{1}+w_{2}\cdot h_{2}-\min(w_{1},w_{2})\cdot\min(h_{1},h_{2})} \tag{2}\]  
Based on the clustering results obtained by k-means using the residual intersection area ratio measurement method, this paper introduces genetic algorithms to further optimize and obtain anchor frame data that best represents the dataset. This optimization aims to expedite the convergence process of the network and enhance the algorithm's robustness [13].  
In this paper, the fitness function calculation method involves dividing the width and height of each bounding box in the dataset by the width and height of the anchor box combination. Then, the Maximum Matching Box Ratio (MMBR) is employed to compute the matching score between the current annotated bounding box and anchor box. Finally, the matching scores exceeding a specified threshold (default value is 0.25) are aggregated to calculate the average score, which reflects the overall fitness of the anchor box. The fitness function calculation formula and MMBR calculation formula proposed in this paper are as follows:  
\[\text{f}(wh,\ anchors,\ thr)=\frac{1}{N}\hat{\sum_{i=1}^{\prime}\delta(MMBR(w_{i },\ h_{i},\ anchors),\ thr)} \tag{3}\]  
\[\delta(x,\ thr)=\begin{cases}x,&\text{if }x>thr\\ 0,&\text{otherwise}\end{cases} \tag{4}\]  
\[\begin{array}{c}MMBR(w,\ h,\ anchors)=\max\{\min\Bigl{[}\gamma(\frac{w}{anchor\_w_{1}}),\ \gamma(\frac{h}{anchor\_h_{1}})\Bigr{]}\\ \ldots,\min\Bigl{[}\gamma(\frac{w}{anchor\_w_{n}}),\ \gamma(\frac{h}{anchor\_h_{n}}) \Bigr{]}\}\end{array} \tag{5}\]  
In the formula, \(h\), \(w\) is the height and width information of all annotated boundary frames of the training set, anchors are the anchoring frame combination obtained by the genetic algorithm, \(n\) is the total number of annotated boundary frames, \(thr\) is the threshold value calculated for MMBR, \(wi\) is the width of the \(i\)-th annotated boundary frame, hi is the height of the \(i\)-th annotated boundary frame, anchor \(wi\) is the width of the \(i\)-th prior frame in the anchor frame combination, and anchor \(i\) is the height of the \(i\)-th prior frame in the anchor frame combination.