# High-Precision Chip Detection Using YOLO-Based Methods
## 2 Materials and Methods
### Dynamic Non-Maximum Suppression (DNMS) Algorithm
#### 2.2.2 Box Size Adjustment  
During the non-maximum suppression (NMS) process, bounding boxes are suppressed by calculating the IoU values between the ground truth and the predicted bounding boxes. The formula for the standard IoU computation is shown in Equation (6):  
\[\text{IoU}=\frac{\text{Area of Overlap}}{\text{Area of Union}} \tag{6}\]  
From Equation (6), it can be observed that the IoU value is related to both the area of the ground truth and the area of the predicted bounding box. However, the chips are usually very small; as a result, when the predicted bounding boxes deviate from their true positions, the NMS algorithm can easily lead to false positives or missed detections, especially in scenarios with overlapping objects or localization errors. In actual processing, in most images, there will be a leaving chip. When the chip is ejected, the most likely situation in the image is the presence of one leaving chip and one left chip. Since the breaking of chips is a random behavior, the possibility of multiple left chips appearing in images where chips have broken off is also very high. Based on this possibility, this paper first introduces a scaling mechanism for the size of the predicted bounding box. Through this adjustment, the monitoring results can be better combined with the actual conditions. In this paper, the size of the predicted bounding box of the chips (denoted as \(Bd\)) will be adjusted according to the relative positions of the ground truth box of the workpiece (denoted as \(BW^{gt}\)) and the chip box. Suppose that \(\left(xw_{\varepsilon}^{gt},yw_{\varepsilon}^{gt}\right)\) and \(\left(xd_{c},yd_{c}\right)\) are the center points of \(BW^{gt}\) and \(Bd\), respectively. \(ww^{gt}\) and \(hw^{gt}\) are the width and height of \(BW^{gt}\), and \(wd\) and \(hd\) are the width and height of \(Bd\). A ratio is used as the adjustment coefficient, and the new width and height of \(Bd\) (\(wd^{\prime},hd^{\prime}\)) are formulated as  
\[wd^{\prime}=\left\{ \begin{matrix}wd+ratio*(1-wd)\ if\ wd<0.9\\ wd,\ if\ wd\geq 0.9\end{matrix} \right. \tag{7}\]  
\[hd^{\prime}=\left\{ \begin{matrix}hd+ratio*(1-hd)\ if\ hd<0.9\\ hd,\ if\ hd\geq 0.9\end{matrix} \right. \tag{8}\]  
where the ratio is determined by Equation (9):  
Figure 6: Leaving chips and left chips: (**a**) the workpiece processing site, (**b**) pixel size information. on the original YOLO algorithm to count the number of left chips in the video can lead to large errors. To address this issue, this paper proposes a video post-processing algorithm that utilizes a rising edge signal trigger based on the prediction result as follows. The post-processing algorithm in this paper uses the leaving chips detected by the YOLO algorithm as a trigger and calculates the chip quantity based on the number of left chip occurrences throughout the triggered frames. During detection, we only verify the presence of leaving chips in each frame (without considering the quantity), whereas, for left chips, we track the number of occurrences in every frame. Therefore, this method is applicable to statistical tasks under both single-target and multi-target scenarios. The specific steps are as follows. The process begins with the preliminary processing of the prediction results of YOLO into temporal information, where the horizontal axis represents the time and the vertical axis indicates the number of predictions. Figure 7 illustrates the complete procedure of YOLO in detecting the video frames. On the time axis, the horizontal coordinate represents the timeframe, while the corresponding vertical coordinate shows the number of prediction results. YOLO detects crack chips in each frame and generates prediction results. For instance, the first frame may detect zero chips, yielding a prediction flag of 0; the 2 nd to 5 th frames all contain one or more leaving chips, resulting in a prediction flag of 1; finally, the last frame may again show no detected leaving chips, reducing the prediction flag back to 0.