# Research on a Multi-Type Barcode Defect Detection Model Based on Machine Vision
###### Abstract  
Barcodes are ubiquitous in manufacturing and logistics, but defects can reduce decoding efficiency and disrupt the supply chain. Existing studies primarily focus on a single barcode type or rely on small-scale datasets, limiting generalizability. We propose Y8-LiBAR Net, a lightweight two-stage framework for multi-type barcode defect detection. In stage 1, a YOLOv8n backbone localizes 1D and 2D barcodes in real time. In stage 2, a dual-branch network integrating ResNet50 and ViT-B/16 via hierarchical attention performs three-class classification on cropped regions of interest (ROIs): intact, defective, and non-barcode. Experiments conducted on the public BarBeR dataset, covering planar/non-planar surfaces, varying illumination, and sensor noise, show that Y8-LiBARNet achieves a detection-stage [EMAIL_ADDRESS] = 0.984 (1D: 0.992; 2D: 0.977) with a peak F1 score of 0.970. Subsequent defect classification attains 0.925 accuracy, 0.925 recall, and a 0.919 F1 score. Compared with single-branch baselines, our framework improves overall accuracy by 1.8-3.4% and enhances defective barcode recall by 8.9%. A Cohen's kappa of 0.920 indicates strong label consistency and model robustness. These results demonstrate that Y8-LiBARNet delivers high-precision real-time performance, providing a practical solution for industrial barcode quality inspection. computer vision; defect detection; multi-type barcodes; Y8-LiBAR Net 202515817618 June 202515 July 202515 July 202515 July 202515 July 202515 July 202515817618 June 202515 July 202515 July 202515 July 202515817618 June 202515 July 202515817618 June 202515 July 202515817618 June 202515817618 June 202  
variable-width bars and spacings, whereas 2D variants store more data using a matrix structure across horizontal and vertical axes, delivering higher capacity [4] (Figures 1 and 2). Advances in deep learning and machine vision, coupled with diverse application scenarios, offer powerful solutions to these challenges. For example, [PERSON] et al. [5] proposed a hybrid human-in-the-loop model for musculoskeletal disease diagnosis using X-ray images, achieving significant improvements in diagnostic accuracy and efficiency. Likewise, deep learning has been applied to barcode detection, focusing primarily on identification and defect detection during printing processes [6]. In 2023, [PERSON] et al. [7] released the general-purpose YOLOv8 object detection model, which provides fast and efficient performance for barcode detection, among other computer vision tasks. Significant progress has been made in barcode defect detection, with 25 publications from 2015 to 2021 introducing deep learning-based methods for 1D, 2D, or hybrid barcode detection [8]. However, persistent issues hinder definitive assessments of method effectiveness and applicability [9], including reliance on small datasets that inadequately represent real-world conditions, methodological restriction to single barcode types, compromising generalizability, and inconsistent evaluation metrics causing contradictory comparisons even with identical algorithms and datasets. To address these limitations, we employ the BarBeR (Barcode Benchmark Repository) public dataset [9], released by [PERSON] et al. in 2025, which encompasses multiple barcode types and standardized benchmarks. We construct a two-stage hybrid model by integrating YOLOv8n, ResNet50, and Vision Transformer (ViT-B/16) to enable rapid and accurate barcode defect detection. Our main contributions include the following:  
(1) Unified Detection Process for Multi-Modal Features. This work integrates differences in the features of 1D and 2D barcodes, as well as flat and non-flat barcodes, to establish a unified detection pipeline from real-time barcode localization to precise defect classification.