Barcode recognition method and device, electronic equipment and storage medium

By performing segmented threshold group determination and binary processing on barcode grayscale images, a binary image group suitable for barcode recognition is generated, which solves the problem of interference with reading of low-quality barcode images and improves the recognition success rate and recognition effect.

CN119918553APending Publication Date: 2025-05-02GRG BANKING EQUIPMENT CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411994768.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-31
Publication Date
2025-05-02

AI Technical Summary

Technical Problem

In the prior art, low-quality barcode images are likely to interfere with barcode reading, resulting in a decrease in the reading success rate and affecting information transmission.

Method used

By obtaining the barcode grayscale image containing the barcode, segmented threshold groups are determined, and the image is binarized using these threshold groups to generate a binarized image group with partial overlap between the foreground and the background, and then barcode recognition is performed.

Benefits of technology

This method can effectively filter low-quality barcode images, improve the success rate of barcode recognition, and enhance the filtering effect on interferences such as color, noise, lighting, and posture.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119918553A_ABST
    Figure CN119918553A_ABST
Patent Text Reader

Abstract

The invention discloses a bar code recognition method and device, electronic equipment and a storage medium, and belongs to the technical field of image processing, and the method comprises the steps: obtaining a bar code grayscale image containing a bar code; determining at least one segmentation threshold value group according to the bar code gray scale image, wherein each segmentation threshold value group comprises two segmentation threshold values obtained through transformation according to the same gray scale threshold value; binarization is carried out on the bar code grayscale image by using the segmented threshold groups to obtain a binarized image group corresponding to each segmented threshold group, and each binarized image group comprises two images of which the foreground and the background are partially overlapped; according to the method, the images in the binarized image group are subjected to bar code recognition to determine the recognition result of the bar code, so that fine image details can be captured, interference such as color, noise, illumination and posture of the bar code can be well filtered, the recognition success rate of the low-quality bar code image is improved, and the recognition effect is good.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of image processing technology, and in particular, relates to a barcode recognition method, device, electronic device and storage medium. Background Art

[0002] With the development of the information digital age, the way information is transmitted has also undergone tremendous changes. Among them, barcodes, as information carriers, play a very important role in digital transmission and have penetrated into people's daily lives, such as retail, medical care, library management, government affairs, asset management, and smartphone information interaction.

[0003] When barcodes are used for information storage and transmission, they generally need to go through the process of generation, printing, scanning and recognition. Generally speaking, barcodes are easier to read than machines and can reduce human errors, which is very helpful in improving productivity. However, when barcodes are printed and scanned, due to the complexity of the real natural scene, it is easy to form low-quality barcode images. Such low-quality images will interfere with barcode reading, affect the success rate of barcode reading, and are not conducive to the development of barcode information transmission. Summary of the invention

[0004] The present application aims to solve at least one of the technical problems existing in the prior art. To this end, the present application proposes a barcode recognition method, device, electronic device and storage medium, which can effectively filter low-quality barcode images and improve the success rate of barcode recognition.

[0005] In a first aspect, the present application provides a barcode recognition method, comprising:

[0006] Get the barcode grayscale image containing the barcode;

[0007] Determine at least one segmentation threshold group according to the barcode grayscale image, each of the segmentation threshold groups includes two segmentation thresholds obtained by transforming the same grayscale threshold;

[0008] Binarizing the barcode grayscale image using the segmentation threshold group to obtain a binary image group corresponding to each segmentation threshold group, each of the binary image groups including two images with partially overlapping foreground and background;

[0009] Barcode recognition is performed on the images in the binary image group to determine the recognition result of the barcode.

[0010] In some embodiments, acquiring a barcode grayscale image containing a barcode includes:

[0011] Using an image acquisition module to acquire a barcode image containing a barcode;

[0012] When the barcode image is a black and white image, the black and white image is used as a barcode grayscale image;

[0013] When the barcode image is a color image, the color image is split into multiple single-channel images, and the grayscale variance of each single-channel image is calculated; and the single-channel image with the largest grayscale variance is selected as the barcode grayscale image.

[0014] In some embodiments, determining at least one segmentation threshold group according to the barcode grayscale image includes:

[0015] Determine the statistical analysis results of all grayscale values ​​in the barcode grayscale image;

[0016] Determine a first grayscale threshold for binarizing the barcode grayscale image according to the statistical analysis result;

[0017] At least one segmentation threshold group is determined based on the first grayscale threshold and at least one target weight group, wherein the target weight group includes a weight not less than 1 and a weight less than 1.

[0018] In some embodiments, when there are multiple segmentation threshold groups, determining at least one segmentation threshold group according to the first grayscale threshold and at least one target weight group includes:

[0019] The first grayscale threshold is transformed according to a plurality of target weight groups to obtain a plurality of segmentation threshold groups, wherein each target weight group corresponds to one segmentation threshold group.

[0020] In some embodiments, when there are two segmentation threshold groups, determining at least one segmentation threshold group according to the first grayscale threshold and at least one target weight group includes:

[0021] Transforming the first grayscale threshold according to a target weight group to obtain a first segmentation threshold group, and determining a local grayscale value interval corresponding to the segmentation threshold group;

[0022] Determine a statistical analysis result of the grayscale value located in the local grayscale value interval in the barcode grayscale image, and determine a second grayscale threshold value according to the statistical analysis result;

[0023] The second grayscale threshold is transformed according to the target weight group to obtain a second segmentation threshold group.

[0024] In some embodiments, the barcode grayscale image is binarized using the segmentation threshold group to obtain a binarized image group corresponding to each segmentation threshold group, including:

[0025] Dividing all grayscale values ​​of the barcode grayscale image into three grayscale value segments according to the segmentation threshold group;

[0026] The barcode grayscale image is binarized twice according to the grayscale value segment to obtain a binarized image group corresponding to the corresponding segmentation threshold group, wherein the two binarization results of the pixel points located in the middle of the grayscale value segment are opposite, and the two binarization results of the pixel points located in the remaining grayscale value segments are the same.

[0027] In a second aspect, the present application provides a barcode recognition device, comprising:

[0028] An acquisition module, used for acquiring a barcode grayscale image containing a barcode;

[0029] A determination module, used to determine at least one segmentation threshold group according to the barcode grayscale image, each of the segmentation threshold groups includes two segmentation thresholds obtained by transforming the same grayscale threshold;

[0030] A binarization module, used for binarizing the barcode grayscale image using the segmentation threshold group to obtain a binarized image group corresponding to each segmentation threshold group, each of which includes two images with partially overlapping foreground and background;

[0031] The recognition module is used to perform barcode recognition on the images in the binary image group to determine the recognition result of the barcode.

[0032] In some embodiments, the acquisition module is specifically used to:

[0033] Using an image acquisition module to acquire a barcode image containing a barcode;

[0034] When the barcode image is a black and white image, the black and white image is used as a barcode grayscale image;

[0035] When the barcode image is a color image, the color image is split into multiple single-channel images, and the grayscale variance of each single-channel image is calculated; and the single-channel image with the largest grayscale variance is selected as the barcode grayscale image.

[0036] In some embodiments, the determining module is specifically used to:

[0037] Determine the statistical analysis results of all grayscale values ​​in the barcode grayscale image;

[0038] Determine a first grayscale threshold for binarizing the barcode grayscale image according to the statistical analysis result;

[0039] At least one segmentation threshold group is determined based on the first grayscale threshold and at least one target weight group, wherein the target weight group includes a weight not less than 1 and a weight less than 1.

[0040] In some embodiments, when there are multiple segmentation threshold groups, the determination module is specifically configured to:

[0041] The first grayscale threshold is transformed according to a plurality of target weight groups to obtain a plurality of segmentation threshold groups, wherein each target weight group corresponds to one segmentation threshold group.

[0042] In some embodiments, when there are two segmentation threshold groups, the determination module is specifically configured to:

[0043] Transforming the first grayscale threshold according to a target weight group to obtain a first segmentation threshold group, and determining a local grayscale value interval corresponding to the segmentation threshold group;

[0044] Determine a statistical analysis result of the grayscale value located in the local grayscale value interval in the barcode grayscale image, and determine a second grayscale threshold value according to the statistical analysis result;

[0045] The second grayscale threshold is transformed according to the target weight group to obtain a second segmentation threshold group.

[0046] In some embodiments, the binarization module is specifically used for:

[0047] Dividing all grayscale values ​​of the barcode grayscale image into three grayscale value segments according to the segmentation threshold group;

[0048] The barcode grayscale image is binarized twice according to the grayscale value segment to obtain a binarized image group corresponding to the corresponding segmentation threshold group, wherein the two binarization results of the pixel points located in the middle of the grayscale value segment are opposite, and the two binarization results of the pixel points located in the remaining grayscale value segments are the same.

[0049] In a third aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements any of the barcode recognition methods described above.

[0050] In a fourth aspect, the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements any of the above-described barcode recognition methods when executing the program.

[0051] In a fifth aspect, the present application provides a computer program product, including a computer program, which implements any of the above-mentioned barcode recognition methods when executed by a processor.

[0052] The barcode recognition method, device, storage medium, electronic device and computer program product provided by the embodiments of the present application obtain a barcode grayscale image containing a barcode; determine at least one segmentation threshold group according to the barcode grayscale image, each segmentation threshold group includes two segmentation thresholds obtained by transforming the same grayscale threshold; binarize the barcode grayscale image using the segmentation threshold group to obtain a binarized image group corresponding to each segmentation threshold group, each binarized image group includes two images with partial overlap in foreground and background respectively; perform barcode recognition on the images in the binarized image group to determine the recognition result of the barcode, that is, determine at least one segmentation threshold group according to the grayscale threshold of the barcode grayscale image, and binarize the barcode grayscale image multiple times using the segmentation threshold group to obtain at least one group of binarized images with partial overlap in foreground and background, so as to capture finer image details, have a good filtering effect on interference such as color, noise, light, posture, etc. of the barcode, improve the recognition success rate of low-quality barcode images, and have a good recognition effect. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] In order to more clearly illustrate the technical solution of the present invention, the accompanying drawings required for use in the description of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.

[0054] Figure 1 It is a flowchart of a barcode recognition method provided in an embodiment of the present application;

[0055] Figure 2 is another flowchart of the barcode recognition method provided by an embodiment of the present application;

[0056] Figure 3 is a schematic diagram of the structure of a barcode recognition device provided in an embodiment of the present application;

[0057] Figure 4 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application;

[0058] Figure 5 It is a schematic diagram of the hardware structure of the electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION

[0059] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application, and cannot be understood as limiting the present application.

[0060] At present, in the process of using barcodes, there are various unfavorable factors in real natural scenes that affect the reading of barcodes. For example, due to the different quality of printing equipment or ink, the quality of printed barcodes is uneven; the barcodes are worn out due to repeated use; the barcodes are interfered by light, posture and the scanning equipment itself when scanning images, and the scanned images have poor quality; the barcode scanned images undergo multiple lossy compression transmissions, resulting in poor final image quality. These unfavorable factors will lead to the formation of low-quality barcode images, which in turn affects barcode reading, greatly reducing the success rate of barcode reading, and are not conducive to the development of barcode information transmission.

[0061] To solve at least one of the above technical problems, the embodiments of the present application provide a barcode recognition method, device, storage medium, electronic device and computer program product.

[0062] See also Figure 1 , Figure 1 1 is a flow chart of a barcode recognition method provided in an embodiment of the present application. The barcode recognition method is applied to an electronic device and can be executed by a functional module in the electronic device. The barcode recognition method includes the following steps 101-104, wherein:

[0063] 101. Obtain a barcode grayscale image containing a barcode.

[0064] Among them, the barcode grayscale image is an image that only contains brightness information but not color information, which can be directly acquired by the black and white image acquisition module, or obtained by performing certain processing on the image acquired by the color image acquisition module. The barcode can be a two-dimensional barcode, such as a QR code, or a one-dimensional barcode, such as a barcode.

[0065] In some embodiments, see Figure 2 , Figure 2 1 is another flowchart of the barcode recognition method provided in the embodiment of the present application, wherein the above step 101 specifically includes:

[0066] 1011. Using an image acquisition module to acquire a barcode image including a barcode;

[0067] 1012. When the barcode image is a black and white image, the black and white image is used as the barcode grayscale image; when the barcode image is a color image, the color image is split into multiple single-channel images, and the grayscale variance of each single-channel image is calculated; the single-channel image with the largest grayscale variance is selected as the barcode grayscale image.

[0068] When a barcode recognition requirement is received, the image acquisition module can be called to acquire the barcode image. For the barcode image I acquired by the image acquisition module, the attribute of the image I is determined. If the image I is a black and white image, it is directly used as the barcode grayscale image IGray.

[0069] If the image I is an RGB color image, the color image I is first split into multiple single-channel images [IB0, IB1, IB2], and then the grayscale variance of the images [IB0, IB1, IB2] is calculated to obtain [σ0, σ1, σ2]. The grayscale variance is the average of the square of the difference between the image brightness value and its average brightness value, which reflects the degree of brightness change of the image on this channel. At this time, according to the characteristics of the black and white storage information of the barcode, generally speaking, the clearer the barcode, the higher the contrast of its black and white bars, and the larger the corresponding image grayscale variance. Therefore, the single-channel image (such as IB0) corresponding to the largest value in [σ0, σ1, σ2] is taken as the barcode grayscale image IGray. The IGray selected in this way can more clearly express the black and white bar information of the barcode, which is conducive to the subsequent successful conversion of the barcode into text symbols, thereby improving the barcode recognition success rate.

[0070] 102. Determine at least one segmentation threshold group according to the barcode grayscale image, each segmentation threshold group including two segmentation thresholds obtained by transforming the same grayscale threshold.

[0071] The grayscale threshold is a threshold determined based on the grayscale value of the pixel points of the entire barcode grayscale image, which is used to segment the foreground and background. Each segmentation threshold group has two segmentation thresholds, one greater than or equal to the grayscale threshold, and one less than the grayscale threshold. For example, if the grayscale threshold is t and the grayscale value range is [0, 255], then the value range of one segmentation threshold is (0, t), and the value range of the other segmentation threshold is [t, 255).

[0072] In some embodiments, the above step 102 specifically includes:

[0073] 1021. Determine a statistical analysis result of all grayscale values ​​in the barcode grayscale image, and determine a first grayscale threshold for binarizing the barcode grayscale image according to the statistical analysis result;

[0074] 1022. Determine at least one segmentation threshold group based on the first grayscale threshold and at least one target weight group, where the target weight group includes a weight not less than 1 and a weight less than 1.

[0075] Among them, the maximum inter-class variance method can be used to calculate the first grayscale threshold t1, that is, first calculate the grayscale histogram of the image IGray, then traverse all possible grayscale values ​​as thresholds, and calculate the inter-class variance under each threshold. Considering that the maximum inter-class variance means the maximum difference between the foreground and the background, the grayscale value that makes the inter-class variance maximum can be found as the first grayscale threshold t1, which has a better binarization effect than the grayscale values ​​corresponding to other inter-class variances; the average method can also be used to calculate the first grayscale threshold t1, that is, the grayscale values ​​in the image IGray are averaged, and the grayscale value average is used as t1. Of course, other grayscale threshold calculation methods can also be used, which are not limited here.

[0076] The number of target weight groups depends on the number of binary image groups to be generated. When the number of binary image groups required is 1, only one target weight group needs to be set. The segmentation threshold group is used for subsequent segmentation binarization of the image IGray. Each segmentation threshold group can obtain two binary images with slight differences (partial non-overlapping) between the foreground and background.

[0077] Furthermore, when there is one segmentation threshold group, T1 and T2 in the segmentation threshold group can be calculated using the following formulas ① and ②:

[0078] ①T1=αt1, α∈(0, 1.0);

[0079] ②T2=βt1, β∈[1.0, 255 / t1);

[0080] Among them, α and β are the weights in the target weight group, and t1 is the first grayscale threshold.

[0081] Furthermore, when there are multiple segmentation threshold groups, it can be achieved by setting multiple target weight groups, or it can also be achieved by setting only one target weight group and updating multiple grayscale thresholds.

[0082] For example, when multiple target weight groups are set, the above step 1022 may specifically include:

[0083] The first grayscale threshold is transformed according to a plurality of target weight groups to obtain a plurality of segmentation threshold groups, one segmentation threshold group corresponding to each target weight group.

[0084] Among them, multiple segmentation threshold groups can be achieved by setting multiple target weight groups, that is, setting multiple α and β. The calculation method of each segmentation threshold group is shown in the above formulas ① and ②, which will not be repeated here.

[0085] For example, when only one target weight group is set, taking the number of the segmentation threshold groups as two as an example, the above step 1022 may specifically include:

[0086] The first grayscale threshold is transformed according to a target weight group to obtain a first segmentation threshold group, and a local grayscale value interval corresponding to the segmentation threshold group is determined;

[0087] Determine a statistical analysis result of the grayscale value in the barcode grayscale image located in the local grayscale value interval, and determine a second grayscale threshold value according to the statistical analysis result;

[0088] The second grayscale threshold is transformed according to the target weight group to obtain a second segmentation threshold group.

[0089] That is, after determining the first grayscale threshold t1 by calculating the inter-class variance or average grayscale value of all grayscale values ​​in the image IGray, the above formulas ① and ② are used to calculate the first segmentation threshold group, and the local grayscale value interval corresponding to T1 and T2 is [T1, T2]. Next, the second grayscale threshold t2 is calculated. The second grayscale threshold t2 is determined by calculating the inter-class variance or average of the grayscale values ​​in the image IGray within [T1, T2]. After that, the above formulas ① and ② are still used to calculate the second segmentation threshold group, except that the first grayscale threshold t1 in the formula is replaced by the second grayscale threshold t2. If more segmentation threshold groups need to be calculated, the new grayscale threshold can be determined in the same way, and the new segmentation threshold group is calculated based on the new grayscale threshold and the above formulas ① and ②, which will not be repeated here.

[0090] 103. Binarize the barcode grayscale image using the segmentation threshold group to obtain a binary image group corresponding to each segmentation threshold group, each binary image group including two images with partially overlapping foreground and background.

[0091] In some embodiments, please see Figure 2 , the above step 103 specifically includes:

[0092] 1031. Divide all grayscale values ​​of the barcode grayscale image into three grayscale value segments according to each segmentation threshold group;

[0093] 1032. Binarize the barcode grayscale image twice according to the grayscale value segment to obtain a binarized image group corresponding to the corresponding segmentation threshold group, wherein the binarization results of the pixels located in the middle grayscale value segment are opposite, and the binarization results of the pixels located in the remaining grayscale value segments are the same.

[0094] The process of using the segmented threshold group to perform two binarization processes on the image IGray can be seen in the following formulas ③ and ④, where:

[0095]

[0096] Among them, images Bin0 and Bin1 are two images in the binary image group, Bin0(x) represents the pixel value of the pixel in image Bin0, Bin1(x) represents the pixel value of the pixel in image Bin1, IGray(x) is the grayscale value of the pixel x in image IGray, and T1 and T2 are segmentation thresholds.

[0097] It is easy to know that for the pixels in the gray value range [T1, T2] in the image IGray, the two binarization results are opposite, and for the pixels in the gray value range [0, T1) and (T2, 255] in the image IGray, the two binarization results are the same. This binarization method can obtain two binary images with slight differences in the foreground and background, can capture finer image details from the image IGray, and is more sensitive to local changes in the image. Moreover, the more segmentation threshold groups there are, the more binary image groups there are, and the more fine details are captured. This binarization method has a good filtering effect on the interference of barcode color, noise, illumination, posture, etc., which helps to filter out noise and improve the robustness of the image.

[0098] 104. Perform barcode recognition on the images in the binary image group to determine a recognition result of the barcode.

[0099] Among them, since in the binary image, 1 is white and 0 is black, if the barcode is a white barcode, the pixel point with a pixel value of 1 in the binary image is the target point that needs to be recognized by the barcode, and if the barcode is a black barcode, the pixel point with a pixel value of 0 in the binary image is the target point that needs to be recognized by the barcode. Based on the target point, the area where the barcode is located can be located first, and then the text symbol conversion of the content of the located area can be performed based on the barcode rules to perform barcode recognition. When any image in the binary image group is successfully recognized, the recognition result of the barcode is successful.

[0100] As can be seen from the above, the barcode recognition method provided by the embodiment of the present application obtains a barcode grayscale image containing a barcode; determines at least one segmentation threshold group according to the barcode grayscale image, each segmentation threshold group includes two segmentation thresholds obtained by transforming the same grayscale threshold; binarizes the barcode grayscale image using the segmentation threshold group to obtain a binarized image group corresponding to each segmentation threshold group, each binarized image group includes two images with partial overlap in the foreground and background respectively; performs barcode recognition on the images in the binarized image group to determine the recognition result of the barcode, that is, determines at least one segmentation threshold group according to the grayscale threshold of the barcode grayscale image, and binarizes the barcode grayscale image multiple times using the segmentation threshold group to obtain at least one group of binarized images with partial overlap in the foreground and background, thereby capturing finer image details, having a good filtering effect on interference such as color, noise, illumination, and posture of the barcode, improving the recognition success rate of low-quality barcode images, and having a good recognition effect.

[0101] According to the barcode recognition method described in the above embodiment, the present application embodiment also provides a barcode recognition device. Figure 3 , Figure 3 20 is a schematic diagram of the structure of a barcode recognition device provided in an embodiment of the present application. The barcode recognition device is applied to an electronic device, and the barcode recognition method described in the above embodiment can be executed by a functional module in the electronic device. The barcode recognition device includes an acquisition module 201, a determination module 202, a binarization module 203 and an identification module 204, wherein:

[0102] An acquisition module 201 is used to acquire a barcode grayscale image containing a barcode;

[0103] A determination module 202, configured to determine at least one segmentation threshold group according to the barcode grayscale image, each segmentation threshold group including two segmentation thresholds obtained by transforming the same grayscale threshold;

[0104] A binarization module 203 is used to binarize the barcode grayscale image using the segmentation threshold group to obtain a binarized image group corresponding to each segmentation threshold group, each binarized image group includes two images with partially overlapping foreground and background;

[0105] The recognition module 204 is used to perform barcode recognition on the images in the binary image group to determine the recognition result of the barcode.

[0106] In some embodiments, the acquisition module 201 is specifically used for:

[0107] Using an image acquisition module to acquire a barcode image containing a barcode;

[0108] When the barcode image is a black and white image, the black and white image is used as the barcode grayscale image;

[0109] When the barcode image is a color image, the color image is split into multiple single-channel images, and the grayscale variance of each single-channel image is calculated; the single-channel image with the largest grayscale variance is selected as the barcode grayscale image.

[0110] In some embodiments, the determination module 202 is specifically configured to:

[0111] Determine the statistical analysis results of all grayscale values ​​in the barcode grayscale image;

[0112] Determine a first grayscale threshold for binarizing the barcode grayscale image according to the statistical analysis result;

[0113] At least one segmentation threshold group is determined based on the first grayscale threshold and at least one target weight group, wherein the target weight group includes a weight not less than 1 and a weight less than 1.

[0114] In some embodiments, when there are multiple segmentation threshold groups, the determination module 202 is specifically configured to:

[0115] The first grayscale threshold is transformed according to a plurality of target weight groups to obtain a plurality of segmentation threshold groups, one of the segmentation threshold groups corresponding to each target weight group.

[0116] In some embodiments, when the number of segmentation threshold groups is two, the determination module 202 is specifically configured to:

[0117] The first grayscale threshold is transformed according to a target weight group to obtain a first segmentation threshold group, and a local grayscale value interval corresponding to the segmentation threshold group is determined;

[0118] Determine a statistical analysis result of the grayscale value in the barcode grayscale image located in the local grayscale value interval, and determine a second grayscale threshold value according to the statistical analysis result;

[0119] The second grayscale threshold is transformed according to the target weight group to obtain a second segmentation threshold group.

[0120] In some embodiments, the binarization module 203 is specifically used for:

[0121] Divide all grayscale values ​​of the barcode grayscale image into three grayscale value segments according to the segmentation threshold group;

[0122] The barcode grayscale image is binarized twice according to the grayscale value segment to obtain a binarized image group corresponding to the corresponding segmentation threshold group, wherein the two binarization results of the pixel points located in the middle grayscale value segment are opposite, and the two binarization results of the pixel points located in the remaining grayscale value segments are the same.

[0123] It should be noted that the specific details of each module unit in the above-mentioned barcode recognition device 200 have been described in detail in the embodiment of the above-mentioned barcode recognition method, and will not be repeated here.

[0124] As can be seen from the above, the barcode recognition device 200 provided in the embodiment of the present application obtains a barcode grayscale image containing a barcode through the acquisition module 201; the determination module 202 determines at least one segmentation threshold group according to the barcode grayscale image, each segmentation threshold group includes two segmentation thresholds obtained by transforming the same grayscale threshold; the binarization module 203 uses the segmentation threshold group to binarize the barcode grayscale image to obtain a binarized image group corresponding to each segmentation threshold group, each binarized image group includes two images with partial overlap in the foreground and background respectively; the recognition module 204 performs barcode recognition on the image in the binarized image group to determine the recognition result of the barcode, that is, at least one segmentation threshold group is determined according to the grayscale threshold of the barcode grayscale image, and the barcode grayscale image is binarized multiple times using the segmentation threshold group to obtain at least one group of binarized images with partial overlap in the foreground and background, so that finer image details can be captured, and the interference of the color, noise, light, posture, etc. of the barcode has a good filtering effect, thereby improving the recognition success rate of low-quality barcode images and having a good recognition effect.

[0125] In some embodiments, Figure 4 As shown, the embodiment of the present application also provides an electronic device 300, including a processor 301, a memory 302, and a computer program stored in the memory 302 and executable on the processor 301. When the program is executed by the processor 301, each process of the above-mentioned barcode recognition method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0126] It should be noted that the electronic devices in the embodiments of the present application include the above-mentioned mobile electronic devices and non-mobile electronic devices.

[0127] Figure 5 A schematic diagram of the hardware structure of an electronic device to implement an embodiment of the present application.

[0128] The electronic device 400 includes but is not limited to: a radio frequency module 401, a network module 402, an audio output module 403, an item input module 404, a sensor 405, a display module 406, a user item input module 407, an interface module 408, a memory 409 and a processor 410 and other components.

[0129] In some embodiments, the processor 410 implements the following steps when executing the program:

[0130] Get the barcode grayscale image containing the barcode;

[0131] Determine at least one segmentation threshold group according to the barcode grayscale image, each segmentation threshold group includes two segmentation thresholds obtained by transforming the same grayscale threshold;

[0132] Binarizing the barcode grayscale image using the segmentation threshold group to obtain a binary image group corresponding to each segmentation threshold group, each binary image group including two images with partially overlapping foreground and background;

[0133] Barcode recognition is performed on the images in the binary image group to determine the recognition result of the barcode.

[0134] Furthermore, the processor 410 implements the following steps:

[0135] Using an image acquisition module to acquire a barcode image containing a barcode;

[0136] When the barcode image is a black and white image, the black and white image is used as the barcode grayscale image;

[0137] When the barcode image is a color image, the color image is split into multiple single-channel images, and the grayscale variance of each single-channel image is calculated; the single-channel image with the largest grayscale variance is selected as the barcode grayscale image.

[0138] Furthermore, the processor 410 implements the following steps:

[0139] Determine the statistical analysis results of all grayscale values ​​in the barcode grayscale image;

[0140] Determine a first grayscale threshold for binarizing the barcode grayscale image according to the statistical analysis result;

[0141] At least one segmentation threshold group is determined based on the first grayscale threshold and at least one target weight group, wherein the target weight group includes a weight not less than 1 and a weight less than 1.

[0142] Further, when there are multiple segmentation threshold groups, the processor 410 implements the following steps:

[0143] The first grayscale threshold is transformed according to a plurality of target weight groups to obtain a plurality of segmentation threshold groups, one of the segmentation threshold groups corresponding to each target weight group.

[0144] Further, when there are two segmentation threshold groups, the processor 410 implements the following steps:

[0145] The first grayscale threshold is transformed according to a target weight group to obtain a first segmentation threshold group, and a local grayscale value interval corresponding to the segmentation threshold group is determined;

[0146] Determine a statistical analysis result of the grayscale value in the barcode grayscale image located in the local grayscale value interval, and determine a second grayscale threshold value according to the statistical analysis result;

[0147] The second grayscale threshold is transformed according to the target weight group to obtain a second segmentation threshold group.

[0148] Furthermore, the processor 410 implements the following steps:

[0149] Divide all grayscale values ​​of the barcode grayscale image into three grayscale value segments according to the segmentation threshold group;

[0150] The barcode grayscale image is binarized twice according to the grayscale value segment to obtain a binarized image group corresponding to the corresponding segmentation threshold group, wherein the two binarization results of the pixel points located in the middle grayscale value segment are opposite, and the two binarization results of the pixel points located in the remaining grayscale value segments are the same.

[0151] Those skilled in the art will appreciate that the electronic device 400 may also include a power source (such as a battery) for supplying power to each component, and the power source may be logically connected to the processor 410 through a power management system, thereby implementing functions such as managing charging, discharging, and power consumption management through the power management system. Figure 5 The electronic device structure shown in the figure does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently, which will not be described in detail here.

[0152] It should be understood that, in the embodiment of the present application, the project input module 404 may include a graphics processor (Graphics Processing Unit, GPU) 4041 and a microphone 4042, and the graphics processor 4041 processes the image data of the static picture or video obtained by the image capture device (such as a camera) in the video capture mode or the image capture mode. The display module 406 may include a display panel 4061, and the display panel 4061 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. The user project input module 407 includes a touch panel 4071 and at least one of other input devices 4072. The touch panel 4071 is also called a touch screen. The touch panel 4071 may include two parts: a touch detection device and a touch controller. Other input devices 4072 may include, but are not limited to, a physical keyboard, function keys (such as a volume control button, a switch button, etc.), a trackball, a mouse, and a joystick, which will not be repeated here.

[0153] The memory 409 can be used to store software programs and various data. The memory 409 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, an application program or instructions required for at least one function (such as a sound playback function, an image playback function, etc.), etc. In addition, the memory 409 may include a volatile memory or a non-volatile memory, or the memory 409 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), a static random access memory (SRAM), a dynamic random access memory (DRAM), a synchronous dynamic random access memory (SDRAM), a double data rate synchronous dynamic random access memory (DDRSDRAM), an enhanced synchronous dynamic random access memory (ESDRAM), a synchronous link dynamic random access memory (SLDRAM) and a direct memory bus random access memory (DRRAM). The memory 409 in the embodiment of the present application includes but is not limited to these and any other suitable types of memory.

[0154] The processor 410 may include one or more processing modules; the processor 410 integrates an application processor and a modem processor, wherein the application processor mainly processes operations related to the operating system, user interface, and application programs, and the modem processor mainly processes wireless communication signals, such as a baseband processor. It is understandable that the modem processor may not be integrated into the processor 410.

[0155] The embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the various processes of the above-mentioned barcode recognition method embodiment are implemented and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0156] The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory ROM, a random access memory RAM, a magnetic disk or an optical disk.

[0157] An embodiment of the present application also provides a computer program product, including a computer program, which implements the above-mentioned barcode recognition method when executed by a processor.

[0158] The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory ROM, a random access memory RAM, a magnetic disk or an optical disk.

[0159] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.

[0160] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.

[0161] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.

[0162] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.

[0163] In the description of the present application, “plurality” means two or more.

[0164] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "illustrative embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials, or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.

[0165] Although the embodiments of the present application have been shown and described, those skilled in the art will appreciate that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present application, and that the scope of the present application is defined by the claims and their equivalents.

Claims

1. A barcode recognition method, characterized in that: include: Get the barcode grayscale image containing the barcode; Determine at least one segmentation threshold group according to the barcode grayscale image, each of the segmentation threshold groups includes two segmentation thresholds obtained by transforming the same grayscale threshold; Binarizing the barcode grayscale image using the segmentation threshold group to obtain a binary image group corresponding to each segmentation threshold group, each of the binary image groups including two images with partially overlapping foreground and background; Barcode recognition is performed on the images in the binary image group to determine the recognition result of the barcode.

2. The barcode recognition method according to claim 1, characterized in that: The step of obtaining a barcode grayscale image containing a barcode includes: Using an image acquisition module to acquire a barcode image containing a barcode; When the barcode image is a black and white image, the black and white image is used as a barcode grayscale image; When the barcode image is a color image, the color image is split into multiple single-channel images, and the grayscale variance of each single-channel image is calculated; and the single-channel image with the largest grayscale variance is selected as the barcode grayscale image.

3. The barcode recognition method according to claim 1, characterized in that: The step of determining at least one segmentation threshold group according to the barcode grayscale image comprises: Determine the statistical analysis results of all grayscale values ​​in the barcode grayscale image; Determine a first grayscale threshold for binarizing the barcode grayscale image according to the statistical analysis result; At least one segmentation threshold group is determined based on the first grayscale threshold and at least one target weight group, wherein the target weight group includes a weight not less than 1 and a weight less than 1.

4. The barcode recognition method according to claim 3, characterized in that: When there are multiple segmentation threshold groups, determining at least one segmentation threshold group according to the first grayscale threshold and at least one target weight group includes: The first grayscale threshold is transformed according to a plurality of target weight groups to obtain a plurality of segmentation threshold groups, wherein each target weight group corresponds to one segmentation threshold group.

5. The barcode recognition method according to claim 3, characterized in that: When there are two segmentation threshold groups, determining at least one segmentation threshold group according to the first grayscale threshold and at least one target weight group includes: Transforming the first grayscale threshold according to a target weight group to obtain a first segmentation threshold group, and determining a local grayscale value interval corresponding to the segmentation threshold group; Determine a statistical analysis result of the grayscale value located in the local grayscale value interval in the barcode grayscale image, and determine a second grayscale threshold value according to the statistical analysis result; The second grayscale threshold is transformed according to the target weight group to obtain a second segmentation threshold group.

6. The barcode recognition method according to any one of claims 1 to 5, characterized in that: The step of binarizing the barcode grayscale image by using the segmentation threshold group to obtain a binarized image group corresponding to each segmentation threshold group includes: Dividing all grayscale values ​​of the barcode grayscale image into three grayscale value segments according to the segmentation threshold group; The barcode grayscale image is binarized twice according to the grayscale value segment to obtain a binarized image group corresponding to the corresponding segmentation threshold group, wherein the two binarization results of the pixel points located in the middle of the grayscale value segment are opposite, and the two binarization results of the pixel points located in the remaining grayscale value segments are the same.

7. A barcode recognition device, characterized in that: include: An acquisition module, used for acquiring a barcode grayscale image containing a barcode; A determination module, used to determine at least one segmentation threshold group according to the barcode grayscale image, each of the segmentation threshold groups includes two segmentation thresholds obtained by transforming the same grayscale threshold; A binarization module, used for binarizing the barcode grayscale image using the segmentation threshold group to obtain a binarized image group corresponding to each segmentation threshold group, each of which includes two images with partially overlapping foreground and background; The recognition module is used to perform barcode recognition on the images in the binary image group to determine the recognition result of the barcode.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the barcode recognition method according to any one of claims 1 to 6 is implemented.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the barcode recognition method according to any one of claims 1 to 6 is implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the barcode recognition method according to any one of claims 1 to 6 is implemented.