## 2 Methods and Materials
### Detection Approach
#### 2.3.1 ROI Extraction  
The special structure of solder joints in aviation plugs prevents the camera with a limited DoF from covering the entire image, resulting in only the middle region of image can be clearly captured. The top-down sequential detection strategy cannot ensure that the row of solder joints to be detected remains in the DoF. Therefore, in our detection approach, we first use a fine-tuned YOLOv5 to detect the coordinate of the row to be examined, i.e., ROI extraction. According to this coordinate, the extracted ROI is then fine-adjusted to the center of the DoF via the sliding platform. In this case, the clarity and detail of ROI can be significantly enhanced to facilitate subsequent quality assessment. Moreover, limiting the scope of quality assessment to ROI will greatly reduce background interference. Among the four versions of YOLOv5, we choose YOLOv5m with a good balance between accuracy and speed for ROI extraction. The structure of YOLOv5m with the added squeeze-and-excitation (SE) block [44] is shown in Figure 8, and is made up of three main components: backbone, neck, and prediction head. The numbers indicate the size of the longest side of the image or feature map. Figure 7: The example of image augmentation for ROI extraction. (**a**) Original image. (**b**) Image graying. (**c**) Image blurring. (**d**) Horizontal flipping. (**e**) HSV jittering. (**f**) Mosaic. The backbone module is designed to extract multi-scale features of the input image through layer-by-layer convolution. It consists of five CBS blocks, four CSP1_X blocks, one SPPF block and one SE block. The CBS block is used to achieve image downsampling, and it is stacked with a convolution operation, a batch normalization (BN), and a SiLU activation function. In practice, with the exception of the first CBS block, which uses a convolutional layer with kernel size 6, stride 2, and padding size 2, the others in the backbone are all with kernel size 3 and stride 2. The SCP1_x block is derived from the cross stage partial network [45], and used to enhance model learning capability while ensuring lightweight. It splits the input feature into two paths. One path passes through a CBS model followed by X residual structures, while the other goes directly through a CBS block. Finally, the outputs of the two paths are concatenated and then go through a CBS model. The SPPF block is a fast version of spatial pyramid pooling, which can integrate the feature maps of different receptive fields at a low computational cost. As shown in Figure 8, firstly, a CBS block with kernel size 1 is used to halve the feature channel, and then three serial Maxpool operations are used to obtain three feature maps of different receptive fields, and finally, the above  
Figure 8: The structure of YOLOv5m with the added SE block. four outputs are concatenated followed by a CBS block with kernel size 1 to restore the original feature channel. The Neck module fuses and combines the feature maps generated from the backbone module through the FPN-PAN [46] structure. It is mainly constructed by four CBS blocks, four CSP2_X blocks, some concatenation and upsampling operations. The CSP2_X block is similar to the CSP1_X block but does not have a shortcut connection in the residual structure. As shown in Figure 8, the FPN structure can propagate semantically strong features via a top-bottom path, while the PAN structure boosts the propagation of localization information existing in the shallower layer via a bottom-top path. This dual fusion strategy ensures that each feature layer contains sufficient semantic and localization information, thus, enhancing the ability to detect objects of different sizes and scales. The prediction head aims to output object detection results from three feature maps with different sizes respectively. Since different feature layers contain different semantic and location information, such multi-scale prediction can improve the final detection results and has become a basic operation in modern object detection models.