A barcode quick identification method based on a code scanning gun and the code scanning gun
By using a double-sided barcode scanner and a lightweight image recognition model, the accuracy and speed issues of traditional barcode recognition methods under different conditions have been resolved, achieving fast and accurate barcode recognition and improving checkout efficiency and user experience.
Patent Information
- Application Number
- CN202510761624.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-09
- Publication Date
- 2026-01-23
- Estimated Expiration
- 2045-06-09
AI Technical Summary
Traditional barcode recognition methods struggle to guarantee accuracy and speed under varying sizes, angles, and lighting conditions. This is especially problematic on mobile devices where computing resources are limited, and barcode scanners can only scan in one direction, impacting checkout efficiency and user experience.
Image data is acquired using a double-sided barcode scanner, and preprocessed by grayscale conversion, binarization, and normalization. A lightweight image recognition model is used for real-time recognition, combined with an image enhancement mechanism to fill in unclear parts, and the convolution kernel and network depth are optimized to achieve fast and accurate recognition.
It improves the accuracy and robustness of barcode recognition, meets the rapid recognition needs of commercial scenarios, enhances checkout efficiency and user experience, and is suitable for supermarkets, shopping malls and other scenarios.
Smart Images

Figure CN120654718B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of image recognition, and in particular to a bar code rapid identification method based on a code scanning gun and the code scanning gun. BACKGROUND
[0002] Traditional bar code identification methods usually rely on specific hardware devices and complex software algorithms. When facing bar codes of different sizes, angles and lighting conditions, the identification accuracy and speed are often difficult to guarantee, especially on mobile devices or embedded systems, which are limited by computing resources and storage space. Traditional identification methods are difficult to meet the needs of rapid identification.
[0003] Although existing partial bar code identification schemes use certain image processing and deep learning techniques, they often have problems such as complex models, large parameter quantities, and high computational costs, making it difficult to achieve real-time and rapid identification in actual commercial scenarios.
[0004] In the design of code scanning guns, most code scanning guns can only scan codes in one direction. For some bar codes placed in a special way, the user needs to adjust the scanning angle multiple times, which seriously affects the checkout efficiency and user experience. After scanning the bar code of a product, the user needs to wait for the data information obtained by decoding the bar code before continuing to scan the next code, resulting in low scanning efficiency. When there are many people in line, the user needs to wait for a long time, which cannot meet the daily needs of people. SUMMARY
[0005] To solve the above problems, the present application provides a bar code rapid identification method based on a code scanning gun and the code scanning gun. The double-sided code scanning gun obtains image data of bar codes under different sizes, angles and lighting conditions. The image is preprocessed by grayscale, binarization and normalization, and then input into a lightweight image recognition model for processing. The lightweight image recognition model optimizes the size and number of convolution kernels, uses depth separable convolution and group convolution, simplifies the network depth, and optimizes the fully connected layer to realize real-time identification on embedded systems or mobile devices, and to strengthen the unclear part of the bar code, achieving rapid and accurate identification.
[0006] To achieve the above purpose, the technical solution adopted by the present application is:
[0007] In the first aspect of the present application, a bar code rapid identification method based on a code scanning gun is provided, comprising the following steps:
[0008] S1, obtaining image data of a bar code using a code scanning gun with double-sided code scanning function, the bar code including bar code images under different sizes, angles and lighting conditions;
[0009] S2, preprocessing the acquired barcode image, including converting a color image into a grayscale image using an adaptive grayscale algorithm, enhancing the contrast of the image through dynamic threshold binarization processing, and performing geometric correction to normalize the image to a standard size;
[0010] S3, inputting the preprocessed image data into an image recognition model for processing, the processing steps including instant processing and reinforcing the unclear image data part in the supplementary barcode image, followed by recognition processing;
[0011] S4, implementing real-time image quality evaluation, when the image quality evaluation score is lower than the threshold, triggering the image enhancement mechanism, using the bilinear interpolation algorithm to supplement the missing pixels and applying edge sharpening processing;
[0012] S5, inputting the enhanced image into the image recognition model for secondary recognition, and outputting the final decoding result.
[0013] As a preferred, in the S1, the double-sided scanning function of the scanning gun uses two scanning cameras facing away from each other, which can scan the barcodes located in opposite directions at the same time.
[0014] As a preferred, in the S2, the preprocessing step converts the image data of barcodes under different sizes, angles and lighting conditions into image data with uniform scale and brightness.
[0015] As a preferred, in the S3, the image recognition model is a lightweight CNN model, which controls the parameter quantity within 500KB by optimizing the network structure and parameters, and supports completing inference calculation on ARM Cortex-M7 microcontroller with a delay of less than 200ms.
[0016] As a preferred, in the S4, when the image quality evaluation score is lower than the threshold, the image enhancement mechanism is triggered, which specifically includes dividing the input image into 8x8 to 16x16 overlapping grid units, performing contrast limited histogram equalization on each unit; implementing multi-scale edge detection by improving the Canny operator; reducing image noise in two stages while preserving edge sharpness, including frequency domain filtering and spatial domain filtering.
[0017] More preferably, the image quality evaluation score is used to evaluate the recognition degree 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 evaluation 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 of the recognition image and the feature map in the image recognition model, ω3 represents the decoding verification weight, and a represents the feedback factor;
[0020] Wherein, the calculation formula of the similarity ICS of the recognition image and the feature map in the image recognition model is as follows:
[0021]
[0022] Wherein, Y(x, y) represents a feedback writing function, which is used for writing the image recognition model output feedback into the image recognition model, ρ represents a feedback fusion weight, which is used for controlling the update amplitude, R(x, y) represents a reward function constructed by structural and brightness double constraints, x and y respectively represent two images to be compared, and μx and μy respectively represent the mean values of the two images.
[0023] As preferred, in S4, when the image quality evaluation score is higher than the threshold value, the decoding result is directly output.
[0024] In the second aspect of the present application, a code scanning gun is also provided, wherein the code scanning gun adopts the above-mentioned barcode fast recognition method based on the code scanning gun to recognize the barcode, and comprises a double-sided code 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 code scanning module comprises two code scanning cameras facing away from each other, which can simultaneously scan barcodes in different directions.
[0026] The processing module and the lightweight CNN model module are integrated and installed in an embedded system or a mobile device, so that the code scanning gun can quickly complete the recognition processing of the barcode locally without relying on external devices or network connection.
[0027] The present application has the following advantages:
[0028] 1. The present application can effectively reduce the complexity of model processing and improve the accuracy and robustness of barcode recognition by acquiring barcode images under different sizes, angles and illumination conditions and performing preprocessing.
[0029] 2. The designed lightweight image recognition model (CNN) can greatly reduce the parameter quantity and calculation quantity of the model by optimizing convolution operation, simplifying network structure, adopting low-rank decomposition and selecting lightweight activation function, so that it can quickly run on an embedded system or a mobile device, realize instant recognition of the barcode, and meet the demand for fast recognition in commercial scenarios.
[0030] 3. The dual-scan function of the code scanner, which adopts two code scanning cameras facing opposite directions, can simultaneously scan barcodes in different directions, realizing the operation of scanning codes by consumers and cashiers at the same time, greatly improving the efficiency and convenience of cashing and improving the user experience.
[0031] 4. The lightweight image recognition model can strengthen and supplement the unclear part of the barcode in the instant processing process, further improving the recognizability of the barcode, reducing the recognition error rate caused by factors such as barcode blur and contamination, and enhancing the stability and reliability of the entire barcode recognition system.
[0032] 5. The barcode rapid identification method and code scanner of the present application have high practicability and wide application prospect, can be widely applied to supermarkets, shopping malls, warehouse management and other scenes requiring a large number of barcode identification, provide more efficient and convenient identification solutions for business activities, and help to improve the operation efficiency and competitiveness of enterprises. BRIEF DESCRIPTION OF DRAWINGS
[0033] Figure 1 is a flow chart of a barcode rapid identification method based on a code scanner.
[0034] Figure 2 is a system block diagram of the code scanner.
[0035] Figure 3 is a schematic diagram of the external structure of the code scanner.
[0036] BRIEF DESCRIPTION OF DRAWINGS: 1. Code scanner body; 2. Dual-scan module; 21. First code scanning camera; 22. Second code scanning camera. DETAILED DESCRIPTION
[0037] In the first aspect of the present application, please refer to Figure 1 The present application relates to a barcode rapid identification method based on a code scanner, which comprises the following steps:
[0038] S1, acquiring image data of a barcode by using a code scanner with a dual-scan function, wherein the barcode includes barcode images under different sizes, angles and illumination conditions;
[0039] This embodiment is implemented on an ARM Cortex-M7 microcontroller (clock frequency 216MHz), and the specific configuration is as follows:
[0040] Memory allocation: SRAM 256KB (model running) + Flash 1MB (algorithm storage)
[0041] Real-time operating system: FreeRTOS task scheduling (for image acquisition, processing and transmission, which belong to different priority tasks)
[0042] The scanning gun with double-sided code scanning function, two code scanning cameras are opposite to each other, each camera has high resolution and fast response capability, can capture barcode images in different directions, and ensure comprehensive coverage of barcodes in various situations.
[0043] For example, in a supermarket checkout environment, place the items to be identified under the scanning gun, the double-sided code scanning camera starts simultaneously, captures barcode images from two opposite directions respectively, whether the barcode is front or side, the salesperson can use the camera on the front, and the consumer can use the camera on the back, and the goods can be scanned at the same time, ensuring that they can be clearly captured by at least one camera, so as to obtain barcode image data under different sizes, angles and lighting conditions.
[0044] For example, when the cashier uses the front camera of the scanning gun to scan the product A, the consumer can use the back camera to scan the product B, which improves the work efficiency.
[0045] S2, preprocessing the obtained barcode image, including converting color image to grayscale image by using adaptive grayscale algorithm, enhancing image contrast by dynamic threshold binarization processing, and normalizing image to standard size by performing geometric correction;
[0046] The obtained barcode image data is processed by grayscale processing, the color image is converted to grayscale image, the basic structure information of the image is retained, the dimension of the image data is reduced, and the data amount and the calculation complexity are reduced.
[0047] This embodiment converts the color image to grayscale image by using YUV420 conversion formula:
[0048] Y = 0.299R + 0.587G + 0.114B
[0049] Where Y represents the luminance channel, U and V represent the chrominance channel, 420 represents that each Y component corresponds to two UV components, i.e. the UV sampling rate is 1 / 2, R represents the luminance of the red channel, G represents the luminance of the green channel, and B represents the luminance of the blue channel.
[0050] Then, the binarization processing is performed, the pixel points in the grayscale image are divided into foreground and background two colors, so that the bars and spaces of the barcode are more clear and distinguishable.
[0051] Then, the normalization processing is performed, the image data is scaled to a unified scale and brightness distribution, so that the barcode images under different conditions have the same standard, and the subsequent model processing is prepared.
[0052] The image data of the bar code under different sizes, angles and light conditions is converted into image data with uniform scale and brightness by the preprocessing step.
[0053] S3, input the preprocessed image data into an image recognition model for processing, the processing step including instant processing and reinforcing unclear image data parts in the supplementary bar code image, and then performing recognition processing;
[0054] The image recognition model is a lightweight CNN model, which optimizes the network structure and parameters, controls the parameter quantity within 500KB, and supports completing inference calculation on an ARM Cortex-M7 microcontroller with a delay of less than 200ms.
[0055] The following are the commonly optimized parameters of the lightweight CNN model:
[0056] Convolution operation related
[0057] Convolution kernel size: smaller convolution kernels such as 3x3, 5x5, etc. can reduce parameter quantity and calculation amount while maintaining a certain receptive field. For example, EfficientNetV2 tends to select a convolution kernel with a kernel size of 3, but increases multiple convolutions to enhance the receptive field.
[0058] Convolution kernel quantity: reducing the number of convolution kernels can directly reduce the parameter quantity and calculation amount, but may affect the feature extraction capability of the model, and needs to be balanced between the two.
[0059] Introducing depth separable convolution: decomposing standard convolution into channel-wise convolution and point-wise convolution, such as the depth separable convolution in the MobileNet series, which can greatly reduce the parameter quantity and calculation amount.
[0060] Adopting group convolution: dividing the input channels into multiple groups and performing convolution operations respectively, such as the group convolution in ResNeXt, which can reduce the parameter quantity and improve the model performance.
[0061] Network structure simplification
[0062] Reducing network depth: reducing the number of stacked convolution layers, pooling layers, etc. under the premise of meeting the problem complexity, reducing the parameter quantity and calculation amount, such as MobileNetV3 simplifying the last stage and deleting the redundant convolution layers.
[0063] Optimizing the fully connected layer: the fully connected layer usually has a large parameter quantity, which can be reduced by reducing the number of neurons in the fully connected layer, using global average pooling instead of part of the fully connected layer, etc. to reduce the parameter quantity, such as SqueezeNet using global average pooling instead of the traditional fully connected layer.
[0064] Two-stage bottleneck module: SqueezeNext uses two 1x1 Convs as the two-stage bottleneck module, which can significantly reduce the weight parameters.
[0065] Parameter optimization strategy
[0066] Low-rank decomposition: decompose a large matrix into multiple small matrices, such as using Canonical Polyadic Decomposition in SqueezeNext, which can reduce the number of parameters.
[0067] Width multiplier and resolution multiplier: MobileNet and other models introduce width multiplier and resolution multiplier, which can adjust the size and computational complexity of the model according to actual needs.
[0068] Activation function selection
[0069] Lightweight activation function: MobileNetV3 introduces h-swish activation function, which is more simple and suitable for embedded mobile devices compared to traditional swish function.
[0070] Training strategy optimization
[0071] Learning rate adjustment: use appropriate learning rate adjustment strategies such as cosine annealing, ReduceLROnPlateau, etc., to speed up model convergence and improve training efficiency.
[0072] Regularization techniques: use Dropout, L2 regularization and other regularization methods to prevent model overfitting, improve model generalization ability and robustness.
[0073] Collect a large number of barcode image data in different scenarios, including barcodes in supermarkets, shopping malls, warehouses and other environments, as well as barcodes of different sizes, angles and lighting conditions, to build a rich training dataset.
[0074] Training process
[0075] Use the collected training dataset to train the lightweight CNN model, use data augmentation techniques such as rotation, translation, scaling, etc. to expand the training data and improve the model's generalization ability.
[0076] In the training process, use appropriate learning rate adjustment strategies and regularization techniques such as cosine annealing, Dropout, L2 regularization, etc. to speed up model convergence, prevent overfitting and improve model performance and stability.
[0077] The pre-processed image data is input into a lightweight CNN model. The model includes multiple convolutional layers, pooling layers, and fully connected layers. By optimizing the size and number of convolutional kernels, using techniques such as depthwise separable convolution and group convolution, the model reduces the number of parameters and computational complexity, allowing it to run quickly on embedded systems or mobile devices.
[0078] During processing, the model first extracts features from the input image. Through the combination of convolutional and pooling layers, it gradually extracts features such as edges, textures, and shapes from the image, and reduces the dimensionality and compression of the features to reduce computational complexity.
[0079] To reinforce and supplement unclear parts of the barcode, the model uses specific image enhancement algorithms such as adaptive filtering and edge enhancement to repair and enhance unclear parts during feature extraction, improving the recognizability of the barcode.
[0080] The image enhancement algorithm is executed in the following order:
[0081] (a) Local contrast enhancement: The input image is divided into 8x8 to 16x16 overlapping grid cells, 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] - The histogram distribution uses an exponential weighting method (γ = 0.8-1.2);
[0084] - The adjacent grids use bicubic interpolation for smooth transition;
[0085] (b) Edge structure enhancement: Multi-scale edge detection is implemented by improving the Canny operator, which includes:
[0086] 1. Use a 5x5 Gaussian filter (σ = 1.2-1.8) for noise suppression;
[0087] 2. Calculate the gradient amplitude and direction based on the Sobel operator, and use non-maximum suppression to refine the edges;
[0088] 3. Dynamically set the high and low threshold values: high threshold = 85% quantile of the image gradient histogram, low threshold = 40%-60% of the high threshold;
[0089] 4. Perform morphological closing operation (3x3 elliptical kernel) on the detected edge contours to connect broken edges;
[0090] I. Frequency domain filtering: The image is decomposed into three layers by Haar wavelet, and the Bayesian shrinkage algorithm is applied to the high-frequency sub-band coefficients. The shrinkage threshold is adaptively calculated according to the sub-band energy:
[0091] The threshold T = σ_n^2 / σ_s, where σ_n is the noise variance (estimated by the finest scale sub-band), and σ_s is the signal variance;
[0092] II. Spatial domain filtering: Non-local mean filtering is performed in flat areas (gradient < 5 gray levels), with a search window of 11x11 pixels, a similar block of 5x5 pixels, and a decay parameter h = 0.8σ_n
[0093] Finally, the extracted features are classified and recognized by a fully connected layer, and the recognition result of the barcode is output.
[0094] Recognition result output
[0095] The recognition information of the barcode is output in real time, including the encoding of the barcode, the corresponding item information, the price, etc., providing accurate cash register data for cashiers and improving cash register efficiency and accuracy.
[0096] S4, image quality real-time evaluation is implemented, and when the image quality evaluation score is lower than the threshold, the image enhancement mechanism is triggered, and the bilinear interpolation algorithm is used to supplement the missing pixels and apply edge sharpening processing;
[0097] When the image quality evaluation score is lower than the threshold, the image enhancement mechanism is triggered, which specifically includes dividing the input image into 8x8 to 16x16 overlapping grid units, performing contrast-limited histogram equalization on each unit; multi-scale edge detection is implemented by improving the Canny operator; reduce image noise in two stages under the premise of preserving edge sharpness, including frequency domain filtering and spatial domain filtering.
[0098] The image quality evaluation score is used to evaluate the recognition degree of the barcode image data,
[0099] The specific calculation steps are as follows:
[0100] goal = ω1·goal0 + ω2·ICS + ω3·α
[0101] Where goal represents the image quality evaluation 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] In 1000 test samples, the values of ω1, ω2 and ω3 are 0.6 / 0.3 / 0.1 respectively, and the false trigger rate of this combination is the lowest (<3%).
[0103] The calculation formula of the similarity ICS of the identified image and the feature map in the image recognition model is as follows:
[0104]
[0105] Wherein Y(x,y) represents a feedback writing function for feeding back the image recognition model output to the image recognition model, p represents a feedback fusion weight for controlling the update amplitude, R(x,y) represents a reward function constructed by structure and brightness double constraints, x and y respectively represent two images to be compared, and mu x and mu y respectively represent the mean values of the two images.
[0106] The responsibility of this step is to apply the corresponding bar code identified by the image recognition model output in the third step to the real system, to collect the actual execution feedback while performing bar code recognition, to write the feedback back to the image state of the image recognition model, and to fine-tune the convolution structure in the lightweight CNN model. This process does not involve any modeling behavior, but is limited to state update and parameter writing, which is the last link of building the closed-loop control ability of the system.
[0107] When the image quality evaluation score is higher than the threshold value, the decoding result is directly output.
[0108] The application also sets up an abnormality processing logic:
[0109] When the enhancement fails for 3 times in succession, the following emergency process is started:
[0110] Switch the light source mode (white light→infrared light);
[0111] Adjust the focal length to the preset safe distance (15cm);
[0112] Send a retry request instruction to the recognition system.
[0113] In the model instant processing process, in addition to using image enhancement algorithm to strengthen and supplement the unclear part of the bar code, the prior knowledge and statistical information of the bar code are also combined to more accurately repair and reconstruct the fuzzy area of the bar code, and the recognizability of the bar code is further improved.
[0114] Under low light conditions, when the illuminance is less than 100 lux, the dynamic threshold mechanism can improve the effective triggering rate by 37%.
[0115] For a locally damaged bar code, when the shielding area is less than 30%, the image quality evaluation score evaluation error can be effectively controlled within ±5%.
[0116] In this step, a composite evaluation mechanism of model output probability + image quality analysis + traditional decoding feedback is constructed. Through the linkage design of dynamic threshold adjustment and multi-stage abnormality processing, the robustness of the scheme is strengthened.
[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: input the enhanced image into the following three decoding channels simultaneously:
[0120] I. Deep learning decoding channel: call a lightweight CNN model for secondary feature extraction, output candidate barcode type and coordinate positioning information;
[0121] II. Traditional algorithm decoding channel: use an improved ZBar decoding library, the configuration parameters include:
[0122] - Code scanning line density: 8 lines / mm;
[0123] - Fault tolerance level: ECC200 standard (error correction capacity ≤15% data damage);
[0124] III. Mixed decoding channel: fuse CNN positioning results and traditional algorithms to perform directional code scanning in 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 the classification confidence is ≥0.9);
[0127] - Traditional algorithm channel weight: 0.3 (must meet checksum verification);
[0128] - Mixed channel weight: 0.2 (effective when the ROI area area is ≥70% of the complete barcode);
[0129] - Total score ≥0.75 is determined as valid recognition;
[0130] For the barcode image after enhancement processing, the model performs recognition processing again, and compares and fuses the recognition results with the original image, optimizes the final recognition result, reduces the recognition error rate caused by unclear barcodes, and improves the accuracy and reliability of the entire recognition system.
[0131] Finally, the final recognition result is compressed: use differential encoding (Delta Encoding) to reduce the amount of transmission data, and output the recognition result.
[0132] The application fuses the heterogeneous computing of the traditional algorithm (high real-time) and deep learning (high robustness), realizes the weight distribution with the average decoding time ≤150ms on the ARM Cortex-M7, and is based on experimental data: the traditional algorithm is dominant (fast) in standard barcode recognition, and the deep learning has an accuracy improvement of 42% in the fuzzy / broken barcode scene.
[0133] In the warehouse management scenario, the code scanning gun is used to identify the barcodes on the goods, and the warehouse in / out information, inventory location, etc. of the goods are quickly obtained. Due to the complex warehouse environment, the barcodes may be affected by factors such as pollution, wrinkles, insufficient light, etc., and the advantages of the double-sided code scanning function of the code scanning gun and the lightweight CNN model are more obvious.
[0134] The double-sided code scanning camera can capture barcode images from different angles to improve the success rate of identification. The lightweight CNN model has strong adaptability to barcode images of different sizes, angles and light conditions, and can quickly and accurately identify the barcode information to realize efficient management of goods.
[0135] In the second aspect of the application, a code scanning gun is also provided, as shown in Figure 2 and Figure 3 , comprising a code scanning gun body 1, wherein the code scanning gun adopts a barcode fast identification method based on the code scanning gun for barcode identification, comprising a double-sided code scanning module 2 for acquiring image data, a processing module for image preprocessing, and a lightweight CNN model module for barcode identification.
[0136] The double-sided code scanning module 2 comprises two mutually opposite code scanning cameras (i.e. a first code scanning camera 21 and a second code scanning camera), which can simultaneously scan barcodes in different directions.
[0137] The processing module and the lightweight CNN model module are integrated and installed in an embedded system or a mobile device, so that the code scanning gun can quickly complete the identification and processing of the barcode locally without relying on external devices or network connection.
[0138] In the several embodiments provided in the present application, it should be understood that the disclosed system and method can also be implemented in other ways. The system embodiments described above are only schematic, for example, the flowcharts and block diagrams in the drawings show the possible implementation architectures, functions and operations of the system, method and computer program product according to the embodiments of the present application.
[0139] The above embodiments are only used to describe the preferred embodiments of the present application, and are not used to limit the scope of the present application. Without departing from the design spirit of the present application, various modifications and improvements made by those skilled in the art to the technical solutions of the present application shall fall within the protection scope of the claims of the present application.
Claims
1. A method for rapid barcode recognition based on a barcode scanner, characterized in that, Includes the following steps: S1. Use a barcode scanner with double-sided scanning function to acquire barcode image data, wherein the barcode includes barcode images of different sizes, angles and lighting conditions; In S1, the barcode scanner's double-sided scanning function uses two barcode scanning cameras facing away from each other to scan barcodes located in opposite directions simultaneously. S2. Preprocess the acquired barcode image, including converting the color image to 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. Input the preprocessed image data into the image recognition model for processing. The processing steps include real-time processing and enhancement of unclear image data in the barcode image, followed by 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, and the missing pixels are supplemented by bilinear interpolation algorithm and edge sharpening is applied. S5. Input the enhanced image into the image recognition model for secondary recognition and output the final decoding result.
2. The method for rapid barcode recognition based on a barcode scanner according to claim 1, characterized in that, In step S2, the preprocessing step transforms barcode image data of different sizes, angles, and lighting conditions into image data with uniform scale and brightness.
3. The method for rapid barcode recognition 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, keeping the number of parameters within 500KB, and supports inference calculations on an ARM Cortex-M7 microcontroller with a latency of less than 200ms.
4. The method for rapid barcode recognition based on a barcode scanner according to claim 1, characterized in that, In S4, when the image quality assessment score is lower than the threshold, an 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. Image noise is reduced in two stages while preserving edge sharpness, including frequency domain filtering and spatial domain filtering.
5. The method for rapid barcode identification based on a barcode scanner according to claim 4, characterized in that, The image quality assessment score is used to evaluate the recognizability of barcode image data. The specific calculation steps are as follows: in, This represents the image quality assessment score. Indicates the classification score weight. This represents the feature vector output by the image recognition model. Represents the structural similarity weights. This indicates the similarity between the recognized image and the feature maps in the image recognition model. Indicates the decoding verification weight. Indicates the feedback factor; The similarity between the recognized image and the feature maps in the image recognition model. The calculation formula is as follows: in, This indicates a feedback write function, used to write the output feedback of the image recognition model into the image recognition model. This represents the feedback fusion weight, used to control the update magnitude. Let represent the reward function constructed by the dual constraints of structure and brightness, where x and y represent the two images to be compared. and These represent the mean values of the two images.
6. The method for rapid barcode recognition based on a barcode scanner according to claim 1, characterized in that, In step S4, when the image quality assessment score is higher than the threshold, the decoding result is directly output.
7. A barcode scanner, characterized in that, The barcode scanner uses the barcode scanning method for rapid barcode recognition based on the barcode scanner as described in any one of claims 1-6, including a double-sided scanning module for acquiring image data, a processing module for image preprocessing, and a lightweight CNN model module for barcode recognition. The double-sided scanning module includes two scanning cameras facing away from each other, which can scan barcodes from different directions simultaneously. The processing module and the lightweight CNN model module are integrated into one unit and installed in an embedded system or mobile device, enabling the barcode scanner to quickly complete barcode recognition and processing locally without relying on external devices or network connections.
Citation Information
Patent Citations
Image processing method and electronic equipment
CN117077703A
Optical reader having inclinable stage which mounts optical unit thereon
US20020056750A1