Bar code detection method and system based on improved YOLOv8

By improving the barcode detection method of YOLOv8, a multi-scale linear attention mechanism and an EfficientViT unit were introduced, combined with the C2f-Ghost unit and the anchor-free detection head, and combined optimization using DFL and CIoU loss functions was solved, and the problem of insufficient barcode detection accuracy and low detection efficiency in the prior art was solved, and efficient and accurate barcode detection was achieved.

CN119540709AActive Publication Date: 2025-02-28ZHEJIANG SCI-TECH UNIV

Patent Information

Application Number
CN202411412703.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-11
Publication Date
2025-02-28
Estimated Expiration
2044-10-11

AI Technical Summary

Technical Problem

The prior art has insufficient detection accuracy due to the limitation of feature extraction capabilities in barcode detection, and consumes more computing resources in complex backgrounds, reducing detection efficiency.

Method used

The barcode detection method of YOLOv8 is improved, and the EfficientViT unit of the multi-scale linear attention mechanism unit and the linear attention mechanism enhancement unit is introduced into the backbone network module, combined with the C2f-Ghost unit and the anchor-free detection head, and combined with the DFL and CIoU loss functions are used for joint optimization.

Benefits of technology

It improves the accuracy and efficiency of barcode feature extraction, enhances the robustness of the model to complex backgrounds, improves the detection speed and accuracy, and reduces the number of parameters and calculations of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119540709A_ABST
    Figure CN119540709A_ABST
Patent Text Reader

Abstract

The invention provides a bar code detection method and system based on improved YOLOv8, and relates to the technical field of target detection.The method comprises the steps that a sample set with a plurality of bar code pictures is established, and each bar code picture is provided with a bar code position label and a bar code category label; a bar code detection model is constructed, and the bar code detection model comprises a backbone network module, a neck network module and a detection head module which are connected in sequence; establishing a joint loss function comprising a DFL loss function and a CIoU loss function; inputting the extended data set into a bar code detection model to train the bar code detection model until the joint loss function value is smaller than a preset joint loss function value; obtaining a to-be-detected bar code picture; and inputting a to-be-detected bar code picture into the trained bar code detection model, and outputting a predicted bar code position and a predicted bar code category. Detection resource consumption is reduced, and detection accuracy and detection speed are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of target detection, and in particular to a barcode detection method and system based on improved YOLOv8. Background Art

[0002] A barcode is a machine-readable encoding method, usually composed of black and white stripes of varying widths, used to identify a unique identifier for a product, asset, or other item. By scanning a barcode, you can quickly obtain relevant information, such as the price and inventory of a product. YOLOv8 is a deep learning-based object detection algorithm, and its full name is "You Only LookOnce". The algorithm is able to detect and identify multiple objects in real time in an image or video, and is known for its high speed and accuracy. YOLOv8 is the latest version of this series of algorithms, with higher detection accuracy and faster inference speed.

[0003] Barcode detection is crucial in many applications, such as inventory management, logistics tracking and automated settlement. By accurately detecting and reading barcodes, work efficiency can be improved, human errors can be reduced, and data accuracy can be ensured. This not only optimizes operational processes, but also provides companies with real-time data tracking and analysis capabilities.

[0004] However, in the existing barcode detection process, since barcodes usually appear as thin lines and high-contrast stripes, these features are difficult to be fully captured during the extraction process, and the feature extraction capability is greatly limited, resulting in insufficient detection accuracy. In addition, in actual scenarios, barcodes may appear in complex backgrounds, and sometimes even have a similar color to the background. In complex backgrounds, more computing resources are consumed to distinguish barcodes from other similar features, which increases processing time and reduces detection efficiency. Summary of the invention

[0005] In order to solve the technical problems in the prior art that, in the barcode detection process, since the barcode is usually presented as thin and long lines and high-contrast stripes, these features are difficult to be fully captured during the extraction process, the feature extraction capability is greatly limited, resulting in insufficient detection accuracy, and in actual scenarios, the barcode may appear in a complex background, and sometimes even have a similar color to the background. In the complex background, more computing resources are consumed to distinguish the barcode from other similar features, which increases the processing time and reduces the detection efficiency. The present invention provides a barcode detection method and system based on improved YOLOv8.

[0006] The technical solution provided by the embodiment of the present invention is as follows:

[0007] First aspect

[0008] An embodiment of the present invention provides a barcode detection method based on improved YOLOv8, comprising:

[0009] S1: establishing a sample set with multiple barcode images, wherein each barcode image has a barcode position label and a barcode category label;

[0010] S2: construct a barcode detection model, wherein the barcode detection model includes a backbone network module, a neck network module and a detection head module connected in sequence, wherein the backbone network module includes an EfficientViT unit having a multi-scale linear attention mechanism unit and a linear attention mechanism enhancement unit with a nonlinear function, the linear attention mechanism enhancement unit includes an FFN layer and a deep convolution unit connected to each other, the neck network module includes a C2f-Ghost unit for feature fusion, and the detection head module includes a detection unit having multiple anchor-free detection heads, wherein the C2f-Ghost unit is a C2f unit including a Ghost subunit;

[0011] S3: Establish a joint loss function including the DFL loss function and the CIoU loss function;

[0012] S4: inputting the expanded data set into the barcode detection model to train the barcode detection model until the joint loss function value is less than a preset joint loss function value;

[0013] S5: Obtain the barcode image to be detected;

[0014] S6: Input the barcode image to be detected into the trained barcode detection model, and output the predicted barcode position and predicted barcode category.

[0015] Second aspect

[0016] An embodiment of the present invention provides a barcode detection system based on improved YOLOv8, comprising:

[0017] processor;

[0018] A memory having computer-readable instructions stored thereon, wherein when the computer-readable instructions are executed by the processor, the barcode detection method based on the improved YOLOv8 as described in the first aspect is implemented.

[0019] The third aspect

[0020] An embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored. When the program is executed by a processor, the barcode detection method based on the improved YOLOv8 as described in the first aspect is implemented.

[0021] The beneficial effects brought about by the technical solution provided by the embodiment of the present invention include at least:

[0022] In the present invention, the traditional YOLOv8 backbone network module, neck network module and detection head module are improved. Specifically, a multi-scale linear attention mechanism unit with a nonlinear function and an EfficientViT unit of a linear attention mechanism enhancement unit are introduced into the backbone network module. The linear attention mechanism enhancement unit includes an interconnected FFN layer and a deep convolution unit. The attention mechanism is introduced to achieve higher accuracy of barcode detection with a smaller amount of parameters and calculations. Convolution is used to enhance linear attention to improve the model's attention to spatial local information. Group convolution is used inside the module to reduce the total number of operations for information aggregation, which can further improve the efficiency of the model in extracting barcode features. A C2f-Ghost unit for feature fusion is introduced into the neck network module, and a Ghost module is introduced into the C2f module. The C2f module is improved from the convolution level to improve The efficiency of the convolution operation of the C2f module is improved, thereby improving the detection speed of the barcode detection model. A detection unit with multiple anchor-free detection heads is introduced in the detection head module. The design of multiple detection heads can learn and fuse the target's position and category information through different branches respectively. This method can effectively reduce the number of parameters, speed up the model training speed, reduce the risk of model overfitting, and enhance the generalization ability and robustness of the model. It improves the efficiency of feature extraction, feature fusion and target recognition in all aspects, improves the accuracy of feature capture, and thus increases the detection accuracy and efficiency of barcode targets. In addition, considering that the actual distribution of the target barcode is usually not too far from its labeled position, the model should focus on the value near the labeled position during training. Therefore, the DFL loss function is selected in combination with the CIoU loss function to improve the training effect of the model and further improve the accuracy of target detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0024] Figure 1 A schematic diagram of a barcode detection method based on improved YOLOv8 provided in an embodiment of the present invention;

[0025] Figure 2 A schematic diagram of the structure of a barcode detection model provided by an embodiment of the present invention;

[0026] Figure 3A schematic diagram of the structure of an EfficientViT unit provided in an embodiment of the present invention;

[0027] Figure 4 A schematic diagram of the structure of a C2f-Ghost unit provided in an embodiment of the present invention;

[0028] Figure 5 A schematic diagram of a feature extraction process of a Ghost subunit provided in an embodiment of the present invention;

[0029] Figure 6 A schematic diagram of the characteristic structure of a detection head module provided by an embodiment of the present invention;

[0030] Figure 7 A schematic diagram of the structure of a barcode detection system based on improved YOLOv8 provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0031] The technical solution of the present invention is described below in conjunction with the accompanying drawings.

[0032] In the embodiments of the present invention, words such as "exemplarily" and "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "example" in the present invention should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of the word "example" is intended to present the concept in a specific way. In addition, in the embodiments of the present invention, the meaning expressed by "and / or" can be both, or it can be either of the two.

[0033] In the embodiments of the present invention, "image" and "picture" can sometimes be used interchangeably. It should be noted that when the difference between them is not emphasized, the meanings they intend to express are the same. "of", "corresponding, relevant" and "corresponding" can sometimes be used interchangeably. It should be noted that when the difference between them is not emphasized, the meanings they intend to express are the same.

[0034] In the embodiments of the present invention, sometimes the subscripts such as W 1 It may be mistakenly written as a non-subscript form such as W1. When the difference is not emphasized, the meanings they express are the same.

[0035] In order to make the technical problems, technical solutions and advantages to be solved by the present invention more clear, a detailed description will be given below with reference to the accompanying drawings and specific embodiments.

[0036] Reference Manual Attached Figure 1 , shows a schematic flow chart of a barcode detection method based on improved YOLOv8 provided in an embodiment of the present invention.

[0037] The embodiment of the present invention provides a barcode detection method based on improved YOLOv8, which can be implemented by a barcode detection device based on improved YOLOv8, and the barcode detection device based on improved YOLOv8 can be a terminal or a server. The processing flow of the barcode detection method based on improved YOLOv8 can include the following steps:

[0038] S1: Create a sample set with multiple barcode images.

[0039] Each barcode image has a barcode location label and a barcode category label.

[0040] Among them, the barcode position label refers to the specific location of the barcode in the image. It is usually represented in the form of a rectangular box, and the coordinates of the four vertices of the rectangular box are used to define the boundary of the barcode in the image. The main function of the position label is to help the model identify the exact location of the barcode so that the barcode can be accurately located during detection. The barcode category label refers to the category or type to which the barcode belongs. The category label is used to identify these different types of barcodes so that the model can not only detect the location of the barcode, but also determine which category it belongs to. By constructing a precisely annotated barcode image sample set, the model is provided with supervision information of location and category, thereby improving the detection accuracy and classification performance of the model. The advantage is that it can ensure that the model accurately identifies and classifies barcodes in various situations and enhance the generalization ability of the model.

[0041] In a possible implementation, S1 specifically includes:

[0042] S101: Get the original dataset with multiple barcode images

[0043] S102: Re-label the original data set to obtain a labeled data set

[0044] S103: Performing data enhancement operation on the labeled data set through the Mosaic algorithm to obtain an expanded data set, wherein the data enhancement operation includes image scaling, image cropping and image splicing to obtain a sample set.

[0045] It should be noted that by obtaining the original data set, re-labeling, and using the Mosaic algorithm for data enhancement, the diversity and quantity of the sample set are effectively expanded. The advantage of these operations is that they greatly improve the generalization ability of the model, enabling it to better cope with various complex detection scenarios, reduce the risk of overfitting, and improve the accuracy and robustness of the model in practical applications.

[0046] Refer to the instruction manual Figure 2 , showing a structural schematic diagram of a barcode detection model provided by an embodiment of the present invention.

[0047] Refer to the instruction manual Figure 3 , shows a schematic structural diagram of an EfficientViT unit provided in an embodiment of the present invention.

[0048] Refer to the instruction manual Figure 4 , showing a schematic structural diagram of a C2f-Ghost unit provided in an embodiment of the present invention.

[0049] S2: Build a barcode detection model,

[0050] The barcode detection model includes a backbone network module, a neck network module and a detection head module connected in sequence, wherein the backbone network module includes an EfficientViT unit having a multi-scale linear attention mechanism unit and a linear attention mechanism enhancement unit with a nonlinear function, the linear attention mechanism enhancement unit includes an FFN layer and a deep convolution unit connected to each other, the neck network module includes a C2f-Ghost unit for feature fusion, and the detection head module includes a detection unit having multiple anchor-free detection heads, wherein the C2f-Ghost unit is a C2f unit including a Ghost subunit.

[0051] Among them, the backbone network module is the basic part of the model, responsible for extracting features from the input image. These features will be further processed in subsequent network layers. The backbone network is usually a deep convolutional neural network (CNN) that is used to capture important information in the image, such as edges, textures, shapes, etc. The neck network module is located between the backbone network and the detection head, and is responsible for further fusing and processing the features extracted by the backbone network in preparation for input into the detection head module. This module is usually responsible for feature fusion, so that features from different levels can be better combined to enhance the detection ability of the model. The detection head module is the final part of the model, which receives feature maps processed by the neck network for object detection and classification. In barcode detection, this module will output the location and category of the barcode. The multi-scale linear attention mechanism unit is an advanced attention mechanism for processing image features at different scales. Multi-scale means that it can process large and small features in the image at the same time, and the attention mechanism allows the model to focus on the most important parts of the image. Linear attention refers to reducing the computational complexity of the traditional attention mechanism through a simpler calculation method. The EfficientViT unit is an efficient visual Transformer module that combines the advantages of convolutional neural networks and transformers. ViT (Vision Transformer) is a Transformer architecture for processing images with powerful feature extraction capabilities. EfficientViT improves processing speed and efficiency by optimizing the calculation method and attention mechanism. The Linear Attention Mechanism Enhancement Unit further strengthens the attention mechanism, allowing the model to focus on the key areas of the image more effectively. This unit contains interconnected FFN layers and deep convolution units to enhance feature extraction and processing. The C2f-Ghost unit is a feature fusion module that combines the characteristics of the C2f unit and the Ghost unit. C2f refers to a convolution structure applied in the feature map, while the Ghost unit is a lightweight convolution operation that reduces the amount of calculation and improves computational efficiency by generating "virtual" feature maps. Ghost subunit: Generates multiple "virtual" feature maps through less calculation. These feature maps help reduce the actual calculation overhead while retaining feature information. Anchor-free detection head: Traditional object detection models usually require pre-defined anchor boxes, while the anchor-free detection head eliminates this step, making the model more flexible and efficient in detecting objects.

[0052] It should be noted that the barcode detection model effectively improves the accuracy and efficiency of feature extraction by combining the multi-scale linear attention mechanism and the EfficientViT unit. At the same time, the C2f-Ghost unit in the neck network achieves efficient feature fusion through lightweight convolution operations, further improving the computational efficiency of the model. The anchor-free detection head makes the model more flexible and accurate in detecting barcodes, reducing the limitation of relying on predefined anchors. This design not only improves the detection speed, but also enhances the recognition accuracy of barcodes in various scenarios.

[0053] In one possible implementation, a multi-scale linear attention mechanism unit is used to extract features, and the extraction process is specifically as follows:

[0054] Sim(Q,K)=ReLU(Q)ReLU(K) T

[0055]

[0056] Among them, Q, K, V represent the query vector, key vector and value vector respectively, Q, K, V ∈ R N×d ,Attention(Q,K,V) i represents the i-th row of the attention matrix Attention(Q,K,V) representing the feature, Sim(Q,K) represents the similarity matrix, ReLU represents the ReLU activation function as a similarity function, R N×d represents the input tensor set, R represents the real number set, d represents the input tensor dimension, N represents the number of input tensors, Q i represents the query vector of the i-th row in the attention matrix, K j represents the jth key vector, V j Represents the j-th value vector.

[0057] It should be noted that by extracting features through the multi-scale linear attention mechanism, the model can effectively capture the key information in the image at different scales, and use the ReLU activation function to enhance the nonlinear ability of feature selection, reduce the computational complexity while improving the accuracy and efficiency of feature extraction, making the model more suitable for processing complex and diverse visual tasks.

[0058] Refer to the instruction manual Figure 5 , shows a schematic diagram of a feature extraction process of a Ghost subunit provided in an embodiment of the present invention.

[0059] Figure 5 Medium i (x) represents the i-th convolutional layer.

[0060] In a possible implementation, the Ghost subunit is used to extract features, and the extraction process is specifically as follows:

[0061] Receive the input feature map, where the number of channels of the feature map is C, the width is W, and the height is H

[0062] The convolution filters of the Ghost subunit are divided into S groups, and one group is selected to convolve the feature map to generate the Intrinsic feature map, where the number of Intrinsic feature maps is M, and the width and height are W respectively. 1 and H 1

[0063] Perform a linear transformation on the Intrinsic feature map to obtain the Ghost feature map, where the number of Ghost feature maps is (S-1)×M

[0064] The obtained Intrinsic feature map and Ghost feature map are spliced ​​in the channel dimension to obtain the extracted feature map.

[0065] Among them, the Intrinsic feature map is the basic feature map extracted directly from the input feature map through the convolution operation, representing the core information of the original feature map. They are the initial feature representation in the extraction process and are used to further generate more feature maps. By first generating fewer Intrinsic feature maps and then generating Ghost feature maps through linear transformation, this method significantly reduces the amount of calculation, improves the efficiency of feature extraction and the reasoning speed of the model, while retaining enough feature information to support high-precision detection tasks.

[0066] In one possible implementation, the EfficientViT unit includes an input unit, a multi-scale linear attention unit, a FFN-DWconv unit, and an output unit that are connected in sequence.

[0067] Among them, the input unit, multi-scale linear attention unit, FFN-DWconv unit and output unit correspond to Figure 3 Input, Multi-Scale Linear Att / FFN+DWConv and Output.

[0068] It should be noted that deep convolution is used after each FFN layer in the EfficientViT module, and convolution is used to enhance ReLU linear attention to improve the model's attention to spatial local information. Group convolution is used inside the module to reduce the total number of operations for information aggregation, which can further improve the model's efficiency in extracting barcode features.

[0069] The multi-scale linear attention unit includes a linear layer, a depthwise separable layer, a ReLU linear attention layer, and a concatenation layer. The depthwise separable layer includes interconnected depthwise separable convolutions and 1x1 group convolutions. The linear layer is connected to the concatenation layer through a ReLU linear attention layer. The linear layer is connected to the concatenation layer through a depthwise separable layer and a ReLU linear attention layer in turn.

[0070] exist Figure 3 In the figure, the linear layer, depthwise separable layer, ReLU linear attention layer and concatenation layer correspond to Linear, DWConv and 1x1GConv, ReLU Linear Attention and concat respectively, where the depthwise separable layer includes the interconnected depthwise separable convolution, i.e. DWConv, and 1x1 group convolution, i.e. 1x1GConv.

[0071] The C2f-Ghost unit includes a Conv+BN+SiLU layer, a Split layer, multiple Bottleneck layers, a concat layer, a Ghost-Conv layer, a BatchNorm layer, and a SiLU layer connected in sequence, wherein the Conv+BN+SiLU layer, the Split layer, and each Bottleneck layer are connected to the concat layer by skip connections.

[0072] Among them, Conv in the Conv+BN+SiLU layer refers to the convolution layer, which is used to extract input features. BN (BatchNorm) is a batch normalization layer used to accelerate the training process and stabilize the network. SiLU (Sigmoid Linear Unit) is an activation function, also known as Swish, and its calculation formula is It can enhance the nonlinear expression ability of the model. The Split layer splits the feature map after convolution and activation function processing, usually dividing the feature map into multiple parts for parallel processing or feature processing of different paths in subsequent layers. The Bottleneck layer is a common structure used to reduce the amount of calculation and the number of parameters. Its purpose is to reduce the number of parameters and computational overhead while maintaining the model capability. There are multiple bottleneck layers in the figure, which means that after the features are extracted and processed multiple times, they are deeply extracted through different paths. The Ghost-Conv layer is a lightweight convolution operation that reduces the amount of calculation by generating some "virtual" feature maps. Specifically, it calculates some basic feature maps and then generates additional feature maps through simple linear transformations, thereby reducing the number of feature maps actually calculated and improving the efficiency of the model. The BatchNorm layer is used to perform batch normalization again to further stabilize the feature map and accelerate convergence. The SiLU layer makes the output features more nonlinear. The jump connection method means that the feature map after the initial convolution operation is not discarded, but is retained and concatenated with the feature map processed by multiple Bottleneck layers in subsequent operations. This jump connection is often used to alleviate the gradient vanishing problem in deep neural networks, ensuring that information can be passed more directly from the previous layer to the next layer, thereby helping to maintain the original feature information.

[0073] Refer to the instruction manual Figure 6 , showing a schematic diagram of the characteristic structure of a detection head module provided by an embodiment of the present invention.

[0074] The detection unit includes a first branch and a second branch, wherein the first branch includes a convolutional layer unit, a convolutional layer unit, a two-dimensional convolutional layer unit and a DFL loss function connected in sequence, and the second branch includes a convolutional layer unit, a convolutional layer unit, a two-dimensional convolutional layer unit and a CIoU loss function connected in sequence.

[0075] It should be noted that the multi-scale linear attention mechanism, deep separable convolution and ghost convolution and other technologies significantly reduce the amount of model calculation and the number of parameters, while maintaining efficient feature extraction capabilities. By introducing jump connections and multi-path processing, the transmission and fusion of feature information are further enhanced, the gradient vanishing problem is reduced, and the training speed and stability of the model are improved. Ultimately, this design achieves high-precision and high-efficiency target detection with limited computing resources.

[0076] In a possible implementation, the backbone network module includes a first convolutional layer unit, a depth-separable convolutional layer unit, a first MBConv unit, a second MBConv unit, a third MBConv unit, a first EfficientViT unit, a fourth MBConv unit, a second EfficientViT unit, and a spatial pyramid pooling unit connected in sequence.

[0077] exist Figure 2 In the example, Backbone represents the backbone network model. Figure 2 From bottom to top, conv, DSConv, MBConv, MBConv, MBConv, EfficientViT Module, MBConv, EfficientViT Module and SPPF correspond to the first convolutional layer unit, depthwise separable convolutional layer unit, first MBConv unit, second MBConv unit, third MBConv unit, first EfficientViT unit, fourth MBConv unit, second EfficientViT unit and spatial pyramid pooling unit of the backbone network module respectively.

[0078] It should be noted that due to the complexity and diversity of the scanning environment in reality, the clutter, lighting and area occupied by the barcode in the input image are different, and the traditional single-scale window cannot effectively process multi-scale input data, which may lead to data missing problems. To further improve the efficiency of the model in extracting barcode feature information in complex operating environments, we retain the SPPF module at the end of the backbone. Since SPPF has a multi-scale spatial container, compared with the single-scale sliding window pooling, the model can process spatial feature information of different sizes, avoid cropping and distortion, etc., which causes uneven spatial feature information of the package in the picture, and improve the quality of model training and the recognition accuracy of the package.

[0079] The neck network module includes a first upper acquisition unit, a second upper acquisition unit, a first splicing unit, a second splicing unit, a third splicing unit, a fourth splicing unit, a first C2f-Ghost unit, a second C2f-Ghost unit, a third C2f-Ghost unit, a fourth C2f-Ghost unit, a first convolution unit and a second convolution unit, wherein the first upper acquisition unit is sequentially connected to the fourth C2f-Ghost unit through the first splicing unit, the first C2f-Ghost unit, the second upper acquisition unit, the second splicing unit, to form a first circuit, the output of the first circuit is the input of the second convolution unit, the second convolution unit is sequentially connected to the third C2f-Ghost unit through the third splicing unit, the third C2f-Ghost unit is sequentially connected to the second C2f-Ghost unit through the second convolution unit and the fourth splicing unit, the fourth splicing unit is connected to the second C2f-Ghost unit, and the first C2f-Ghost unit is connected to the third splicing unit.

[0080] Figure 2 In the figure, Neck represents the neck network module. Figure 2 The neck network module in the figure is divided into three columns from left to right, namely the first column, the second column and the third column from left to right. In the first column, Upsample, Concat, Csf-Ghost, Upsample and Concat from top to bottom correspond to the first upper acquisition unit, the first splicing unit, the first C2f-Ghost unit, the second upper acquisition unit and the second splicing unit, respectively. In the second column, Concat, Conv, Concat and Conv from top to bottom correspond to the fourth splicing unit, the second convolution unit, the third splicing unit and the second convolution unit, respectively. In the third column, the three C2f-Ghosts from top to bottom correspond to the second C2f-Ghost unit, the third C2f-Ghost unit and the fourth C2f-Ghost unit, respectively. Head corresponds to the detection head module, and each Detect-Head corresponds to a detection unit. X*Y*Z in the figure represents the size.

[0081] The spatial pyramid pooling unit is respectively connected to the first upsampling unit and the fourth splicing unit, the first EfficientViT unit is connected to the first splicing unit, the second MBConv unit is connected to the second splicing unit, and the second C2f-Ghost unit, the third C2f-Ghost unit and the fourth C2f-Ghost unit are all connected to the detection unit in the detection head module.

[0082] It should be noted that the combination of multi-level convolutional units and EfficientViT units achieves efficient feature extraction and processing. Depth-wise separable convolution and MBConv units reduce the amount of computation while maintaining the expressiveness of features. The spatial pyramid pooling unit (SPP) enhances the model's ability to capture multi-scale information, especially when dealing with complex scenes. The multiple splicing and upsampling operations of the neck network ensure that features from different levels are fully integrated, which helps to detect targets more accurately. Through these designs, the entire model has been significantly improved in terms of computational efficiency, detection accuracy, and scene adaptability. The EfficientViT module based on the linear self-attention mechanism is introduced into the backbone network of the original model to enhance the model's attention to barcode features. Linear mapping and grouped convolution are used to improve the efficiency of feature fusion in the C2f module. Experimental results show that the improved model improves the recall rate by 1.5 percentage points, mAP50:95 by 0.4 percentage points, FPS by 40 frames per second in barcode positioning and classification, the number of model parameters by 53.2 percentage points, and FLOPs by 52.1 percentage points.

[0083] S3: Establish a joint loss function including DFL loss function and CIoU loss function

[0084] Among them, the DFL (Distribution Focal Loss) loss function is a loss function used for regression tasks, especially for bounding box prediction in target detection. DFL uses a distributed modeling method to enable the model to more accurately predict the position of the target bounding box, focusing on the error of the key part of the regression task, thereby improving the accuracy of positioning. The CIoU (Complete Intersection over Union) loss function is a loss function used to measure the difference between the predicted bounding box and the true bounding box. CIoU not only considers the IoU (intersection over union) between the two, but also comprehensively considers factors such as the distance of the center point of the bounding box and the aspect ratio, thereby providing more comprehensive geometric constraints and enhancing the accuracy of bounding box prediction. The DFL and CIoU loss functions are used together to optimize the position regression and shape matching of the bounding box at the same time. The DFL loss function improves the accuracy of the model in bounding box position prediction, while the CIoU loss function ensures the geometric matching of the bounding box and the maximization of the overlapping area. This joint optimization enables the model to more accurately predict the boundaries and categories of the target in barcode detection, thereby improving the overall detection performance.

[0085] In a possible implementation, the joint loss function is specifically:

[0086]

[0087] DFL(S i ,S i+1 )=-(y i+1 -y)log(S i )-(yy i log(S i+1 )),

[0088]

[0089] Among them, L CIoU represents the CIoU loss function, IoU, α, v all represent intermediate variables, ρ represents the Euclidean distance, b represents the coordinates of the center point of the prediction box, and b gt represents the coordinates of the center point of the real box, c represents the diagonal distance of the minimum circumscribed rectangle, A represents the area occupied by the predicted box, B represents the area occupied by the real box, w represents the width of the predicted box, and w gt represents the width of the real box, h represents the height of the predicted box, and h gt represents the real box height, y represents the real label, and y i and i+1 They represent the first label and the second label closest to the true label y, respectively. i Indicates the probability that the prediction result is the first label, S i+1 represents the probability of the predicted result being the second label, DEL represents the DFL loss function, and log represents the logarithmic function, where y i ≤y≤y i+1 .

[0090] It should be noted that the joint loss function combines the CIoU loss function and the DFL loss function, which not only optimizes the overlap and geometric matching between the predicted box and the real box, reduces the box offset error through CIoU, but also accurately adjusts the distribution of classification probability through DFL, thereby enhancing the model's dual performance in bounding box positioning and classification accuracy. This design makes the model more robust and accurate when handling complex object detection tasks, improving the overall detection performance.

[0091] S4: Input the expanded data set into the barcode detection model to train the barcode detection model until the joint loss function value is less than the preset joint loss function value

[0092] It should be noted that by inputting the augmented data set into the barcode detection model for training until the joint loss function value reaches the preset standard, it can be ensured that the model fully learns the characteristics and variability of various barcode samples. The advantage of this is that the model can show higher accuracy and robustness in complex and diverse real-world scenarios, effectively reducing false detections and missed detections, while improving the adaptability and generalization ability of the model in different application environments.

[0093] It should be noted that those skilled in the art can set the size of the preset joint loss function value according to actual needs, and the present invention is not limited here.

[0094] In a possible implementation, S4 specifically includes:

[0095] S401: Extract features from the sample set through the backbone network module and output first feature maps of multiple scales, wherein the first feature maps include edge features of the barcode image, texture features of the barcode image, and shape features of the barcode image.

[0096] S402: Input each first feature map into the neck network module, fuse each first feature map, and obtain a fused feature map

[0097] S403: Input the fused feature map into the detection head module to obtain barcode information, where the barcode information includes the barcode position and barcode category.

[0098] S404: Calculate the joint loss function value of the barcode information

[0099] S405: Adjust the hyperparameters of the barcode detection model, increase the number of iterations by 1, and return to step S401 until the joint loss function value is less than the preset joint loss function value.

[0100] It should be noted that by gradually extracting and fusing multi-scale feature maps, the model can fully capture the detailed features of the barcode, such as edges, textures, and shapes. Finally, the detection head module can accurately predict the position and category of the barcode. By calculating the joint loss function value and adjusting the hyperparameters, the model can be continuously optimized to gradually improve the detection accuracy and stability. This iterative optimization method ensures the high performance of the model in complex scenarios, effectively reduces errors and improves the overall detection effect.

[0101] S5: Get the barcode image to be detected

[0102] S6: Input the barcode image to be detected into the trained barcode detection model, and output the predicted barcode position and predicted barcode category.

[0103] Specifically, after obtaining the barcode image to be detected, it is input into the trained barcode detection model, and the model automatically outputs the precise location and category of the barcode. The advantage of this process is that by using the features and patterns learned during the training process, the model can quickly and accurately identify and locate the barcode, which is suitable for scenarios such as automated scanning and inventory management, greatly improving work efficiency and accuracy, and reducing human intervention and errors.

[0104] In the actual application process, at the beginning of model training, the YOLOv8 model uses the Mosaic algorithm to scale, cut and splice the image and perform data enhancement on the data set. In the model training stage, the backbone network is responsible for feature extraction of the target in the input image, extracting low-level features such as the edge, texture and shape of the target. The neck network screens the features in the backbone network by fusing feature maps of different levels and scales. As the end of the model network structure, the detection head integrates the feature maps from the backbone network and the neck network, performs non-maximum suppression on the prediction results of the target and then inputs them, and is responsible for the specific visual tasks of the network such as classification, detection and segmentation. The barcode detection process forms a closed-loop system from data preparation, model construction, training to practical application. Through precise annotation and data enhancement, the model can learn a variety of barcode features. Combined with the multi-scale attention mechanism and efficient feature fusion technology, the model achieves higher detection accuracy and efficiency during the training process. Finally, the optimized model can quickly and accurately identify and locate barcodes in practical applications, greatly improving the automation level and reliability of barcode detection, and is suitable for a variety of complex scenarios.

[0105] The beneficial effects brought about by the technical solution provided by the embodiment of the present invention include at least:

[0106] In the present invention, the traditional YOLOv8 backbone network module, neck network module and detection head module are improved. Specifically, a multi-scale linear attention mechanism unit with a nonlinear function and an EfficientViT unit of a linear attention mechanism enhancement unit are introduced into the backbone network module. The linear attention mechanism enhancement unit includes an interconnected FFN layer and a deep convolution unit. The attention mechanism is introduced to achieve higher accuracy of barcode detection with a smaller amount of parameters and calculations. Convolution is used to enhance linear attention to improve the model's attention to spatial local information. Group convolution is used inside the module to reduce the total number of operations for information aggregation, which can further improve the efficiency of the model in extracting barcode features. A C2f-Ghost unit for feature fusion is introduced into the neck network module, and a Ghost module is introduced into the C2f module. The C2f module is improved from the convolution level to improve The efficiency of the convolution operation of the C2f module is improved, thereby improving the detection speed of the barcode detection model. A detection unit with multiple anchor-free detection heads is introduced in the detection head module. The design of multiple detection heads can learn and fuse the target's position and category information through different branches respectively. This method can effectively reduce the number of parameters, speed up the model training speed, reduce the risk of model overfitting, and enhance the generalization ability and robustness of the model. It improves the efficiency of feature extraction, feature fusion and target recognition in all aspects, improves the accuracy of feature capture, and thus increases the detection accuracy and efficiency of barcode targets. In addition, considering that the actual distribution of the target barcode is usually not too far from its labeled position, the model should focus on the value near the labeled position during training. Therefore, the DFL loss function is selected in combination with the CIoU loss function to improve the training effect of the model and further improve the accuracy of target detection.

[0107] Reference Manual Attached Figure 7 , showing a structural schematic diagram of a barcode detection system based on improved YOLOv8 provided by the present invention.

[0108] The present invention also provides a barcode detection system 20 based on improved YOLOv8, which is applied to the above-mentioned barcode detection method based on improved YOLOv8, comprising:

[0109] Processor 201.

[0110] The memory 202 stores computer-readable instructions. When the computer-readable instructions are executed by the processor 201, the barcode detection method based on the improved YOLOv8 in the method embodiment is implemented.

[0111] The barcode detection system 20 based on improved YOLOv8 provided by the present invention can execute the above-mentioned barcode detection method based on improved YOLOv8 and achieve the same or similar technical effects. To avoid repetition, the present invention will not go into details.

[0112] The beneficial effects brought about by the technical solution provided by the embodiment of the present invention include at least:

[0113] In the present invention, the traditional YOLOv8 backbone network module, neck network module and detection head module are improved. Specifically, a multi-scale linear attention mechanism unit with a nonlinear function and an EfficientViT unit of a linear attention mechanism enhancement unit are introduced into the backbone network module. The linear attention mechanism enhancement unit includes an interconnected FFN layer and a deep convolution unit. The attention mechanism is introduced to achieve higher accuracy of barcode detection with a smaller amount of parameters and calculations. Convolution is used to enhance linear attention to improve the model's attention to spatial local information. Group convolution is used inside the module to reduce the total number of operations for information aggregation, which can further improve the efficiency of the model in extracting barcode features. A C2f-Ghost unit for feature fusion is introduced into the neck network module, and a Ghost module is introduced into the C2f module. The C2f module is improved from the convolution level to improve The efficiency of the convolution operation of the C2f module is improved, thereby improving the detection speed of the barcode detection model. A detection unit with multiple anchor-free detection heads is introduced in the detection head module. The design of multiple detection heads can learn and fuse the target's position and category information through different branches respectively. This method can effectively reduce the number of parameters, speed up the model training speed, reduce the risk of model overfitting, and enhance the generalization ability and robustness of the model. It improves the efficiency of feature extraction, feature fusion and target recognition in all aspects, improves the accuracy of feature capture, and thus increases the detection accuracy and efficiency of barcode targets. In addition, considering that the actual distribution of the target barcode is usually not too far from its labeled position, the model should focus on the value near the labeled position during training. Therefore, the DFL loss function is selected in combination with the CIoU loss function to improve the training effect of the model and further improve the accuracy of target detection.

[0114] It should be understood that the processor in the embodiment of the present invention may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0115] It should also be understood that the memory in the embodiments of the present invention may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of random access memory (RAM) are available, such as static RAM (SRAM), dynamic random access memory (DRAM), synchronous DRAM (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link DRAM (SLDRAM), and direct rambus RAM (DR RAM).

[0116] The above embodiments can be implemented in whole or in part by software, hardware (such as circuits), firmware or any other combination. When implemented by software, the above embodiments can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions or computer programs. When the computer instructions or computer programs are loaded or executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center by wired (such as infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that contains one or more available media sets. The available medium can be a magnetic medium (for example, a floppy disk, a hard disk, a tape), an optical medium (for example, a DVD), or a semiconductor medium. The semiconductor medium can be a solid-state hard disk.

[0117] It should be understood that the term "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. A and B can be singular or plural. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship, but it may also indicate an "and / or" relationship. Please refer to the context for specific understanding.

[0118] In the present invention, "at least one" means one or more, and "more than one" means two or more. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can be represented by: a, b, c, ab, ac, bc, or abc, where a, b, c can be single or multiple.

[0119] It should be understood that in various embodiments of the present invention, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.

[0120] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0121] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described equipment, devices and units can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0122] In the several embodiments provided by the present invention, it should be understood that the disclosed devices, apparatuses and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0123] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0124] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0125] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0126] An embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon. When the program is executed by a processor, the barcode detection method based on the improved YOLOv8 as described in the method embodiment is implemented.

[0127] A computer-readable storage medium provided by the present invention can implement the steps and effects of the barcode detection method based on the improved YOLOv8 of the above method embodiment. To avoid repetition, the present invention will not go into details.

[0128] The beneficial effects brought about by the technical solution provided by the embodiment of the present invention include at least:

[0129] In the present invention, the traditional YOLOv8 backbone network module, neck network module and detection head module are improved. Specifically, an EfficientViT unit having a multi-scale linear attention mechanism unit and a linear attention mechanism enhancement unit with a nonlinear function is introduced into the backbone network module. The linear attention mechanism enhancement unit includes an interconnected FFN layer and a deep convolution unit. The attention mechanism is introduced to achieve higher accuracy of barcode detection with a smaller amount of parameters and calculations. The linear attention is enhanced by convolution to improve the model's attention to spatial local information. Group convolution is used inside the module to reduce the total number of operations for information aggregation, which can further improve the efficiency of the model in extracting barcode features. A C2f-Ghost unit for feature fusion is introduced into the neck network module, and a Ghost module is introduced into the C2f module. The C2f module is improved from the convolution level to improve the detection accuracy. The efficiency of the convolution operation of the high C2f module is improved, thereby improving the detection speed of the barcode detection model. A detection unit with multiple anchor-free detection heads is introduced in the detection head module. The design of multiple detection heads can learn and fuse the target's position and category information through different branches respectively. This method can effectively reduce the number of parameters, speed up the model training speed, reduce the risk of model overfitting, and enhance the generalization ability and robustness of the model. It improves the efficiency of feature extraction, feature fusion and target recognition in all aspects, improves the accuracy of feature capture, and thus increases the detection accuracy and efficiency of barcode targets. In addition, considering that the actual distribution of the target barcode is usually not too far from its labeled position, the model should focus on the value near the labeled position during training. Therefore, the DFL loss function is selected in combination with the CIoU loss function to improve the training effect of the model and further improve the accuracy of target detection.

[0130] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.

[0131] There are a few points to note:

[0132] (1) The drawings of the embodiments of the present invention only relate to the structures related to the embodiments of the present invention, and other structures may refer to the general design.

[0133] (2) For the sake of clarity, in the drawings used to describe the embodiments of the present invention, the thickness of the layers or regions is exaggerated or reduced, that is, these drawings are not drawn according to the actual scale. It is understood that when an element such as a layer, film, region or substrate is referred to as being "on" or "under" another element, the element may be "directly" "on" or "under" the other element or there may be intermediate elements.

[0134] (3) In the absence of conflict, the embodiments of the present invention and the features therein may be combined with each other to obtain new embodiments.

[0135] The above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. The protection scope of the present invention shall be based on the protection scope of the claims.

Claims

1. A barcode detection method based on improved YOLOv8, characterized in that: include: S1: establishing a sample set with multiple barcode images, wherein each barcode image has a barcode position label and a barcode category label; S2: construct a barcode detection model, wherein the barcode detection model includes a backbone network module, a neck network module and a detection head module connected in sequence, wherein the backbone network module includes an EfficientViT unit having a multi-scale linear attention mechanism unit and a linear attention mechanism enhancement unit with a nonlinear function, the linear attention mechanism enhancement unit includes an FFN layer and a deep convolution unit connected to each other, the neck network module includes a C2f-Ghost unit for feature fusion, the detection head module includes a detection unit having multiple anchor-free detection heads, wherein the C2f-Ghost unit is a C2f unit including a Ghost subunit; S3: Establish a joint loss function including the DFL loss function and the CIoU loss function; S4: inputting the expanded data set into the barcode detection model to train the barcode detection model until the joint loss function value is less than a preset joint loss function value; S5: Obtain the barcode image to be detected; S6: Input the barcode image to be detected into the trained barcode detection model, and output the predicted barcode position and predicted barcode category.

2. The barcode detection method based on improved YOLOv8 according to claim 1, characterized in that: The S1 specifically includes: S101: obtaining an original data set having multiple barcode images; S102: re-labeling the original data set to obtain a labeled data set; S103: performing a data enhancement operation on the annotated data set by using a Mosaic algorithm to obtain the expanded data set, wherein the data enhancement operation includes image scaling, image cropping and image splicing to obtain the sample set.

3. The barcode detection method based on improved YOLOv8 according to claim 2, characterized in that: The multi-scale linear attention mechanism unit is used to extract features, and the extraction process is specifically as follows: Sim(Q,K)=ReLU(Q)ReLU(K) T Among them, Q, K, V represent the query vector, key vector and value vector respectively, Q, K, V ∈ R N×d ,Attention(Q,K,V) i represents the i-th row of the attention matrix Attention(Q,K,V) representing the feature, Sim(Q,K) represents the similarity matrix, ReLU represents the ReLU activation function as a similarity function, R N×d represents the input tensor set, R represents the real number set, d represents the input tensor dimension, N represents the number of input tensors, Q i represents the query vector of the i-th row in the attention matrix, K j represents the jth key vector, V j Represents the j-th value vector.

4. The barcode detection method based on improved YOLOv8 according to claim 2, characterized in that: The Ghost subunit is used to extract features, and the extraction process is specifically as follows: Receive an input feature map, wherein the feature map has C channels, W width, and H height; Divide the convolution filters of the Ghost subunit into S groups, take one group to convolve the feature map, and generate an Intrinsic feature map, wherein the number of the Intrinsic feature maps is M, and the width and height are W1 and H1 respectively; Performing a linear transformation on the Intrinsic feature map to obtain a Ghost feature map, wherein the number of the Ghost feature maps is (S-1)×M; The obtained Intrinsic feature map and Ghost feature map are spliced ​​in the channel dimension to obtain the extracted feature map.

5. The barcode detection method based on improved YOLOv8 according to claim 1, characterized in that: The EfficientViT unit includes an input unit, a multi-scale linear attention unit, a FFN-DWconv unit and an output unit connected in sequence; The multi-scale linear attention unit includes a linear layer, a depth-separable layer, a ReLU linear attention layer and a splicing layer, wherein the depth-separable layer includes a depth-separable convolution and a 1x1 group convolution connected to each other, the linear layer is connected to the splicing layer through the ReLU linear attention layer, and the linear layer is connected to the splicing layer through the depth-separable layer and the ReLU linear attention layer in turn; The C2f-Ghost unit includes a Conv+BN+SiLU layer, a Split layer, a plurality of Bottleneck layers, a concat layer, a Ghost-Conv layer, a BatchNorm layer, and a SiLU layer connected in sequence, wherein the Conv+BN+SiLU layer, the Split layer, and each Bottleneck layer are connected to the concat layer by means of a jump connection; The detection unit includes a first branch and a second branch, wherein the first branch includes a convolutional layer unit, a convolutional layer unit, a two-dimensional convolutional layer unit and a DFL loss function connected in sequence, and the second branch includes a convolutional layer unit, a convolutional layer unit, a two-dimensional convolutional layer unit and a CIoU loss function connected in sequence.

6. The barcode detection method based on improved YOLOv8 according to claim 1, characterized in that: The backbone network module includes a first convolutional layer unit, a depth-separable convolutional layer unit, a first MBConv unit, a second MBConv unit, a third MBConv unit, a first EfficientViT unit, a fourth MBConv unit, a second EfficientViT unit and a spatial pyramid pooling unit, which are connected in sequence; The neck network module includes a first upper acquisition unit, a second upper acquisition unit, a first splicing unit, a second splicing unit, a third splicing unit, a fourth splicing unit, a first C2f-Ghost unit, a second C2f-Ghost unit, a third C2f-Ghost unit, a fourth C2f-Ghost unit, a first convolution unit and a second convolution unit, wherein the first upper acquisition unit is sequentially connected to the fourth C2f-Ghost unit through the first splicing unit, the first C2f-Ghost unit, the second upper acquisition unit and the second splicing unit to form a first circuit, the output of the first circuit is the input of the second convolution unit, the second convolution unit is sequentially connected to the third C2f-Ghost unit through the third splicing unit, the third C2f-Ghost unit is sequentially connected to the second C2f-Ghost unit through the second convolution unit and the fourth splicing unit, the fourth splicing unit is connected to the second C2f-Ghost unit, and the first C2f-Ghost unit is connected to the third splicing unit; The spatial pyramid pooling unit is respectively connected to the first upsampling unit and the fourth splicing unit, the first EfficientViT unit is connected to the first splicing unit, the second MBConv unit is connected to the second splicing unit, and the second C2f-Ghost unit, the third C2f-Ghost unit and the fourth C2f-Ghost unit are all connected to the detection unit in the detection head module.

7. The barcode detection method based on improved YOLOv8 according to claim 1, characterized in that: The joint loss function is specifically: DFL(S i ,S i+1 )=-(y i+1 -y)log(S i )-(y-y i log(S i+1 )), Among them, L CIoU represents the CIoU loss function, IoU, α, v all represent intermediate variables, ρ represents the Euclidean distance, b represents the coordinates of the center point of the prediction box, and b gt represents the coordinates of the center point of the real box, c represents the diagonal distance of the minimum circumscribed rectangle, A represents the area occupied by the predicted box, B represents the area occupied by the real box, w represents the width of the predicted box, and w gt represents the width of the real box, h represents the height of the predicted box, and h gt represents the real box height, y represents the real label, and y i and i+1 denote the first label and the second label closest to the true label y, respectively, i represents the probability that the prediction result is the first label, S i+1 represents the probability that the prediction result is the second label, DEL represents the DFL loss function, and log represents the logarithmic function, where y i ≤y≤y i+1 .

8. The barcode detection method based on improved YOLOv8 according to claim 1, characterized in that: The S4 specifically includes: S401: extracting features from the sample set through the backbone network module, and outputting first feature maps of multiple scales, wherein the first feature maps include edge features of the barcode image, texture features of the barcode image, and shape features of the barcode image; S402: Inputting each first feature map into the neck network module, fusing each first feature map to obtain a fused feature map; S403: Inputting the fused feature map into the detection head module to obtain barcode information, wherein the barcode information includes a barcode position and a barcode category; S404: Calculate the joint loss function value of the barcode information; S405: Adjust the hyperparameters of the barcode detection model, increase the number of iterations by 1, and return to step S401 until the joint loss function value is less than a preset joint loss function value.

9. A barcode detection system based on improved YOLOv8, characterized in that: include: processor; A memory having computer-readable instructions stored thereon, wherein when the computer-readable instructions are executed by the processor, the barcode detection method based on the improved YOLOv8 as described in any one of claims 1 to 8 is implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the barcode detection method based on improved YOLOv8 as described in any one of claims 1 to 8 is implemented.

Citation Information

Patent Citations

  • Logistics bar code detection method based on vision and computer program

    CN109583535A

  • Parcel three-dimensional size identification method and system based on deep learning

    CN118608856A

Cited By

  • Image processing method and system and medium

    CN119991516A

  • Bar code and two-dimensional code detection method and related equipment

    CN121303166A