Bar code rapid identification method based on code scanning gun and code scanning gun
Through the use of a double-sided barcode scanner and a lightweight image recognition model, the accuracy and speed issues of traditional barcode recognition methods under different conditions are solved, instant recognition on embedded systems is achieved, and the efficiency and user experience of commercial scenarios are improved.
Patent Information
- Application Number
- CN202510761624.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-09
- Publication Date
- 2025-09-16
- Estimated Expiration
- 2045-06-09
AI Technical Summary
Traditional barcode recognition methods have difficulty guaranteeing accuracy and speed under different sizes, angles, and lighting conditions, especially on mobile devices where computing resources are limited and the scanner needs to adjust the angle multiple times, resulting in low efficiency.
The barcode scanner with double-sided scanning function is combined with a lightweight image recognition model, and pre-processes and recognizes through adaptive grayscale, binarization and a lightweight CNN model, optimizing the convolution kernel and network depth to achieve instant recognition and fast processing on the embedded system.
It improves the accuracy and robustness of barcode recognition, reduces computational complexity, enables instant recognition, improves checkout efficiency and user experience, and is suitable for commercial scenarios.
Smart Images

Figure CN120654718A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image recognition, and in particular to a barcode rapid recognition method based on a barcode scanner and a barcode scanner. Background Art
[0002] Traditional barcode recognition methods typically rely on specific hardware devices and complex software algorithms. When faced with barcodes of different sizes, angles, and lighting conditions, recognition accuracy and speed are often difficult to guarantee. This is especially true on mobile devices or embedded systems. Due to limited computing resources and storage space, traditional recognition methods cannot meet the needs of fast recognition.
[0003] Although some existing barcode recognition solutions use certain image processing and deep learning technologies, they often have problems such as complex models, large number of parameters, and high computational costs, making it difficult to achieve real-time and rapid recognition in actual business scenarios.
[0004] In terms of the design of barcode scanners, most barcode scanners can only scan in one direction. For some specially placed barcodes, users are required to adjust the scanning angle multiple times, which seriously affects the checkout efficiency and user experience. After scanning the barcode of a product, it is necessary to wait for the barcode to be decoded and obtain data information before continuing to scan the next code, resulting in low scanning efficiency. When there are many people in the queue, it takes a long time to wait, which cannot meet people's daily needs. Summary of the Invention
[0005] To solve the above problems, the present invention provides a barcode rapid recognition method based on a barcode scanner and a barcode scanner. The barcode scanner for double-sided scanning obtains image data of barcodes under different sizes, angles and lighting conditions, performs grayscale, binarization and normalization preprocessing on the image, and then inputs it into a lightweight image recognition model for processing. The lightweight image recognition model optimizes the size and number of convolution kernels, adopts depth-separable convolution and group convolution, streamlines the network depth, optimizes the fully connected layer and other measures to achieve instant recognition on embedded systems or mobile devices, and strengthens the supplementary unclear parts of the barcode to achieve fast and accurate recognition.
[0006] To achieve the above object, the technical solution adopted by the present invention is:
[0007] In a first aspect of the present invention, a barcode rapid recognition method based on a barcode scanner is provided, comprising the following steps:
[0008] S1. Using a barcode scanner with a double-sided barcode scanning function to obtain barcode image data, the barcode includes barcode images of different sizes, angles, and lighting conditions;
[0009] S2. Preprocessing the acquired barcode image, including converting the color image into a grayscale image using an adaptive grayscale algorithm, enhancing the image contrast through dynamic threshold binarization, and performing geometric correction to normalize the image to a standard size;
[0010] S3, inputting the pre-processed image data into an image recognition model for processing, wherein the processing steps include immediately processing and strengthening the unclear image data portion in the supplementary barcode image, and then performing recognition processing;
[0011] S4. Implement real-time image quality assessment. When the image quality assessment score is lower than the threshold, trigger the image enhancement mechanism, use the bilinear interpolation algorithm to supplement the missing pixels and apply edge sharpening processing;
[0012] S5. Input the enhanced image into the image recognition model for secondary recognition, and output the final decoding result.
[0013] Preferably, in S1, the double-sided scanning function of the barcode scanner adopts two barcode scanning cameras facing back to back to scan barcodes in opposite directions at the same time.
[0014] Preferably, in S2, the image data of barcodes of different sizes, angles and lighting conditions are converted into image data with uniform scale and brightness through the preprocessing step.
[0015] Preferably, in S3, the image recognition model is a lightweight CNN model, which optimizes the network structure and parameters, controls the parameter amount within 500KB, and supports inference calculation on an ARMCortex-M7 microcontroller with a delay of less than 200ms.
[0016] Preferably, in S4, when the image quality assessment score is lower than a threshold, an image enhancement mechanism is triggered, specifically including dividing the input image into 8×8 to 16×16 overlapping grid units, performing contrast-limited histogram equalization on each unit; implementing multi-scale edge detection by improving the Canny operator; and reducing image noise in two stages while retaining edge sharpness, including frequency domain filtering and spatial domain filtering.
[0017] Preferably, the image quality assessment score is used to evaluate the recognition of the barcode image data, and the specific calculation steps are as follows:
[0018] goal=ω1·goal0+ω2·ICS+ω3·α
[0019] Wherein, goal represents the image quality assessment score, ω1 represents the classification score weight, goal0 represents the feature vector output by the image recognition model, ω2 represents the structural similarity weight, ICS represents the similarity between the recognized image and the feature map in the image recognition model, ω3 represents the decoding verification weight, and α represents the feedback factor;
[0020] The calculation formula of ICS, the similarity between the recognition image and the feature map in the image recognition model, is as follows:
[0021]
[0022] Where Y(x,y) represents the feedback writing function, which is used to write the output feedback of the image recognition model into the image recognition model. ρ represents the feedback fusion weight, which is used to control the update amplitude. R(x,y) represents the reward function constructed by the dual constraints of structure and brightness. x and y represent the two images to be compared, respectively. μx and μy represent the means of the two images, respectively.
[0023] Preferably, in S4, when the image quality assessment score is higher than a threshold, the decoding result is directly output.
[0024] In a second aspect of the present invention, a barcode scanner is further provided, wherein the barcode scanner adopts the above-mentioned barcode scanner-based rapid recognition method for barcode recognition, including a double-sided barcode scanning module for acquiring image data, a processing module for image preprocessing, and a lightweight CNN model module for barcode recognition;
[0025] The double-sided barcode scanning module includes two barcode scanning cameras facing away from each other, capable of scanning barcodes in different directions at the same time;
[0026] The processing module and the lightweight CNN model module are integrated into one and installed in an embedded system or mobile device, so that the barcode scanner can quickly complete the barcode recognition processing locally without relying on external devices or network connections.
[0027] The beneficial effects of the present invention are:
[0028] 1. The present invention effectively reduces the complexity of model processing and improves the accuracy and robustness of barcode recognition by acquiring barcode images of different sizes, angles and lighting conditions and performing preprocessing.
[0029] 2. The designed lightweight image recognition model (CNN) significantly reduces the number of model parameters and computational complexity by optimizing convolution operations, streamlining the network structure, adopting low-rank decomposition, and selecting lightweight activation functions. This enables it to run quickly on embedded systems or mobile devices, achieving instant barcode recognition and meeting the demand for rapid recognition in commercial scenarios.
[0030] 3. The double-sided scanning function of the barcode scanner uses two scanning cameras facing back to back, which can scan barcodes in different directions at the same time, enabling consumers and cashiers to scan codes at the same time, greatly improving the efficiency and convenience of checkout and improving the user experience.
[0031] 4. The lightweight image recognition model can enhance and supplement the unclear parts of the barcode during the real-time processing, further improving the barcode's recognizability, reducing the recognition error rate caused by factors such as blurry and damaged barcodes, and enhancing the stability and reliability of the entire barcode recognition system.
[0032] 5. The barcode rapid recognition method and barcode scanner of the present invention have high practicality and broad application prospects. They can be widely used in scenarios such as supermarkets, shopping malls, warehouse management, etc. that require a large number of barcodes to be recognized, providing more efficient and convenient recognition solutions for commercial activities, and helping to improve the operational efficiency and competitiveness of enterprises. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 This is a flow chart of a barcode rapid recognition method based on a barcode scanner of the present invention.
[0034] Figure 2 This is a block diagram of the internal system of the barcode scanner gun of the present invention.
[0035] Figure 3 It is a schematic diagram of the external structure of the barcode scanning gun of the present invention.
[0036] Explanation of the accompanying figures: 1. Scanning gun body; 2. Double-sided scanning module; 21. First scanning camera; 22. Second scanning camera. DETAILED DESCRIPTION
[0037] In the first aspect of the present invention, see Figure 1 As shown, the present invention relates to a barcode rapid recognition method based on a barcode scanner, comprising the following steps:
[0038] S1. Using a barcode scanner with a double-sided barcode scanning function to obtain barcode image data, the barcode includes barcode images of different sizes, angles, and lighting conditions;
[0039] This embodiment is implemented on an ARM Cortex-M7 microcontroller (main frequency 216MHz), with the following specific configuration:
[0040] Memory allocation: SRAM 256KB (model execution) + Flash 1MB (algorithm storage)
[0041] Real-time operating system: FreeRTOS task scheduling (for image acquisition, processing, and transmission tasks of different priorities)
[0042] It uses a barcode scanner with double-sided scanning function. The two scanning cameras face back to back. Each camera has high resolution and fast response capabilities, and can capture barcode images in different directions to ensure comprehensive coverage of barcodes in various situations.
[0043] For example, in a supermarket checkout environment, the item to be identified is placed under the barcode scanner, and the double-sided scanning cameras are started at the same time to capture barcode images from two opposite directions. Regardless of whether the barcode is on the front or the side, the salesperson can use the camera set on the front and the consumer can use the camera on the back to scan the product at the same time, ensuring that they can be clearly captured by at least one camera, thereby obtaining barcode image data of different sizes, angles and lighting conditions.
[0044] For example, while the cashier is using the front camera of the barcode scanner to scan product A, the consumer can use the back camera to scan and identify product B, thereby improving work efficiency.
[0045] S2. Preprocessing the acquired barcode image, including converting the color image into a grayscale image using an adaptive grayscale algorithm, enhancing the image contrast through dynamic threshold binarization, and performing geometric correction to normalize the image to a standard size;
[0046] The acquired barcode image data is grayscaled to convert the color image into a grayscale image, retaining the basic structural information of the image, reducing the dimension of the image data, and reducing the data volume and computational complexity.
[0047] This embodiment uses the YUV420 conversion formula to convert a color image into a grayscale image:
[0048] Y=0.299R+0.587G+0.114B
[0049] Where Y represents the brightness channel, U and V represent the chrominance channels, 420 means that each Y component corresponds to two UV components, that is, the UV sampling rate is 1 / 2, R represents the brightness of the red channel, G represents the brightness of the green channel, and B represents the brightness of the blue channel.
[0050] Then, binarization is performed to divide the pixels in the grayscale image into foreground and background colors, making the bars and spaces of the barcode more clearly distinguishable.
[0051] Then normalization is performed to scale the image data to a uniform scale and brightness distribution, so that the barcode images under different conditions have the same standard, preparing for subsequent model processing.
[0052] The preprocessing step converts the image data of barcodes in different sizes, angles and lighting conditions into image data with uniform scale and brightness.
[0053] S3, inputting the pre-processed image data into an image recognition model for processing, wherein the processing steps include immediately processing and strengthening the unclear image data portion in the supplementary barcode image, and then performing recognition processing;
[0054] The image recognition model is a lightweight CNN model. By optimizing the network structure and parameters, the parameter amount of the lightweight CNN model is controlled within 500KB, and it supports inference calculations with a delay of less than 200ms on an ARM Cortex-M7 microcontroller.
[0055] The following are the parameters that are often optimized for lightweight CNN models:
[0056] Convolution operation related
[0057] Convolution kernel size: Smaller convolution kernels, such as 3x3 and 5x5, can reduce the number of parameters and computation while maintaining a certain receptive field. For example, EfficientNetV2 tends to choose a convolution kernel size of 3, but adds multiple convolutions to increase the receptive field.
[0058] Number of convolution kernels: Reducing the number of convolution kernels can directly reduce the number of parameters and computational complexity, but this may affect the model's feature extraction capabilities. A balance needs to be struck between the two.
[0059] Introducing depthwise separable convolution: Decomposing the standard convolution into channel-by-channel convolution and point-by-point convolution, such as the depthwise separable convolution of the MobileNet series, can significantly reduce the number of parameters and computation.
[0060] Use group convolution: Divide the input channels into multiple groups and perform convolution operations on them separately, such as the group convolution in ResNeXt, which can reduce the number of parameters and improve model performance.
[0061] Simplified network structure
[0062] Reduce network depth: Reduce the number of stacked convolutional layers, pooling layers, etc., and reduce the number of parameters and computational complexity while meeting the complexity of the problem. For example, MobileNetV3 streamlines the final stage and deletes redundant convolutional layers.
[0063] Optimizing fully connected layers: Fully connected layers usually have a large number of parameters. This can be reduced by reducing the number of neurons in the fully connected layers or replacing some fully connected layers with global average pooling. For example, SqueezeNet uses global average pooling instead of traditional fully connected layers.
[0064] Use a two-stage bottleneck module: For example, SqueezeNext uses two 1x1 Conv as a two-stage bottleneck module, which can significantly reduce the weight parameters.
[0065] Parameter optimization strategy
[0066] Low-rank decomposition: Decomposing a large matrix into multiple small matrices, such as using Canonical Polyadic Decomposition in SqueezeNext, can reduce the number of parameters.
[0067] Width multiplier and resolution multiplier: Models such as MobileNet introduce width multipliers and resolution multipliers to adjust the model size and computational complexity according to actual needs.
[0068] Activation function selection
[0069] Use lightweight activation functions: such as the h-swish activation function introduced in MobileNetV3, which is simpler to calculate than the traditional swish function and more suitable for embedded mobile terminals.
[0070] Training strategy optimization
[0071] Learning rate adjustment: Using appropriate learning rate adjustment strategies, such as cosine annealing and ReduceLROnPlateau, can accelerate model convergence and improve training efficiency.
[0072] Regularization techniques: Using regularization methods such as Dropout and L2 regularization can prevent model overfitting and improve the generalization ability and robustness of the model.
[0073] A rich training dataset is constructed by collecting a large amount of barcode image data in different scenarios, including barcodes in various environments such as supermarkets, shopping malls, warehouses, and barcode images of different sizes, angles, and lighting conditions.
[0074] Training process
[0075] The lightweight CNN model is trained using the collected training dataset, and data enhancement techniques such as rotation, translation, and scaling are used to expand the training data and improve the generalization ability of the model.
[0076] During the training process, appropriate learning rate adjustment strategies and regularization techniques, such as cosine annealing, Dropout, and L2 regularization, are used to accelerate the convergence of the model, prevent overfitting, and improve the performance and stability of the model.
[0077] The preprocessed image data is fed into a lightweight CNN model. This model consists of multiple convolutional layers, pooling layers, and fully connected layers. By optimizing the size and number of convolution kernels and employing techniques such as depthwise separable convolution and group convolution, the model's parameters and computational complexity are reduced, enabling it to run quickly on embedded systems or mobile devices.
[0078] During the processing, the model first extracts features from the input image. Through the combination of convolutional layers and pooling layers, it gradually extracts features such as edges, textures, and shapes in the image, and reduces and compresses the features to reduce computational complexity.
[0079] In order to strengthen and supplement the unclear parts of the barcode, the model uses specific image enhancement algorithms, such as adaptive filtering, edge enhancement and other technologies, to repair and enhance the unclear parts during the feature extraction process, thereby improving the recognizability of the barcode.
[0080] The image enhancement algorithm is performed in the following order:
[0081] (a) Local contrast enhancement: The input image is divided into overlapping grid cells of 8×8 to 16×16, and contrast-limited histogram equalization (CLAHE) is performed on each cell, where:
[0082] - The contrast limit threshold is set to 2.0-3.0 times the average gray value;
[0083] -Histogram distribution uses exponential weighting (γ = 0.8-1.2);
[0084] -Bicubic interpolation is used to achieve smooth transitions between adjacent grids;
[0085] (b) Edge structure enhancement: Multi-scale edge detection is implemented by improving the Canny operator, including:
[0086] 1. Use a 5×5 Gaussian filter (σ=1.2-1.8) for noise suppression;
[0087] 2. Calculate the gradient magnitude and direction based on the Sobel operator, and use non-maximum suppression to refine the edge;
[0088] 3. Dynamically set high and low thresholds: high threshold = 85% quantile of image gradient histogram, low threshold = 40%-60% of the high threshold;
[0089] 4. Perform morphological closing operation (3×3 ellipse kernel) on the detected edge contours to connect the broken edges; (c) Adaptive noise suppression: Reduce image noise in two stages:
[0090] I. Frequency domain filtering: Perform a three-layer Haar wavelet decomposition on the image, apply the Bayesian shrinkage algorithm to the high-frequency sub-band coefficients, and adaptively calculate the shrinkage threshold based on the sub-band energy:
[0091] Threshold T = σ_n^2 / σ_s, where σ_n is the noise variance (estimated by the finest scale subband) and σ_s is the signal variance;
[0092] II. Spatial filtering: Perform non-local mean filtering on flat areas (gradient < 5 gray levels), with a search window of 11 × 11 pixels, a similarity block of 5 × 5 pixels, and an attenuation parameter h = 0.8σ_n
[0093] Finally, the extracted features are classified and recognized through the fully connected layer, and the barcode recognition results are output.
[0094] Recognition result output
[0095] Output barcode identification information in real time, including barcode code, corresponding item information, price, etc., to provide cashiers with accurate cash register data and improve cash register efficiency and accuracy.
[0096] S4. Implement real-time image quality assessment. When the image quality assessment score is lower than the threshold, trigger the image enhancement mechanism, use the bilinear interpolation algorithm to supplement the missing pixels and apply edge sharpening processing;
[0097] When the image quality assessment score is lower than the threshold, the image enhancement mechanism is triggered. Specifically, the input image is divided into overlapping grid cells of 8×8 to 16×16, and contrast-limited histogram equalization is performed on each cell; multi-scale edge detection is implemented by improving the Canny operator; and image noise is reduced in two stages, including frequency domain filtering and spatial domain filtering, while preserving edge sharpness.
[0098] The image quality assessment score is used to evaluate the recognition of barcode image data.
[0099] The specific calculation steps are as follows:
[0100] goal=ω1·goal0+ω2·ICS+ω3·α
[0101] Wherein, goal represents the image quality assessment score, ω1 represents the classification score weight, goal0 represents the feature vector output by the image recognition model, ω2 represents the structural similarity weight, ICS represents the similarity between the recognized image and the feature map in the image recognition model, ω3 represents the decoding verification weight, and α represents the feedback factor;
[0102] Among 1000 test samples, the values of ω1, ω2, and ω3 are 0.6 / 0.3 / 0.1, respectively. This combination has the lowest false trigger rate (<3%).
[0103] The calculation formula of ICS, the similarity between the recognition image and the feature map in the image recognition model, is as follows:
[0104]
[0105] Where Y(x,y) represents the feedback writing function, which is used to write the output feedback of the image recognition model into the image recognition model. ρ represents the feedback fusion weight, which is used to control the update amplitude. R(x,y) represents the reward function constructed by the dual constraints of structure and brightness. x and y represent the two images to be compared, respectively. μx and μy represent the means of the two images, respectively.
[0106] This step is responsible for applying the barcode output from the image recognition model in the third step to the real-world system. While performing barcode recognition, it also collects actual execution feedback, writes this feedback back to the image state of the image recognition model, and fine-tunes the convolutional structure of the lightweight CNN model. This process does not involve any modeling, but is limited to state updates and parameter writing, and is the final step in establishing the system's closed-loop control capabilities.
[0107] When the image quality assessment score is higher than the threshold, the decoding result is directly output.
[0108] The present invention also provides exception handling logic:
[0109] If the enhancement fails to be triggered three times in a row, the following emergency procedures will be initiated:
[0110] Switch light source mode (white light → infrared);
[0111] Adjust the focus to the preset safe distance (15cm);
[0112] Send a retry request command to the recognition system.
[0113] During the real-time processing of the model, in addition to using image enhancement algorithms to strengthen and supplement unclear barcode parts, it also combines prior knowledge and statistical information of the barcode to more accurately repair and reconstruct the blurred areas of the barcode, further improving the barcode's recognizability.
[0114] In low-light conditions, with illumination less than 100 lux, the dynamic threshold mechanism increases the effective trigger rate by 37%;
[0115] For partially damaged barcodes, if the occlusion area is less than 30%, the image quality assessment score error can be effectively controlled within ±5%.
[0116] In this step, a composite evaluation mechanism consisting of model output probability, image quality analysis, and traditional decoding feedback was constructed. The robustness of the solution was enhanced through the linkage design of dynamic threshold adjustment and multi-stage exception handling.
[0117] S5. Input the enhanced image into the image recognition model for secondary recognition, and output the final decoding result.
[0118] The specific implementation includes the following steps:
[0119] (a) Parallel decoding processing: The enhanced image is simultaneously input to the following three decoding channels:
[0120] Ⅰ. Deep learning decoding channel: Calls a lightweight CNN model for secondary feature extraction and outputs candidate barcode types and coordinate positioning information;
[0121] II. Traditional algorithm decoding channel: uses the improved ZBar decoding library. Configuration parameters include:
[0122] - Scanning line density: 8 lines / mm;
[0123] - Fault tolerance level: ECC200 standard (error correction capacity ≤ 15% data corruption);
[0124] III. Hybrid decoding channel: Fusion of CNN positioning results and traditional algorithms to perform directional scanning within the ROI area;
[0125] (b) Result arbitration mechanism: weighted voting on the output results of the three channels:
[0126] -Deep learning channel weight: 0.5 (activated when classification confidence ≥ 0.9);
[0127] - Traditional algorithm channel weight: 0.3 (subject to checksum verification);
[0128] - Hybrid channel weight: 0.2 (effective when the ROI area is ≥ 70% of the complete barcode);
[0129] - A total score of ≥0.75 is considered to be effective recognition;
[0130] For the enhanced barcode image, the model performs recognition processing again and compares and integrates the recognition results with the original image to optimize the final recognition results, reduce the recognition error rate caused by unclear barcodes, and improve the accuracy and reliability of the entire recognition system.
[0131] Finally, the final recognition result is compressed: Delta Encoding is used to reduce the amount of transmitted data and output the recognition result.
[0132] The present invention achieves an average decoding time of ≤150ms on an ARM Cortex-M7 by integrating heterogeneous computing of traditional algorithms (high real-time performance) and deep learning (high robustness). The weight distribution is based on experimental data: traditional algorithms have an advantage in standard barcode recognition (fast speed), while deep learning improves the accuracy by 42% in fuzzy / damaged barcode scenarios.
[0133] In warehouse management scenarios, barcode scanners are used to identify barcodes on goods, quickly obtaining information about goods entering and leaving the warehouse, inventory location, etc. Due to the complex warehouse environment, barcodes may be affected by factors such as stains, wrinkles, and insufficient lighting. The advantages of barcode scanners with dual-sided scanning capabilities and lightweight CNN models are more obvious.
[0134] The dual-sided scanning camera can capture barcode images from different angles, improving recognition success rates. The lightweight CNN model is highly adaptable to barcode images of varying sizes, angles, and lighting conditions, enabling fast and accurate barcode recognition for efficient cargo management.
[0135] In the second aspect of the present invention, a barcode scanner is also provided. Figure 2 and Figure 3 As shown, it includes a barcode scanner body 1, wherein the barcode scanner adopts a barcode rapid recognition method based on a barcode scanner for barcode recognition, including a double-sided barcode scanning module 2 for acquiring image data, a processing module for image preprocessing, and a lightweight CNN model module for barcode recognition;
[0136] The double-sided code scanning module 2 includes two code scanning cameras facing back to back (i.e., the first code scanning camera 21 and the second code scanning camera), which can simultaneously scan barcodes in different directions;
[0137] The processing module and the lightweight CNN model module are integrated into one and installed in an embedded system or mobile device, so that the barcode scanner can quickly complete the barcode recognition processing locally without relying on external devices or network connections.
[0138] In the several embodiments provided in this application, it should be understood that the disclosed systems and methods may also be implemented in other ways. The system embodiments described above are merely illustrative. For example, the flowcharts and block diagrams in the accompanying drawings illustrate possible architectures, functions, and operations of systems, methods, and computer program products according to various embodiments of the present invention.
[0139] The above embodiments are merely descriptions of preferred embodiments of the present invention and are not intended to limit the scope of the present invention. Without departing from the design spirit of the present invention, various modifications and improvements made to the technical solutions of the present invention by ordinary engineering technicians in this field should fall within the scope of protection determined by the claims of the present invention.
Claims
1. A barcode rapid recognition method based on a barcode scanner, characterized in that: The following steps are involved: S1. Using a barcode scanner with a double-sided barcode scanning function to obtain barcode image data, the barcode includes barcode images of different sizes, angles, and lighting conditions; S2. Preprocessing the acquired barcode image, including converting the color image into a grayscale image using an adaptive grayscale algorithm, enhancing the image contrast through dynamic threshold binarization, and performing geometric correction to normalize the image to a standard size; S3, inputting the pre-processed image data into an image recognition model for processing, wherein the processing steps include immediately processing and strengthening the unclear image data portion in the supplementary barcode image, and then performing recognition processing; S4. Real-time evaluation of the image quality output by the image recognition model. When the image quality evaluation score is lower than the threshold, the image enhancement mechanism is triggered, using a bilinear interpolation algorithm to supplement missing pixels and apply edge sharpening. S5. Input the enhanced image into the image recognition model for secondary recognition, and output the final decoding result.
2. The barcode rapid recognition method based on a barcode scanner according to claim 1, characterized in that: In S1, the double-sided scanning function of the barcode scanner uses two barcode scanning cameras facing back to back to scan barcodes in opposite directions at the same time.
3. The barcode rapid recognition method based on a barcode scanner according to claim 1, characterized in that: In S2, the image data of barcodes with different sizes, angles and lighting conditions are converted into image data with uniform scale and brightness through the preprocessing step.
4. The barcode rapid recognition method based on a barcode scanner according to claim 1, characterized in that: In S3, the image recognition model is a lightweight CNN model. The lightweight CNN model optimizes the network structure and parameters, controls the parameter amount within 500KB, and supports inference calculation with a delay of less than 200ms on the ARM Cortex-M7 microcontroller.
5. The barcode rapid recognition method based on a barcode scanner according to claim 1, characterized in that: In S4, when the image quality assessment score is lower than a threshold, an image enhancement mechanism is triggered, specifically including dividing the input image into 8×8 to 16×16 overlapping grid cells, performing contrast-limited histogram equalization on each cell; implementing multi-scale edge detection by improving the Canny operator; and reducing image noise in two stages while retaining edge sharpness, including frequency domain filtering and spatial domain filtering.
6. The barcode rapid recognition method based on a barcode scanner according to claim 5, characterized in that: The image quality evaluation score is used to evaluate the recognition of barcode image data. The specific calculation steps are as follows: goal=ω1·goal0+ω2·ICS+ω3·α Wherein, goal represents the image quality assessment score, ω1 represents the classification score weight, goal0 represents the feature vector output by the image recognition model, ω2 represents the structural similarity weight, ICS represents the similarity between the recognized image and the feature map in the image recognition model, ω3 represents the decoding verification weight, and α represents the feedback factor; The calculation formula of ICS, the similarity between the recognition image and the feature map in the image recognition model, is as follows: Wherein, Υ(x,y) represents the feedback writing function, which is used to write the output feedback of the image recognition model into the image recognition model, ρ represents the feedback fusion weight, which is used to control the update amplitude, R(x,y) represents the reward function constructed by the dual constraints of structure and brightness, x and y represent the two images to be compared, and μx and μy represent the means of the two images, respectively.
7. The barcode rapid recognition method based on a barcode scanner according to claim 1, characterized in that: In S4, when the image quality evaluation score is higher than the threshold, the decoding result is directly output.
8. A barcode scanning gun, characterized in that: The barcode scanner adopts the barcode rapid recognition method based on a barcode scanner according to any one of claims 1 to 7 for barcode recognition, including a double-sided barcode scanning module for acquiring image data, a processing module for image preprocessing, and a lightweight CNN model module for barcode recognition; The double-sided barcode scanning module includes two barcode scanning cameras facing away from each other, capable of scanning barcodes in different directions at the same time; The processing module and the lightweight CNN model module are integrated into one and installed in an embedded system or mobile device, so that the barcode scanner can quickly complete the barcode recognition processing locally without relying on external devices or network connections.
Citation Information
Patent Citations
Code scanning improvement method and device of handheld code scanning terminal
CN115577727A
Image processing method and electronic equipment
CN117077703A
Image acquisition device and scanning device with same
CN216391131U
Rapid identification code scanning gun
CN219349521U
PCB automatic code scanning machine
CN220795869U