# Research on a Multi-Type Barcode Defect Detection Model Based on Machine Vision
## 4 Experiment and Results Analysis
### Defect Detection Experiment  
After completing barcode object detection and obtaining precise bounding boxes, this paper manually annotates all candidate boxes. The annotation work was carried out by two industry experts with over five years of experience in barcode defect quality inspection. They first independently marked the samples and then merged the annotations based on [PERSON]'s \(\kappa\) coefficient \(\geq\) 0.92 to ensure label consistency. The final dataset contains three categories: background (class 0), normal barcode (class 1), and defective barcode (class 2). The constructed dataset was randomly divided into training and validation sets in an 8:2 ratio, ensuring that the class distribution in the validation set remained consistent with that in the training set, thereby reducing evaluation bias. To validate the effectiveness of the proposed Y8-LiBAR Net dual-branch fusion network, three network structures were built for comparison experiments. 1. The complete model, Y8-LiBAR Net, which uses convolutional neural networks to capture local texture features and Transformer to obtain long-range dependency information. 2. ResNet-only, where the ViT branch is removed, leaving only the convolutional backbone. 3. ViT-only, which uses only the pure Transformer feature extractor. All three models were trained using weighted cross-entropy with label smoothing (\(\epsilon\ =0.1\)), where the class weights are inversely proportional to the sample frequency to further alleviate the imbalance caused by the long-tailed distribution. The remaining hyperparameters were kept consistent with those used in the object detection stage to ensure the comparability of the experiments. The results of the ablation experiment are shown in the table below. Table 4 summarizes the ablation study used to quantify the contribution of each architectural component of Y8-LiBAR Net. The full model attains the best overall performance (Accuracy = 0.9250, F1 = 0.9187). Removing either feature-extraction branch degrades the results most sharply. Without the ResNet branch, the accuracy falls by 6.2 pp, and the defect-specific Recall \(Rcall_{D}\) drops by 0.243, confirming the critical role of local texture cues. Without the ViT branch, the accuracy decreases by 4.3 pp and \(Rcall_{D}\) by 0.176, highlighting the importance of global context. \begin{table}
\begin{tabular}{c c c c} \hline \hline
**Detection Method** & **Precision** & **Recall** & **F1 Score** \\ \hline Y8-LiBAR-2D & 0.955 & 0.919 & 0.937 \\ Faster R-CNN & 0.952 & 0.921 & 0.936 \\ YOLO Nano & 0.952 & 0.917 & 0.934 \\ RetinaNe & 0.954 & 0.918 & 0.936 \\ YOLO Medium & 0.948 & 0.922 & 0.935 \\ RT-DETR & 0.946 & 0.916 & 0.931 \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Comparative Results of 2D Barcode Object Detection (Each Image Contains \(\geq\) 1 Two-Dimensional Barcode, IoU = 0.5). Eliminating the shared encoder yields a smaller yet noticeable decline (1.8 pp accuracy), indicating that jointly optimizing the two branches promotes complementary feature learning. Finally, suppressing orthogonal regularization still lowers every metric (0.8 pp accuracy), showing that decorrelating the branch features contributes measurable gains even though its effect is less pronounced than that of either branch itself. Overall, the ablation confirms that (i) the dual-branch design is synergistic--both local and global representations are required for top performance--and (ii) the shared encoder and orthogonal constraint provide additional but secondary improvements to robustness and defect-level recall. Beyond the ablation study, we benchmarked the complete Y8-LiBAR Net against three widely used defect-inspection baselines--SVM with a radial-basis-function kernel, DenseNet-121, and ViT-B/16--each reproduced under identical training and testing protocols on the BarBeR defect subset. All methods were evaluated on the common validation split, and detections were verified with the same IoU threshold of 0.5 before classification metrics were calculated.