# Research on a Multi-Type Barcode Defect Detection Model Based on Machine Vision
## 4 Experiment and Results Analysis
### Object Detection Experiment  
To validate the effectiveness of the barcode object detection scheme proposed in this paper, this section systematically evaluates the fine-tuned YOLOv8n on the BarBeR dataset test set and compares it with various mainstream detectors. The evaluation metrics include Precision, Recall, and [EMAIL_ADDRESS] m. During the training phase, only the two output channels of the Head are retained to adapt to the 1D and 2D barcode categories, while the rest of the network structure maintains the default settings of the official YOLOv8n. The training uses a batch size of 32,100 epochs, the Cosine Decay learning rate strategy, and enables Mosaic and HSV-Aug data augmentation.  
(1) Detection Curve Analysis  
To comprehensively evaluate the model's performance at different detection stages, this paper plots four types of metric curves, including the Precision-Recall curve, F1-Confidence curve, Recall-Confidence curve, and Precision-Confidence curve. The results are shown in Figure 10. These curves form a progressive evaluation system from the perspectives of overall accuracy, optimal threshold, recall stability, and false detection control.  
Starting from the overall detection effect, Figure a shows the change in accuracy at different recall rates, i.e., the Precision-Recall curve. It can be observed that the curve for 1D barcodes is almost close to the upper axis, with [EMAIL_ADDRESS] reaching 0.992, while for 2D barcodes, it is slightly lower at 0.977. The average [EMAIL_ADDRESS] for the overall categories is 0.984, indicating that the model achieves excellent detection accuracy while maintaining strong recall capability, demonstrating good overall detection quality.  
After understanding the model's overall performance, the next step is to determine the optimal confidence threshold for practical deployment. Figure b shows the variation curve of the F1 score with different confidence values. It can be seen that when the confidence is 0.723, the F1 value reaches its maximum value of 0.97, indicating that Precision and Recall achieve an optimal balance, making this an ideal choice for the default threshold in subsequent inference.  
On this basis, Figure c shows the trend of Recall with varying confidence levels, used to measure the model's detection ability. From the graph, it is evident that for confidence values between 0 and 0.8, Recall remains above 0.93, indicating that the model can still stably detect most targets at low to medium thresholds, demonstrating strong recall robustness.  
Figure 9: Examples of barcode images from the dataset, including various 1D and 2D formats with different types of defects.  
Finally, Figure d presents the variation of Precision with confidence. As the confidence increases, Precision monotonically increases and approaches 1.00 at 0.986. This indicates that the model has almost no false detections under high confidence conditions, which is suitable for detection scenarios where a low tolerance for misclassification is required.  
In summary, the four detection metric curves provide a systematic evaluation of the model from overall detection quality, optimal threshold selection, recall stability, and false detection control. The results show that the constructed YOLOv8n detection model not only achieves high Precision and Recall but also exhibits good threshold adaptability, providing stable and reliable candidate region support for subsequent defect recognition.