## 2 Methodology
### Network Structure  
In order to make the selected network relatively suitable for edge computing devices, the Yolov5 network [26] is selected for subsequent algorithm improvement and testing based on previous experience with foreign object detection networks and taking into account the number of parameters, computational power, and model size [27]. The structure of the Yolov5 network is clearly shown in Figure 4.  
In combination with that shown in Figure 1, CSPDarkNet is used as the backbone. The cross-stage partial (CSP) module is used repeatedly to deepen the network depth, thus enhancing the feature extraction ability. It contains two structures, namely CSP 1-X and CSP 2-X, which are shown in Figure 4b. The \"X\" indicates that the structure in the dotted box is repeated X times. In detail, in the CSP 1-X module, the network inside the dotted box contains the residual structure, which effectively increases the gradient value of backpropagation between each convolutional layer, thus reducing the possibility of gradient disappearance caused by network deepening. It should be mentioned that the Yolov5 network can achieve different complexity levels by adjusting the value of X. Specifically, for networks of Yolov5 s-m-l-x with different complexity, the values of X in the network can be found in Table 1. To explain the network more clearly, we use B1-B3 and N1-N5 in Figure 4a and Table 1 to indicate the locations of the corresponding CSP modules, in which B1-B3 represent positions 1-3 in the backbone part, and N1-N5 represent positions 1-5 in the neck part. As for the feature enhancement part, the feature pyramid network (FPN) and path aggregation network (PANet) [28] are used to enhance the obtained features. Through up-sampling and feature layer splicing, target semantic information and location information at different levels can be fully fused or compensated, which has positive significance in improving the accuracy of detection. In the head part, no changes are made to the prediction head; it is still the same and uses the original Yolov5, which is used to predict the left or right belt edge region. Its prediction results contain the confidence of the predicted targets, the center point coordinates, the width and height information of the prediction box, etc. \begin{table}
\begin{tabular}{c c c c c c c c c} \hline \hline
**ModelPosition** & **B1** & **B2** & **B3** & **N1** & **N2** & **N3** & **N4** & **N5** \\ \hline Yolov5-s & 1 & 3 & 3 & 1 & 1 & 1 & 1 & 1 \\ Yolov5-m & 2 & 6 & 6 & 2 & 2 & 2 & 2 \\ Yolov5-l & 3 & 9 & 9 & 3 & 3 & 3 & 3 \\ Yolov5-x & 4 & 12 & 12 & 4 & 4 & 4 & 4 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: The statistics of the number of X in the CSP block. Figure 4: The detection network structure used in this paper: (**a**) main body, (**b**) CSP 1-X, (**c**) CSP 2-X. In addition, considering that the conveyor belt edge straight-line detection method proposed in this paper relies heavily on the detection results for the belt edge region, we incorporate three attention mechanism models--the squeeze-and-excitation network (SENet) [29], efficient channel attention (ECA) [30], and the convolutional block attention module (CBAM) [31]--into the backbone feature extraction network. The added positions are shown in Figure 4, and the network structure of the three attention mechanisms is shown in Figure 5.  
It should be mentioned that each attention mechanism is used separately. As shown in Figure 4, there are three places where attention is added, but a corresponding attention is not added to each place. In Figure 5, Global AVG-Pool (GAP) represents global average pooling, GMP (Global Max-Pool) represents global max pooling, CAP (Channel AVG-Pool) represents the average pooling per channel, and CMP (Channel Max-Pool) represents the max pooling per channel. Through pooling and full connection, the weight of the space occupied by each channel or location can be obtained, i.e., the influence of this channel or location on feature extraction.