| 摘要: | 隨著零售業和物流業的快速發展,條碼識別技術在商品管理、倉儲物 流等領域扮演著越來越重要的角色。傳統的條碼掃描技術在實際應用中面 臨諸多挑戰,包括對掃描角度和距離的嚴格要求、環境因素的影響,以及 無法同時處理多個條碼等問題。本研究旨在運用深度學習技術,開發一套 高效、可靠的一二維條碼定位與辨識系統,並將其成功部署至Android行動 裝置。 本研究採用YOLOv8深度學習模型作為核心檢測架構,建立了包含 EAN13、Code128、Code39、QR、PDF417、Data Matrix、Aztec、 MaxiCode等八種常見條碼格式的訓練資料集。透過系統性的實驗設計,本 研究在多個技術層面實現了重要創新。在損失函數優化方面,深入研究了 CIoU、DIoU、GIoU、EIoU等多種IoU基礎損失函數,並重點評估了Wise- IoU系列損失函數的改進效果,其中WIoU_V3在mAP50-95指標上取得了 90.7%的最佳表現。在模型可解釋性方面,採用HiResCAM高分辨率可視化 技術,相較於傳統Grad-CAM提供了更清晰的激活映射,深入分析了模型 對條碼特徵的學習機制。 實驗結果顯示,YOLOv8模型在一二維條碼偵測任務中表現卓越,達 到了99.3%的精確度、100%的召回率、99.5%的mAP50,以及90.1%的 mAP50-95,單張圖像的平均偵測速度僅需5.5毫秒。與YOLOv5的對比實 驗證明,YOLOv8在訓練收斂速度和最終性能方面具有顯著優勢,僅需約 40個epoch即可達到穩定狀態。模型展現出優異的環境適應性,能夠有效處 理部分遮擋、表面塗鴉、反光條件等實際應用中的困難場景。 為實現移動端部署,本研究將訓練完成的YOLOv8模型轉換為 TensorFlow Lite格式,並通過量化技術進行優化。採用Int8量化方案在將模 型體積從42.69MB減少到10.89MB的同時,僅造成3.53%的mAP50-95性能 損失,實現了模型大小與檢測性能的最佳平衡。開發的Android應用程式實 現了完整的條碼偵測解碼功能,包括相機拍攝、相簿選取、深色模式切 換、歷史記錄管理等實用功能。 移動端性能測試結果顯示,YOLOv8模型在Android裝置上的偵測效率 優異,一維條碼和QR碼的偵測時間分別平均為4.7毫秒和5.8毫秒,滿足即 時應用需求。然而,解碼階段存在性能瓶頸,特別是ZXing解碼庫在處理 多個一維條碼時呈現線性增長的時間複雜度,當處理六個一維條碼時總執 行時間達到1226毫秒,其中解碼時間佔比超過99%。 本研究的主要貢獻包括:建立了高性能的一二維條碼檢測模型,實現 了損失函數的系統性優化,提供了深度學習模型的可解釋性分析,成功實 現了輕量化移動端部署。研究成果不僅在技術層面取得重要進展,更具有 顯著的實際應用價值,能夠廣泛應用於零售業、物流業的自動化系統,為 智慧零售和物流自動化的發展提供技術支撐。;With the rapid development of retail and logistics industries, barcode recognition technology plays an increasingly important role in merchandise management and warehousing logistics. Traditional barcode scanning techniques face numerous challenges in practical applications, including strict requirements for scanning angles and distances, environmental factors, and inability to process multiple barcodes simultaneously. This research aims to develop an efficient and reliable one-dimensional and two-dimensional barcode localization and recognition system using deep learning technology, successfully deploying it on Android mobile devices. This study employs the YOLOv8 deep learning model as the core detection architecture and establishes a training dataset containing eight common barcode formats: EAN13, Code128, Code39, QR, PDF417, Data Matrix, Aztec, and MaxiCode. Through systematic experimental design, this research achieves significant innovations across multiple technical aspects. In loss function optimization, we conducted in-depth studies of various IoU-based loss functions including CIoU, DIoU, GIoU, and EIoU, with particular focus on evaluating the improvement effects of the Wise-IoU series loss functions. Among these, WIoU_V3 achieved the best performance of 90.7% on the mAP50-95 metric. For model interpretability, we adopted HiResCAM high-resolution visualization technology, which provides clearer activation mapping compared to traditional Grad-CAM and enables deep analysis of the model′s learning mechanism for barcode features. Experimental results demonstrate that the YOLOv8 model exhibits excellent performance in one-dimensional and two-dimensional barcode detection tasks, achieving 99.3% precision, 100% recall, 99.5% mAP50, and 90.1% mAP50-95, with an average detection speed of only 5.5 milliseconds per image. Comparative experiments with YOLOv5 prove that YOLOv8 has significant advantages in training convergence speed and final performance, requiring only approximately 40 epochs to reach stable state. The model demonstrates excellent environmental adaptability, effectively handling challenging scenarios in practical applications such as partial occlusion, surface graffiti, and reflective conditions. To achieve mobile deployment, this research converts the trained YOLOv8 model to TensorFlow Lite format and optimizes it through quantization techniques. The Int8 quantization scheme reduces model size from 42.69MB to 10.89MB while causing only 3.53% performance loss in mAP50-95, achieving optimal balance between model size and detection performance. The developed Android application implements complete barcode detection and decoding functionality, including camera capture, photo album selection, dark mode switching, and history record management. Mobile performance testing results show that the YOLOv8 model demonstrates excellent detection efficiency on Android devices, with average detection times of 4.7 milliseconds for one-dimensional barcodes and 5.8 milliseconds for QR codes, meeting real-time application requirements. However, performance bottlenecks exist in the decoding stage, particularly with the ZXing decoding library exhibiting linear time complexity growth when processing multiple one-dimensional barcodes. When processing six one- dimensional barcodes, total execution time reaches 1226 milliseconds, with decoding time accounting for over 99% of total processing time. The main contributions of this research include establishing a high- performance one-dimensional and two-dimensional barcode detection model, achieving systematic optimization of loss functions, providing interpretability analysis of deep learning models, and successfully implementing lightweight mobile deployment. The research achievements not only represent significant technical progress but also possess substantial practical application value, enabling widespread application in automation systems for retail and logistics industries, providing technical support for the development of smart retail and logistics automation. |