Method and device for improving two-dimensional code decoding rate, user equipment and storage medium

By replacing the QR code data codewords with the global variables saved at the previous successful decoding in a complex environment, and using an error correction algorithm for error correction and decoding, the problem of QR code failure in a complex environment is solved, and the decoding rate and stability are improved.

CN120068900APending Publication Date: 2025-05-30SHENZHEN YANXIANG JINMA SOFTWARE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411971568.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-30
Publication Date
2025-05-30

AI Technical Summary

Technical Problem

In complex environments, QR codes are prone to wear, missing, stains, blur, etc., resulting in the number of codeword errors read exceeding the error correction ability and being unable to decode. The existing technology is difficult to effectively improve the decoding rate and decoding stability.

Method used

By replacing the data codeword in the first codeword of the target QR code in the global variable saved at the previous successful decoding, the second codeword is obtained, and the error correction and decoding of the second codeword is used to correct and decode the second codeword until successful.

Benefits of technology

This method can quickly and stably meet the error correction ability of the error correction algorithm, effectively improving the decoding rate and decoding stability of QR codes in complex environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120068900A_ABST
    Figure CN120068900A_ABST
Patent Text Reader

Abstract

The invention provides a method for improving the decoding rate of a two-dimensional code, and the method comprises the steps: replacing a data code word in a first code word of a target two-dimensional code according to a global variable stored during the previous successful decoding, so as to obtain a second code word; performing error correction on the second code word by using an error correction algorithm; and when the error correction of the second code word is successful, decoding the second code word after error correction, and storing the data code word in the second code word after error correction to a global variable. According to the invention, the decoding rate and the decoding stability in a complex environment can be effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data error correction, and in particular to a method, device, user equipment and storage medium for improving the decoding rate of two-dimensional codes. Background Art

[0002] Two-dimensional codes are widely used in industrial environments. From small parts to large products, they may provide functions such as traceability or identification through two-dimensional codes. Due to the complex and diverse industrial environments, it is easy for two-dimensional codes to be worn, missing, stained, blurred, or in other situations that are not easy to accurately identify. Therefore, for two-dimensional codes in complex scenarios with specific sequences, the number of incorrect codewords read is greater than the error correction ability, resulting in inability to decode. In this case, the decoding process of existing technical solutions generally involves sampling to obtain a codeword stream, and then passing through the RS error correction algorithm. If the error correction is successful, decoding is performed; if it fails, the decoding ends. There is also a type that, after decoding fails, tries to flip the binary image obtained by sampling to obtain different codewords, and then performs error correction through the RS error correction algorithm. If the error correction is successful, decoding is continued. However, no matter which of the foregoing methods is used, it is difficult to effectively improve the decoding rate and decoding stability in complex environments. Summary of the Invention

[0003] The method, device, user equipment and storage medium for improving the decoding rate of two-dimensional codes provided by the present invention can effectively improve the decoding rate and decoding stability in complex environments.

[0004] In a first aspect, the present invention provides a method for improving the decoding rate of two-dimensional codes, the method comprising:

[0005] Replacing the data codewords in the first codeword of the target two-dimensional code according to the global variables saved during the previous successful decoding to obtain a second codeword;

[0006] Performing error correction on the second codeword by using an error correction algorithm;

[0007] When the error correction of the second codeword is successful, decoding the corrected second codeword and saving the data codewords in the corrected second codeword to the global variables.

[0008] Optionally, the replacing the data codewords in the first codeword of the target two-dimensional code according to the global variables saved during the previous successful decoding to obtain a second codeword includes:

[0009] Comparing the data codewords of the first codeword with the global variables to obtain the codewords to be replaced in the data codewords of the first codeword that are different from the global variables;

[0010] Replacing the codewords to be replaced according to a preset quantity with the codewords at the corresponding positions in the global variables to obtain the second codeword.

[0011] Optionally, after correcting the errors of the second codeword using the error correction algorithm, the method further includes:

[0012] When the error correction of the second codeword fails, determine whether all of the codewords to be replaced have been replaced;

[0013] When all of the codewords to be replaced have been replaced, end the recognition of the target two-dimensional code;

[0014] When not all of the codewords to be replaced have been replaced, return to the step of replacing the codewords to be replaced with the codewords at the corresponding positions in the global variable according to the preset quantity to obtain the second codeword.

[0015] Optionally, before replacing the data codewords in the first codeword of the target two-dimensional code with the global variable saved during the previous successful decoding to obtain the second codeword, the method further includes:

[0016] Sample the target two-dimensional code to obtain the first codeword corresponding to the target two-dimensional code;

[0017] Use the error correction algorithm to correct the errors of the first codeword;

[0018] When the error correction of the first codeword fails, execute the step of replacing the data codewords in the first codeword of the target two-dimensional code with the global variable saved during the previous successful decoding to obtain the second codeword; the version of the target two-dimensional code is the same as that of the two-dimensional code decoded successfully last time.

[0019] Optionally, after correcting the errors of the first codeword using the error correction algorithm, the method further includes:

[0020] When the error correction of the first codeword is successful, decode the corrected first codeword and save the data codewords in the corrected first codeword to the global variable.

[0021] Optionally, the sampling of the target two-dimensional code to obtain the first codeword corresponding to the target two-dimensional code includes:

[0022] Obtain the codeword information in the target two-dimensional code, and arrange the codeword information into data codewords and error correction codewords according to the preset arrangement rule to obtain the first codeword.

[0023] Optionally, the decoding of the corrected second codeword includes: decoding the corrected second codeword into a string according to the preset decoding rule.

[0024] Second aspect, the present invention provides a device for improving the QR code decoding rate, including:

[0025] A data codeword filling module, configured to replace the data codewords in the first codeword of the target QR code according to the global variables saved during the previous successful decoding, so as to obtain a second codeword;

[0026] An error correction module, configured to perform error correction on the second codeword by using an error correction algorithm;

[0027] A decoding module, configured to, when the error correction of the second codeword is successful, decode the corrected second codeword and save the data codewords in the corrected second codeword as global variables.

[0028] Third aspect, the present invention provides a user equipment, where the user equipment includes:

[0029] At least one processor; and

[0030] A memory communicatively connected to the at least one processor; wherein,

[0031] The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor, so that the at least one processor can execute the method for improving the QR code decoding rate as described in any one of the foregoing.

[0032] Fourth aspect, the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and when the computer instructions are executed by a processor, the method for improving the QR code decoding rate as described in any one of the foregoing is implemented.

[0033] In the technical solution provided by the present invention, based on the industrial environment, the QR codes printed on products generally have product serial numbers, and the serial numbers contain specific sequences used to distinguish different models and different series. There are few cases where meaningless random numbers are used as the QR code encoding of products. That is, in the scenario of decoding QR codes with specific sequences (the encoding sequences have certain rules), the codeword information is arranged in the format of data codewords + error correction codewords in sequence. Therefore, during the decoding process, if a decoding failure occurs, the data codewords saved during the previous successful decoding are used to replace the data codewords of the current QR code, so that the obtained second codeword can quickly and stably meet the error correction ability of the error correction algorithm, thereby effectively improving the decoding rate and decoding stability in complex environments. Description of the Drawings

[0034] Figure 1 It is a flowchart of the method for improving the QR code decoding rate according to an embodiment of the present invention;

[0035] Figure 2Exemplary QR code rules for the method of improving the QR code decoding rate in another embodiment of the present invention;

[0036] Figure 3 Exemplary QR code patterns for the method of improving the QR code decoding rate in another embodiment of the present invention;

[0037] Figure 4 Exemplary QR code patterns for the method of improving the QR code decoding rate in another embodiment of the present invention;

[0038] Figure 5 Data processing flowchart of the device for improving the QR code decoding rate in another embodiment of the present invention. Detailed implementation manners

[0039] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Apparently, the described embodiments are only a part rather than all of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.

[0040] The embodiments of the present invention provide a method for improving the QR code decoding rate, which is applicable to the scenario of decoding QR codes with specific sequences (the coding sequences have certain rules), such as coding sequences A20250001, A20250002,..., A20259999, where the first 5 digits are fixed values and the last 4 digits are variable values and other similar specific sequences. The codeword information is arranged in the format of data codeword + error correction codeword in sequence, as Figure 1 shown, the method includes:

[0041] Step 100, replacing the data codeword in the first codeword of the target QR code according to the global variable saved during the previous successful decoding to obtain a second codeword;

[0042] In some embodiments, replacing the data codeword in the first codeword of the target QR code is usually performed when the error correction of the first codeword fails. When replacing the data codeword in the first codeword of the target QR code, the number of codewords replaced each time can be set according to actual needs. For example, it can be set to replace one codeword each time. QR codes usually have certain rules, such as Figure 2 shown, which exemplarily shows an arrangement rule of a QR code, Figure 2The 18x18 version of the DM code shown in [description], which has 18 data codewords and 14 error correction codewords. The positions of the data codewords are from 1.1 to 18.8, and the positions of the error correction codewords are from 19.1 to 32.8. When using two-dimensional codes in an industrial environment, for the same series of products, the product serial numbers often have a specific string that remains unchanged during encoding, and other strings increase sequentially. Therefore, in this embodiment, by using the method of replacing codewords, the correct codewords can be obtained quickly. For example, Figure 3 exemplarily shows that the decoding result of the previously recognized two-dimensional code is 081000201170001469217160015, and the data codewords are 138, 140, 130, 150, 141, 200, 130, 144, 199, 151, 201, 190, 131, 54, 254, 129, 133, 28. After the previous successful decoding, these 18 data codewords are saved in the global variable; while Figure 4 exemplarily shows the currently recognized two-dimensional code. Since the two-dimensional code is blurred, its sampling result will be inaccurate, making it difficult to correct errors and decode. The sampling result is 138, 140, 130, 150, 141, 200, 138, 152, 223, 151, 201, 190, 131, 51, 254, 129, 133, 28, 24, 189, 22, 252, 219, 124, 174, 206, 174, 179, 28, 208, 78, 243. Among them, there are 9 sampling error codewords, exceeding the error correction ability, and 3 data codeword errors, corresponding to Figure 3 7.1 to 7.8, 8.1 to 8.7, and 9.1 to 9.8 in [description] respectively, and 6 error correction codeword errors, corresponding to Figure 3 20.1 to 20.8, 21.1 to 21.8, 22.1 to 22.8, 23.1 to 23.8, 31.1 to 31.8, and 32.1 to 32.8 in [description] respectively. At this time, only need to compare the data codewords in the global variable with the sampled data codewords, and replace the positions with inconsistent results with the data codewords in the global variable. The error correction codewords need to verify and correct the replaced data codewords. Therefore, the error correction codewords cannot be replaced.

[0043] Step 200, use an error correction algorithm to correct errors in the second codeword;

[0044] In some embodiments, the error correction algorithm may be an error correction algorithm in the prior art, such as the RS error correction algorithm. The error correction algorithm is generally used to detect codeword errors and correct the incorrect codewords. For the error correction algorithm, there is a specified upper limit on the allowable incorrect codewords, that is, the error correction ability has an upper limit. When there are situations such as wear, missing, stains, and blurring, it is easy to cause the number of incorrect codewords to be greater than the error correction ability and unable to decode. However, the replaced second codeword may satisfy the error correction ability of the error correction algorithm. Therefore, in this embodiment, the second codeword is error-corrected. Exemplarily, for example, after replacing the data codewords of the two-dimensional code in Figure 4 , the number of incorrect codewords is 7, just reaching the maximum error correction ability. The replaced codewords are 138, 140, 130, 150, 141, 200, 130, 144, 223, 151, 201, 190, 131, 51, 254, 129, 133, 28, 24, 189, 22, 252, 219, 124, 174, 206, 174, 179, 28, 208, 78, 243. At this time, by error-correcting the second codeword again, the correct codewords can be obtained as 138, 140, 130, 150, 141, 200, 130, 144, 199, 151, 201, 190, 131, 51, 254, 129, 133, 28, 24, 184, 20, 236, 27, 124, 174, 206, 174, 179, 28, 208, 74, 115.

[0045] Step 300, when the error correction of the second codeword is successful, decode the error-corrected second codeword and save the data codewords in the error-corrected second codeword to a global variable.

[0046] In some embodiments, after the error correction of the second codeword is successful, it means that the correct codewords corresponding to the two-dimensional code are obtained. At this time, by decoding the error-corrected second codeword, the correct information contained in the two-dimensional code can be obtained. For example, after error-correcting the second codeword corresponding to Figure 4 , and then decoding, the decoding result is obtained as 081000201170001469217160012.

[0047] In the technical solution provided by the embodiments of the present invention, based on the industrial environment, the two-dimensional codes printed on products generally have product serial numbers, and the serial numbers contain specific sequences to distinguish different models and different series. There are few cases where meaningless random numbers are used as the product two-dimensional code encoding. During the decoding process, if a decoding failure occurs, the data codewords saved during the previous successful decoding are used to replace the data codewords of the current two-dimensional code, so that the second codeword can quickly and stably satisfy the error correction ability of the error correction algorithm, thereby effectively improving the decoding rate and decoding stability in complex environments.

[0048] As an alternative implementation, in step 100, replacing the data codewords in the first codeword of the target QR code according to the global variables saved during the previous successful decoding to obtain a second codeword includes:

[0049] Comparing the data codewords of the first codeword with the global variables to obtain the codewords to be replaced in the data codewords of the first codeword that are different from those in the global variables;

[0050] In some embodiments, such as Figure 3 and Figure 4 the codewords sampled from the QR code, Figure 3 after the sampled codewords are correctly decoded, save their data codewords as global variables, compare the codewords in the global variables with Figure 4 the data codewords in the first codeword. When the codewords at the same position are different, determine the codeword at this position in the data codewords of the first codeword as the codeword to be replaced. After comparison, it is found that Figure 4 there are 3 different codewords in the data codewords of the first codeword and those in the global variables. During the replacement process, replace the codewords in the global variables to the Figure 4 same positions of the codewords to be replaced.

[0051] According to a preset quantity, use the codewords at the corresponding positions in the global variables to replace the codewords to be replaced to obtain the second codeword.

[0052] In some embodiments, the preset quantity can be set according to empirical values or according to the codeword length.

[0053] As an alternative implementation, in step 200, after correcting the errors of the second codeword using the error correction algorithm, the method further includes:

[0054] When the error correction of the second codeword fails, determine whether all the codewords to be replaced have been replaced;

[0055] In some embodiments, since a preset quantity of codewords are replaced each time, when the number of codewords to be replaced is greater than the preset quantity, it is difficult to complete all replacements at one time. Therefore, when the error correction of the second codeword fails, it is necessary to determine whether the codewords to be replaced have been completely replaced.

[0056] When all the codewords to be replaced have been replaced, end the recognition of the target QR code;

[0057] In some embodiments, when all the codewords to be replaced have been replaced but the error correction still fails, at this time, it is difficult to complete the decoding, so end the recognition of the QR code.

[0058] When the codewords to be replaced are not all replaced, return the step of replacing the codewords to be replaced with the codewords at the corresponding positions in the global variable according to the preset quantity to obtain the second codeword.

[0059] In some embodiments, when the codewords to be replaced have not been all replaced, continue to replace the codewords to be replaced. After the replacement is completed, attempt error correction again. That is, the replacement of the codewords to be replaced can be performed multiple times, with a preset quantity of codewords replaced each time, until the two-dimensional code is successfully decoded or error correction still fails after the replacement is completed.

[0060] As an alternative implementation, in step 100, before replacing the data codewords in the first codeword of the target two-dimensional code with the global variable saved when the previous successful decoding was performed to obtain the second codeword, the method further includes:

[0061] Sample the target two-dimensional code to obtain the first codeword corresponding to the target two-dimensional code;

[0062] Perform error correction on the first codeword using the error correction algorithm;

[0063] When error correction on the first codeword fails, perform the step of replacing the data codewords in the first codeword of the target two-dimensional code with the global variable saved when the previous successful decoding was performed to obtain the second codeword; the version of the target two-dimensional code is the same as that of the two-dimensional code decoded successfully last time.

[0064] In some embodiments, after sampling the two-dimensional code, usually error correction is first performed to determine whether the two-dimensional code can be correctly recognized. If it can be correctly recognized, decoding can be directly completed. If it cannot be correctly recognized, codeword replacement is required for recognition.

[0065] As an alternative implementation, after performing error correction on the first codeword using the error correction algorithm, the method further includes:

[0066] When error correction on the first codeword is successful, decode the error-corrected first codeword and save the data codewords in the error-corrected first codeword to the global variable.

[0067] In some embodiments, if error correction on the first codeword is successful, it indicates that the two-dimensional code can be successfully recognized. At this time, save the data codewords in the error-corrected first codeword as the global variable to provide replaceable codewords for subsequent two-dimensional codes that cannot be successfully recognized.

[0068] As an alternative implementation, the sampling the target two-dimensional code to obtain the first codeword corresponding to the target two-dimensional code includes:

[0069] Obtain the codeword information in the target two-dimensional code, and arrange the codeword information into data codewords and error correction codewords according to a preset arrangement rule to obtain the first codeword.

[0070] As an optional implementation manner, the decoding of the second codeword after error correction includes: decoding the second codeword after error correction into a string according to a preset decoding rule.

[0071] An embodiment of the present invention further provides a device for improving the decoding rate of a two-dimensional code, including:

[0072] A data codeword filling module, configured to replace the data codewords in the first codeword of the target two-dimensional code according to the global variables saved during the previous successful decoding to obtain a second codeword;

[0073] An error correction module, configured to perform error correction on the second codeword by using an error correction algorithm;

[0074] A decoding module, configured to, when the error correction of the second codeword is successful, decode the second codeword after error correction and save the data codewords in the second codeword after error correction as global variables.

[0075] As Figure 5 shown, an exemplary data processing flow during the use of the device for improving the decoding rate of a two-dimensional code is shown. In Figure 5 it, an exemplary display is made by using the method of replacing all the codewords to be replaced at one time, specifically as follows:

[0076] Sample the two-dimensional code to obtain a first codeword.

[0077] Perform error correction on the first codeword. If the error correction is successful, directly perform decoding to obtain the information contained in the two-dimensional code. In order to provide codewords that can be used for replacement in the subsequent two-dimensional code decoding process, save the data codewords in the first codeword after error correction to global variables;

[0078] If the error correction of the first codeword fails, use the data codeword filling module to identify and replace the codewords to be replaced. After completing the codeword replacement, form a second codeword.

[0079] Subsequently, perform error correction on the second codeword. If the error correction is successful, directly perform decoding to obtain the information contained in the two-dimensional code. In order to provide codewords that can be used for replacement in the subsequent two-dimensional code decoding process, save the data codewords in the second codeword after error correction to global variables;

[0080] If the error correction of the second codeword fails, end the recognition of the two-dimensional code.

[0081] It should be noted that the foregoing embodiments are processed by replacing all the codewords to be replaced at one time. Therefore, the failure of the second codeword error correction directly ends the recognition of the two-dimensional code. If the method of replacing the codewords to be replaced multiple times is adopted, that is, when the preset number is less than the number of codewords to be replaced, when the error correction fails, if all the codewords to be replaced have not been replaced, it is necessary to continue to use the data codeword filling module to replace the codewords.

[0082] An embodiment of the present invention further provides a user equipment, where the user equipment includes:

[0083] at least one processor; and

[0084] a memory communicatively connected to the at least one processor; wherein,

[0085] the memory stores instructions executable by the at least one processor, and when the instructions are executed by the at least one processor, the at least one processor is enabled to execute the method for improving the decoding rate of the two-dimensional code as described in any one of the foregoing items.

[0086] An embodiment of the present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and when the computer instructions are executed by a processor, the method for improving the decoding rate of the two-dimensional code as described in any one of the foregoing items is implemented.

[0087] Those of ordinary skill in the art can understand that all or part of the processes in the above method embodiments can be completed by instructing relevant hardware through a computer program. The program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the above method embodiments. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM), etc.

[0088] The above is only the specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by those skilled in the art within the technical scope disclosed by the present invention should be covered by the protection scope of the present invention. Therefore, the protection scope of the present invention should be subject to the protection scope of the claims.

Claims

1. A method for improving a two-dimensional code decoding rate, characterized in that: The method comprises: According to the global variable saved during the previous successful decoding, the data codeword in the first codeword of the target two-dimensional code is replaced to obtain the second codeword; performing error correction on the second codeword using an error correction algorithm; When the error correction of the second codeword is successful, the second codeword after the error correction is decoded and the data codeword in the second codeword after the error correction is saved to a global variable.

2. The method according to claim 1, characterized in that The step of replacing the data codeword in the first codeword of the target two-dimensional code according to the global variable saved during the previous successful decoding to obtain the second codeword includes: Comparing the data codeword of the first codeword with the global variable to obtain a codeword to be replaced that is different from the data codeword of the first codeword and the global variable; According to a preset number, the codeword to be replaced is replaced with the codeword at the corresponding position in the global variable to obtain the second codeword.

3. The method according to claim 2, characterized in that After the error correction of the second codeword by using the error correction algorithm, the method further includes: When error correction of the second codeword fails, determining whether all the codewords to be replaced have been replaced; When all the code words to be replaced are replaced, the recognition of the target two-dimensional code is terminated; When the code words to be replaced have not all been replaced, returning to the step of replacing the code words to be replaced with code words at corresponding positions in the global variable according to the preset number to obtain the second code word.

4. The method according to claim 1, characterized in that: Before replacing the data codeword in the first codeword of the target two-dimensional code according to the global variable saved during the previous successful decoding to obtain the second codeword, the method further includes: Sampling the target two-dimensional code to obtain the first codeword corresponding to the target two-dimensional code; Performing error correction on the first codeword using the error correction algorithm; When the error correction of the first codeword fails, the step of replacing the data codeword in the first codeword of the target two-dimensional code according to the global variable saved during the previous successful decoding to obtain the second codeword is executed; the version of the target two-dimensional code is the same as the two-dimensional code successfully decoded last time.

5. The method according to claim 4, characterized in that After correcting the first codeword using the error correction algorithm, the method further includes: When the error correction of the first codeword is successful, the first codeword after the error correction is decoded and the data codeword in the first codeword after the error correction is saved to the global variable.

6. The method according to claim 4, characterized in that The sampling of the target two-dimensional code to obtain the first codeword corresponding to the target two-dimensional code includes: The codeword information in the target two-dimensional code is obtained, and the codeword information is arranged into data codewords and error correction codewords according to a preset arrangement rule to obtain the first codeword.

7. The method according to claim 1, characterized in that The decoding of the second codeword after error correction includes: decoding the second codeword after error correction into a character string according to a preset decoding rule.

8. A device for improving the decoding rate of a two-dimensional code, characterized in that: include: A data codeword filling module is used to replace the data codeword in the first codeword of the target two-dimensional code according to the global variable saved during the previous successful decoding to obtain a second codeword; An error correction module, configured to perform error correction on the second codeword using an error correction algorithm; A decoding module is used for decoding the second codeword after error correction and saving the data codeword in the second codeword after error correction as a global variable when the second codeword is successfully corrected.

9. A user equipment, characterized in that: The user equipment comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method for improving the two-dimensional code decoding rate as described in any one of claims 1-7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and when the computer instructions are executed by a processor, the method for improving the decoding rate of a two-dimensional code as described in any one of claims 1 to 7 is implemented.