RS error correction decoding method and system compatible with multiple two-dimensional codes

By defining and using finite domain and modulus value correspondence tables, combining image sensors and RS error correction algorithms, the problems of high complexity and poor adaptability of RS code encoding and decoding methods in the prior art are solved, and efficient and flexible QR code RS error correction decoding is achieved.

CN119903862APending Publication Date: 2025-04-29NEWLAND YOUMAIJIE (GUANGDONG PROVINCE) TECHNOLOGY CO LTD

Patent Information

Application Number
CN202411974169.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-30
Publication Date
2025-04-29

AI Technical Summary

Technical Problem

The existing RS code encoding and decoding methods are highly complex when processing multiple QR codes, and it is difficult to adapt to the differences between different QR code standards and finite domains, resulting in insufficient decoding efficiency and fault tolerance.

Method used

By defining the finite domain and modulo value correspondence table, a power table is generated and a corresponding relationship table between power and data is constructed, which is stored in the configuration management module. The QR code data is obtained using image sensors, and error detection and correction are performed based on the power data corresponding table, including calculating the companion formula, using the Berlekamp-Massey algorithm, the Chien search algorithm and the Forney algorithm.

Benefits of technology

RS error correction decoding is realized that is compatible with multiple QR codes, which improves decoding speed and efficiency, enhances error correction capabilities, and can correctly decode damaged QR codes without losing information.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119903862A_ABST
    Figure CN119903862A_ABST
Patent Text Reader

Abstract

According to the RS error correction decoding method and system compatible with the multiple two-dimensional codes, a finite field and module value corresponding table is defined, a corresponding relation table between power and data is constructed, and the decoding requirements of the multiple two-dimensional code types are met. The method comprises the following steps: acquiring image data by using an image sensor, extracting two-dimensional code data, and converting the two-dimensional code data into a data code word stream; and performing error detection and correction on the two-dimensional code data based on a preset power data corresponding table, including judging whether an error exists or not by calculating a syndrome, if an error is detected, calculating an error position polynomial by using a Berlekamp-Massey algorithm, then positioning an error position by using a Chien search algorithm, and finally calculating an error value by using a Forne algorithm and performing correction. According to the method, the decoding efficiency and the fault-tolerant capability of the two-dimensional code are remarkably improved, the method is suitable for various standards, and especially when the two-dimensional code is partially damaged or an error occurs in data transmission, the original coding information can be effectively recovered.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of RS error correction codes, and mainly to a RS error correction decoding method and system compatible with multiple two-dimensional codes. Background Art

[0002] As a classic error correction coding technology, RS code has been widely used in two-dimensional code systems. RS code can detect and correct a certain number of errors during data transmission or storage by inserting redundant information into the data. However, the traditional RS code encoding and decoding method has certain complexity in the implementation process, especially the multiplication and addition operations on the finite field, which require a lot of computing resources, limiting the speed and efficiency of encoding and decoding.

[0003] In this context, for example, a Chinese invention patent with a publication number of CN1303763C discloses a method for reducing the complexity of RS code encoding and decoding, which belongs to the field of RS code technology. Its main feature is that when encoding at the transmitting end, the code element of the RS code is represented by the power of the primitive domain element a, and all code words are on the finite field GF (2^m). This method avoids complex finite field operations by representing the non-zero elements on the finite field GF (2^m) as integer powers of the primitive domain element a, and simplifies multiplication and division operations through symbolic representation. For example, for any two elements X and Y, the multiplication of X and Y can be achieved by exponential addition, and the division of X and Y is achieved by exponential subtraction. In addition, addition and subtraction operations are implemented by table lookup. The method described in the invention significantly reduces the complexity of RS code encoding and decoding, improves the encoding and decoding efficiency, and maintains the same error correction performance as the existing method. However, the invention mainly optimizes the traditional RS code encoding and decoding process, and does not consider the diversity of two-dimensional codes. In practical applications, the standards and formats of QR codes are diverse, and different standards have different implementation methods and parameter requirements for RS codes. In addition, since different QR code standards may use different finite fields or module values, the method described in this invention is not flexible enough in dealing with these differences. Therefore, there is an urgent need for an RS error correction decoding method that is compatible with multiple QR codes and can improve the decoding efficiency and fault tolerance of QR codes. Summary of the invention

[0004] In order to solve the above-mentioned problems existing in the prior art, the present application provides a RS error correction decoding method and system that is compatible with multiple two-dimensional codes.

[0005] The technical solution of this application is as follows:

[0006] A RS error correction decoding method compatible with multiple two-dimensional codes, the method comprising:

[0007] Define a finite field and module value correspondence table based on the two-dimensional code type required by the user, generate a power table of finite field elements according to the module value of the finite field, construct a corresponding relationship table between the power and data based on the power table, and store the power data correspondence table in the configuration management module;

[0008] Acquire image data using an image sensor, and extract QR code data from the image data;

[0009] Error detection and correction are performed on the two-dimensional code data based on the power data correspondence table to obtain original coding information.

[0010] As a preferred embodiment of the present invention, extracting the two-dimensional code data from the image data is specifically as follows:

[0011] Scan the image data by full scanning to obtain a corresponding QR code identifier, and determine the type and position of the QR code based on the QR code identifier;

[0012] Convert the image data into a grayscale image, and convert the grayscale image into a binary image using a threshold algorithm to obtain a corresponding black and white array image;

[0013] Based on the type and position of the two-dimensional code, the bit stream arrangement order of the corresponding coding standard is determined, and the data bit stream is extracted row by row or column by column from the black and white array diagram, and the data bit stream is converted into a finite field codeword to obtain the two-dimensional code data, that is, the data codeword stream.

[0014] As a preferred implementation of the present invention, error detection and correction are performed on the two-dimensional code data based on the power data correspondence table, specifically:

[0015] Calculate the corresponding syndrome according to the data codeword stream, and determine whether there is an error based on the syndrome coefficient. If there is an error, calculate the error position polynomial using the Berlekamp-Massey algorithm;

[0016] The Chien search algorithm is used to find the error position, and the Forney algorithm is used to calculate the error value. The errors in the data block are corrected according to the error position and error value.

[0017] As a preferred implementation of the present invention, the corresponding syndrome is calculated according to the data codeword stream, and whether there is an error is determined based on the syndrome coefficient as follows:

[0018] The received data codeword stream is regarded as a polynomial R(x), which can be expressed as:

[0019] R(x)=r0+r1x+r2x 2 +r3x 3 +......+r (n-1) x (n-1) ;

[0020] In the formula, r0, r1, r2, r3, ..., r (n-1) is the value of the data codeword stream; n is the length of the codeword;

[0021] The adjoint polynomial is obtained by dividing the polynomial R(x) by the remainder of the generator polynomial. The adjoint polynomial S(x) is expressed as:

[0022]

[0023] in:

[0024]

[0025] s1=r0+r12+r22 2 +r32 3 +......+r (n-1) 2 (n-1) ;

[0026] s2=r0+r1(2 2 )+r2(2 2 ) 2 +r3(2 2 ) 3 +......+r (n-1) (2 2 ) (n-1) ;

[0027] s3=r0+r1(2 3 )+r2(2 3 ) 2 +r3(2 3 ) 3 +......+r (n-1) (2 3 ) (n-1) ;

[0028] ……;

[0029] s 2t =r0+r1(2 2t )+r2(2 2t ) 2 +r3(2 2t ) 3 +......+r (n-1) (2 2t ) (n-1) ;

[0030] In the formula, x is a variable, t is the error correction capability, and s i is the i-th coefficient of the syndrome;

[0031] If the syndrome coefficient s i If all are 0, it means that there is no error in the received data codeword stream, the decoding process ends, and the data block is output; if the syndrome coefficients are not all 0, it means that there is an error in the received codeword data codeword stream, and correction is performed;

[0032] The storage start address of the syndrome coefficient is determined according to the type of the two-dimensional code, and when judging whether an error exists based on the syndrome coefficient, the syndrome coefficient is read from the storage start address.

[0033] As a preferred embodiment of the present invention, when calculating the syndrome polynomial, each element in the data codeword stream is mapped to its corresponding power, that is, the syndrome coefficient s by searching the power data corresponding table stored in the configuration management module. i The subscript i of corresponds directly to the i-th power of the primitive elements of the finite field.

[0034] As a preferred implementation of the present invention, the error position polynomial is calculated by the Berlekamp-Massey algorithm as follows:

[0035] Initial parameters are set, including initial error position polynomial L(x)=1; initial difference polynomial △(x)=0; initial iteration number j=0; initial record polynomial ∧(x)=1;

[0036] For each iteration j, the difference polynomial is updated, expressed as:

[0037]

[0038] In the formula, r k is the coefficient of the received data codeword stream; k is the position in the currently processed data codeword stream; The coefficients of the record polynomial obtained in the previous iteration;

[0039] Determine whether the difference polynomial △(x) is 0. If △(x)=0, keep the current record polynomial ∧(x) unchanged, update the number of iterations j=j+1, and continue the next round of iterations; if △(x)≠0, update the record polynomial ∧(x), expressed as:

[0040]

[0041] Where, L (j-1) is the order of the error position polynomial obtained in the previous iteration;

[0042] Update the order of the error location polynomial L(x), expressed as:

[0043] L (j) =max(L (j-1),jL (j-1) );

[0044] When the number of iterations j reaches the error correction capability t, the iteration is stopped and the final record polynomial ∧(x) is the error position polynomial.

[0045] As a preferred implementation of the present invention, the Chien search algorithm is used to find the error location specifically as follows:

[0046] Set the search variable x of the error position polynomial, i.e. the final record polynomial Λ(x) to 1;

[0047] Based on the power data corresponding table stored in the configuration management module, all values ​​are traversed in the finite field, each value is substituted into the error position polynomial, and the error position polynomial is checked to see if it is zero. If the error position polynomial is zero, the corresponding variable is the error position, where each value is substituted into the error position polynomial to express the formula as follows:

[0048]

[0049] In the formula, α i is the i-th power of the primitive element α of the finite field, ∧ j' are the coefficients of the error location polynomial, and L is the order of the error location polynomial.

[0050] As a preferred implementation of the present invention, the error value is calculated by the Forney algorithm, and the error in the data block is corrected according to the error position and the error value as follows:

[0051] The error value polynomial Ω(x) is calculated by the adjoint polynomial S(x) and the error location polynomial ∧(x), which can be expressed as:

[0052] Ω(x)=S(x)·∧(x)mod x 2t ;

[0053] Calculate the derivative of the error location polynomial ∧(x), expressed as:

[0054]

[0055] For each error position α i Calculate the error value e i , expressed as:

[0056]

[0057] According to each error position and the corresponding error value, error correction is performed by subtracting the error value from the original data codeword stream to restore the original encoded information.

[0058] The present invention also provides a RS error correction decoding system compatible with multiple two-dimensional codes, the system comprising a configuration management module, an image acquisition module, a two-dimensional code extraction module and an error correction decoding module, wherein:

[0059] The configuration management module stores a power data correspondence table, and the construction of the power data correspondence table is specifically as follows: based on the two-dimensional code type required by the user, a finite field and a module value correspondence table is defined, a power table of finite field elements is generated according to the module value of the finite field, and a corresponding relationship table between power and data is constructed based on the power table;

[0060] The image acquisition module acquires image data using an image sensor;

[0061] The two-dimensional code extraction module extracts the two-dimensional code data from the image data;

[0062] The error correction decoding module performs error detection and correction on the two-dimensional code data based on the power data correspondence table to obtain original coding information, wherein the error detection and correction on the two-dimensional code data based on the power data correspondence table is specifically:

[0063] Calculate the corresponding syndrome according to the data codeword stream, and determine whether there is an error based on the syndrome coefficient. If there is an error, calculate the error position polynomial using the Berlekamp-Massey algorithm;

[0064] The Chien search algorithm is used to find the error position, and the Forney algorithm is used to calculate the error value. The errors in the data block are corrected according to the error position and error value.

[0065] The present invention also provides 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, an RS error correction decoding method compatible with a plurality of two-dimensional codes as described in any embodiment of the present invention is implemented.

[0066] Compared with the prior art, the present invention has the following beneficial effects:

[0067] 1) The present invention provides a RS error correction decoding method and system compatible with multiple two-dimensional codes, which can adapt to different two-dimensional code types and standards by defining different finite fields and module values, and has wide applicability;

[0068] 2) The present invention provides a RS error correction decoding method and system compatible with multiple two-dimensional codes, which accelerates the calculation in the error correction decoding process and improves the decoding speed and efficiency through a pre-constructed power data correspondence table;

[0069] 3) The present invention provides a RS error correction decoding method and system that is compatible with multiple two-dimensional codes. Through the RS error correction code, the two-dimensional code can tolerate a certain proportion of errors or damages, so that it can be correctly decoded without losing information. BRIEF DESCRIPTION OF THE DRAWINGS

[0070] Figure 1 It is a flow chart of a method according to an embodiment of the present invention. DETAILED DESCRIPTION

[0071] The specific implementation modes of the present invention are described below so that those skilled in the art can understand the present invention. However, it should be clear that the present invention is not limited to the scope of the specific implementation modes. For those of ordinary skill in the art, as long as various changes are within the spirit and scope of the present invention as defined and determined by the attached claims, these changes are obvious, and all inventions and creations utilizing the concept of the present invention are protected.

[0072] The present invention provides the following technical solution: a RS error correction decoding method and system compatible with multiple two-dimensional codes.

[0073] Embodiment 1:

[0074] This embodiment provides a RS error correction decoding method compatible with multiple two-dimensional codes, the method comprising:

[0075] S1. Define a finite field and module value correspondence table based on the two-dimensional code type required by the user, generate a power table of finite field elements according to the module value of the finite field, construct a correspondence table between the power and data based on the power table, and store the power data correspondence table in the configuration management module;

[0076] S11. In this embodiment, the two-dimensional code types include DM code, QR code, Hanxin code and AZTEC code. It is worth noting that the two-dimensional code types in step S1 are not limited to the DM code, QR code, Hanxin code and AZTEC code in this embodiment, but are any encoding methods that meet the basic characteristics of the two-dimensional code. The four types of two-dimensional codes in this embodiment are only for illustration;

[0077] In DM code, QR code, Hanxin code and AZTEC code, each two-dimensional code uses a different finite field, which is used to define the basic mathematical structure of polynomial arithmetic and error correction coding;

[0078] Because the error correction mechanisms of DM code, QR code, Hanxin code and AZTEC code are all based on RS error correction code, and the finite field used by RS error correction algorithm is Galois field GF (2 m ), where m is a positive integer, indicating the number of times the domain is expanded, which determines the number of elements in the domain. For example, when m = 1, GF(2 1) contains two elements: 0 and 1; when m = 2, GF(2 2 ) contains four elements; when m = 8, GF(2 8 ) contains 256 elements, corresponding to a byte (8 bits) in a computer; therefore, the use of finite fields in DM code, QR code, Hanxin code, and AZTEC code is also based on GF(2 m );

[0079] Furthermore, due to GF(2 8 ) is consistent with the byte size in the computer, which is convenient for processing and storage, so GF(2 8 ) is the most commonly used finite field, which is widely used in various barcode systems such as QR code, Data Matrix code, Hanxin code and AZTEC code. In this embodiment, DM code, QR code, Hanxin code and AZTEC code also use GF(2 8 ) as a finite field. Preferably, different m can be selected according to the error correction requirements and different data lengths. For example, the Hanxin code includes functional information error correction and data block error correction. The Hanxin code functional information finite field selects GF(2 4 ), and the Hanxin code data selects GF(2 8 ), AZTEC code includes pattern information error correction and data block error correction. The pattern information of AZTEC code selects GF(2 4 ), the data block includes four types of finite field data, namely GF(2 6 )、GF(2 8 )、GF(2 10 ) and GF(2 12 ). In summary, in this embodiment, the finite field of the DM code is 256, the finite field of the QR code is 256, the finite field of the Hanxin code data block is 256, the finite field of the Hanxin code function information is 16, the finite field of the AZTEC code mode information is 16, the finite field of the AZTEC code data block 1 is 64, the finite field of the AZTEC code data block 2 is 256, the finite field of the AZTEC code data block 3 is 1024, and the finite field of the AZTEC code data block 4 is 4096;

[0080] The value of the field element, that is, the modulus value, is obtained by calculating the primitive polynomial corresponding to the finite field. Specifically, in this embodiment:

[0081] The primitive polynomial of DM code is chosen as p(x)=x 8 +x 5 +x 3 +x 2 +1, primitive element α = 2, the modulus value corresponding to the primitive polynomial = 100101101 = 301;

[0082] The primitive polynomial of QR code is chosen as p(x) = x8 +x 4 +x 3 +x 2 +1, primitive element α=2, modulus=100011101=285;

[0083] The primitive polynomial of the Hanxin code data block is selected as p(x)=x 8 +x 6 +x 5 +x 1 +1, primitive element α=2, modulus=101100011=355;

[0084] The primitive polynomial of Hanxin code functional information chooses p(x)=x 4 +x+1, primitive element α=2, modulus value=000010011=19;

[0085] The primitive polynomial of the AZTEC code pattern information is selected as p(x)=x 4 +x+1, primitive element α=2, modulus value=000010011=19;

[0086] The primitive polynomial of AZTEC code data block 1 is p(x)=x 6 +x+1, primitive element α=2, modulus value=001000011=67;

[0087] The primitive polynomial of AZTEC code data block 2 is selected as p(x)=x 8 +x 5 +x 3 +x 2 +1, primitive element α = 2, the modulus value corresponding to the primitive polynomial = 100101101 = 301;

[0088] The primitive polynomial of AZTEC code data block 3 is selected as p(x)=x 10 +x 3 +1, primitive element α = 2, the modulus value corresponding to the primitive polynomial = 10000001001 = 1033;

[0089] The primitive polynomial of AZTEC code data block 4 is selected as p(x)=x 12 +x 6 +x 5 +x 3 +1, primitive element α=2, the modulus value corresponding to the primitive polynomial=1000001100001=4201.

[0090] Summarizing the above finite fields and module values, we obtain the corresponding table of finite fields and module values ​​as shown in Table 1:

[0091] Table 1 Finite field and module value correspondence table

[0092]

[0093] It should be noted that Table 1 does not include all finite fields and modulus values, but is only an example. The predefined finite field and modulus value correspondence table in step S1 includes finite fields and modulus values ​​of all QR code types;

[0094] S12. The power data corresponding table is generated based on the finite field and the modulus value, and records the power representation of each element in the finite field, including an exponential table and a logarithmic table. The exponential table stores the exponential form of each element in the finite field, and the logarithmic table stores the logarithmic form of each element in the finite field.

[0095] S2, acquiring image data using an image sensor, and extracting QR code data from the image data;

[0096] S21. The first step of decoding the two-dimensional code is to obtain image data from an image sensor (such as CMOS or CCD). The information of the two-dimensional code is represented by black and white modules in the image, so it is necessary to obtain the image for subsequent processing; preferably, in order to decode the two-dimensional code in real time, the image sensor is selected based on the ability to quickly obtain image data;

[0097] S22. Since the QR code may appear at any position in the image, the entire image needs to be scanned. Scanning the image pixel by pixel to find the identifier of the QR code is essentially to find features that match the identifier. Different types of QR codes have different identifiers. For example, the QR code identification identifier specifically finds three positioning points (bull's eyes) in the QR code. These three points are arranged in a square and are used to determine the direction and position of the QR code; the DM code identification identifier specifically finds the L mark, which is used to locate the upper left and upper right corners of the QR code; other QR codes are identified according to the special identifier of each QR code; the type and position of the QR code can be determined by identifying these identifiers;

[0098] S23, converting the color image of the image data into a grayscale image (if the original image is in color), because the two-dimensional code is composed of black and white modules, and the black and white modules of the two-dimensional code also show obvious brightness differences in the grayscale image, but the grayscale image contains too much information, and it is necessary to simplify it into a binary image (black and white image) to remove unnecessary details. Specifically, a threshold algorithm (such as a global threshold or an adaptive threshold) is used to convert the grayscale image into a binary image. The selection of the threshold depends on the brightness and contrast of the image, and a black and white array image is obtained, in which black pixels represent the black modules of the two-dimensional code, and white pixels represent the white modules of the two-dimensional code;

[0099] S231. Preferably, in practical applications, the two-dimensional code may be perspectively deformed (such as tilted, rotated, and scaled) due to shooting angles, lens distortion, and the like. This embodiment further performs perspective correction on the image data. The purpose of the perspective correction is to restore the deformed two-dimensional code image to a standard shape (usually a square or a rectangle), and the position information of the two-dimensional code (especially the coordinates of the positioning points) provides necessary information for perspective correction. Through these coordinates, the perspective transformation matrix can be calculated to correct the image. Specifically:

[0100] Through the known position of the QR code, the coordinates of the positioning points (such as the coordinates of the three bull's eyes of the QR code) are extracted; according to the coordinates of the positioning points, the perspective transformation matrix is ​​calculated, and the calculation formula depends on the selected perspective transformation algorithm; the perspective transformation matrix is ​​applied to the whole image or the QR code area to generate the corrected image data; the color image converted into the grayscale image is actually the image data that has been corrected;

[0101] S24. The data of the two-dimensional code is arranged according to a specific coding standard, and the data bit stream needs to be extracted in a standard order. Because different types of two-dimensional codes (such as QR codes, DM codes, Data Matrix codes, etc.) have different data arrangement orders, these orders are usually defined based on the geometric structure of the two-dimensional code (such as the location of the positioning points, the module layout). Therefore, through the position information of the two-dimensional code, the direction and layout of the two-dimensional code can be determined, so as to correctly decode the data bit stream; specifically, according to the coding standard of the two-dimensional code (such as the bit stream arrangement order of the QR code), the data bit stream is extracted row by row or column by column from the black and white array diagram, and each data bit corresponds to a module (black or white), black is 1, and white is 0;

[0102] S25. The data bit stream in the QR code is binary, but the RS error correction algorithm needs to represent the data as a finite field (such as GF(2 8 )) codewords, so it is necessary to convert them. Specifically, the extracted binary data bit stream is grouped into 8 bits (or according to the modulus value of the finite field, such as GF(2 8 ) is converted into a code word. For example, the data bit stream extracted from the black and white array is: 10101010 11001100…, which is converted into GF(2 8 )) in the codeword: D0 = 10101010, D1 = 11001100, ...; Based on the above conversion, the data codeword stream GF (a m ), including D0 D1 D2 D3..., each code word is mbit.

[0103] S3. Perform error detection and correction on the two-dimensional code data based on the power data correspondence table to obtain original coding information:

[0104] S31, calculating the corresponding syndrome according to the data codeword stream, and judging whether there is an error based on the syndrome coefficient;

[0105] The full name of the RS error correction algorithm is Reed-Solomon coding. It is a powerful error correction code algorithm, mainly used for error detection and correction in data transmission and storage.

[0106] The goal of RS coding is to expand the original information (length k) into a longer codeword (length n), which contains redundant information (check symbols) to support error detection and correction. Furthermore, in the encoding process, the generator polynomial G(x) is the core tool for generating check symbols; the codeword polynomial C(x) is the polynomial representation of the final generated codeword. The goal of decoding is to recover the original information from the received codeword that may have errors. The decoding process includes error detection and error correction. In the decoding process, the codeword polynomial C(x) is the polynomial representation of the received codeword, and the generator polynomial G(x) is used to assist in error detection and correction.

[0107] Furthermore, the RS encoding steps are as follows:

[0108] Define the original information polynomial M(x), expressed as:

[0109] M(x)=m0+m1x+m2x+...+m k'-1 x k'-1 ;

[0110] Where m0, m1, m2, ..., m k'-1 are k' symbols of the original information; x is a variable;

[0111] In order to generate the check symbol, M(x) is shifted left by n-k' bits to obtain the extended information polynomial M(x)·x n-k ', expressed as:

[0112] M(x)·x n-k' =m0x n-k' +m1x n-k'+1 +…+m k'-1 x n-1 ;

[0113] The generating polynomial G(x) is used to check the symbol and is expressed as:

[0114]

[0115] Where t is the error correction capability (the number of errors that can be corrected), α i is the i-th power of the primitive element of the finite field, x is a variable, and n is the length of the codeword;

[0116] Extend the information polynomial M(x)·x n-k' Divide by the generator polynomial G(x) to get the remainder polynomial Y(x), the degree of the remainder polynomial Y(x) is less than n-k', expressed as:

[0117] Y(x)=y0+y1x+y2x 2 +...+y n-k'-1 x n-k'-1 ;

[0118] Where y0, y1, y2, ..., y n-k'-1 is the check symbol;

[0119] Based on the extended information polynomial M(x)·x n-k' The codeword polynomial C(x) is constructed by summing the remainder polynomial Y(x), which can be expressed as:

[0120] C(x)=M(x)·x n-k' +Y(x);

[0121] The decoding steps are as follows:

[0122] The received codeword polynomial may introduce errors due to channel noise, hardware failure, medium damage, etc. during data transmission or storage. This may cause the codeword polynomial received by the receiving end to be wrong. The received codeword polynomial, that is, the received data codeword stream in this embodiment, is regarded as R(x), which is expressed by the formula:

[0123] R(x)=r0+r1x+r2x 2 +r3x 3 +......+r (n-1) x (n-1) ;

[0124] In the formula, r0, r1, r2, r3, ..., r (n-1) is the value of the data codeword stream; n is the length of the codeword;

[0125] The adjoint polynomial is obtained by dividing the polynomial R(x) by the remainder of the generator polynomial. The adjoint polynomial S(x) is expressed as:

[0126]

[0127] in:

[0128]

[0129] s1=r0+r12+r22 2 +r32 3 +......+r (n-1) 2(n-1) ;

[0130] s2=r0+r1(2 2 )+r2(2 2 ) 2 +r3(2 2 ) 3 +......+r (n-1) (2 2 ) (n-1) ;

[0131] s3=r0+r1(2 3 )+r2(2 3 ) 2 +r3(2 3 ) 3 +......+r (n-1) (2 3 ) (n-1) ;

[0132] ……;

[0133] s 2t =r0+r1(2 2t )+r2(2 2t ) 2 +r3(2 2t ) 3 +......+r (n-1) (2 2t ) (n-1) ;

[0134] In the formula, x is a variable, t is the error correction capability, and s i is the i-th coefficient of the syndrome, which represents a measure of the matching degree between the received codeword and the generator polynomial G(x);

[0135] If R(x) has no errors, then the syndrome coefficient s i All are 0, the decoding process ends and the data block is output; if the syndrome coefficient s i If not all are 0, it means that the received codeword data codeword stream has errors and needs to be corrected;

[0136] S311. Preferably, this embodiment further includes determining a storage start address of the syndrome coefficient according to the type of the two-dimensional code, and when judging whether there is an error based on the syndrome coefficient, reading the syndrome coefficient from the storage start address;

[0137] S312. Preferably, when calculating the syndrome polynomial, each element in the data codeword stream is mapped to its corresponding power, that is, the syndrome coefficient s by searching the power data corresponding table stored in the configuration management module. i The subscript i of corresponds directly to the i-th power of the primitive element of the finite field;

[0138] S32, if there is an error, calculating the error position polynomial by the Berlekamp-Massey algorithm;

[0139] The Berlekamp-Massey algorithm is used to find the location of the error from the syndrome coefficients. The algorithm gradually constructs a polynomial through an iterative process. This implementation can best predict the syndrome sequence through the Berlekamp-Massey algorithm. Specifically:

[0140] Initial parameters are set, including initial error position polynomial L(x)=1; initial difference polynomial △(x)=0; initial iteration number j=0; initial record polynomial ∧(x)=1;

[0141] For each iteration j, the difference polynomial is updated, expressed as:

[0142]

[0143] In the formula, r k is the coefficient of the received data codeword stream; k is the position in the currently processed data codeword stream; The coefficients of the record polynomial obtained in the previous iteration;

[0144] Determine whether the difference polynomial △(x) is 0. If △(x)=0, keep the current record polynomial ∧(x) unchanged, update the number of iterations j=j+1, and continue the next round of iterations; if △(x)≠0, update the record polynomial ∧(x), expressed as:

[0145]

[0146] Where, L (j-1) is the order of the error position polynomial obtained in the previous iteration;

[0147] Update the order of the error location polynomial L(x), expressed as:

[0148] L (j) =max(L (j-1) ,jL (j-1) );

[0149] When the number of iterations j reaches the error correction capability t, the iteration is stopped, and the final recorded polynomial ∧(x) is the error position polynomial;

[0150] S321. Preferably, in the Berlekamp-Massey algorithm, it is necessary to iteratively update the syndrome coefficients, and the update of these coefficients involves multiplication and addition operations in a finite field. In this embodiment, it is implemented by a power data correspondence table stored in the configuration management module, and the multiplication is converted into addition through the logarithm table of the power data correspondence table to accelerate the calculation.

[0151] S33, using Chien search algorithm to find the error location;

[0152] The Chien search algorithm is used to find the root, that is, the location of the error, in the error location polynomial. Due to the characteristics of the RS code, there may be multiple error locations, so all possible values ​​need to be checked until all roots are found. Specifically:

[0153] Set the search variable x of the error position polynomial, i.e. the final record polynomial Λ(x) to 1;

[0154] Based on the power data corresponding table stored in the configuration management module, all values ​​are traversed in the finite field, each value is substituted into the error position polynomial, and the error position polynomial is checked to see if it is zero. If the error position polynomial is zero, the corresponding variable is the error position, where each value is substituted into the error position polynomial to express the formula as follows:

[0155]

[0156] In the formula, α i is the i-th power of the primitive element α of the finite field, ∧ j' are the coefficients of the error location polynomial, and L is the order of the error location polynomial;

[0157] S34, calculating an error value by using the Forney algorithm, and correcting the error in the data block according to the error position and the error value;

[0158] The error value polynomial Ω(x) is calculated by the adjoint polynomial S(x) and the error location polynomial ∧(x), which can be expressed as:

[0159] Ω(x)=S(x)·∧(x)mod x 2t ;

[0160] Calculate the derivative of the error location polynomial ∧(x), expressed as:

[0161]

[0162] For each error position α i Calculate the error value e i , expressed as:

[0163]

[0164] According to each error position and corresponding error value, error correction is performed by subtracting the error value from the original data codeword stream to recover the original coded information;

[0165] S341. Preferably, when calculating the error value polynomial, it is necessary to multiply the companion polynomial and the error position polynomial, and accelerate the polynomial multiplication through the logarithmic table of the power data correspondence table; when calculating the derivative of the error position polynomial, it is necessary to perform power operations on the polynomial coefficients, and quickly calculate the power in the finite field through the power table of the power data correspondence table; when calculating the error value, the power table and logarithmic table of the power data correspondence table are used to accelerate the power and multiplication calculations.

[0166] As described above, the RS error correction decoding method provided in this embodiment can effectively detect and correct errors introduced during data transmission or storage through a series of precise calculation steps. In practical applications, users often encounter different types of two-dimensional codes, each of which may have its own unique encoding rules and error correction requirements. The method described in this embodiment meets this diversity and makes full use of the advantages of the RS error correction algorithm. It not only adapts to different two-dimensional code standards, but also can flexibly handle various error correction parameters and codeword structures.

[0167] Embodiment 2:

[0168] This embodiment provides a RS error correction decoding system compatible with multiple two-dimensional codes, the system comprising a configuration management module, an image acquisition module, a two-dimensional code extraction module and an error correction decoding module, wherein:

[0169] The configuration management module stores a power data correspondence table, and the construction of the power data correspondence table is specifically as follows: based on the two-dimensional code type required by the user, a finite field and a module value correspondence table is defined, a power table of finite field elements is generated according to the module value of the finite field, and a corresponding relationship table between power and data is constructed based on the power table;

[0170] The image acquisition module acquires image data using an image sensor;

[0171] The two-dimensional code extraction module extracts the two-dimensional code data from the image data;

[0172] The error correction decoding module performs error detection and correction on the two-dimensional code data based on the power data correspondence table to obtain original coding information, wherein the error detection and correction on the two-dimensional code data based on the power data correspondence table is specifically:

[0173] Calculate the corresponding syndrome according to the data codeword stream, and determine whether there is an error based on the syndrome coefficient. If there is an error, calculate the error position polynomial using the Berlekamp-Massey algorithm;

[0174] The Chien search algorithm is used to find the error position, and the Forney algorithm is used to calculate the error value. The errors in the data block are corrected according to the error position and error value.

[0175] Embodiment 3:

[0176] This embodiment provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, an RS error correction decoding method compatible with multiple two-dimensional codes as described in Embodiment 1 of the present invention is implemented.

[0177] It is worth noting that the system and electronic device described in the present invention are based on the same inventive concept as the method described in Example 1 of the present invention, and will not be described in detail here.

[0178] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A RS error correction decoding method compatible with multiple two-dimensional codes, characterized in that: The method comprises: Define a finite field and module value correspondence table based on the two-dimensional code type required by the user, generate a power table of finite field elements according to the module value of the finite field, construct a corresponding relationship table between the power and data based on the power table, and store the power data correspondence table in the configuration management module; Acquire image data using an image sensor, and extract QR code data from the image data; Error detection and correction are performed on the two-dimensional code data based on the power data correspondence table to obtain original coding information.

2. The RS error correction decoding method compatible with multiple two-dimensional codes according to claim 1, characterized in that: Extracting the QR code data from the image data is specifically as follows: Scan the image data by full scanning to obtain a corresponding QR code identifier, and determine the type and position of the QR code based on the QR code identifier; Convert the image data into a grayscale image, and convert the grayscale image into a binary image using a threshold algorithm to obtain a corresponding black and white array image; Based on the type and position of the two-dimensional code, the bit stream arrangement order of the corresponding coding standard is determined, and the data bit stream is extracted row by row or column by column from the black and white array diagram, and the data bit stream is converted into a finite field codeword to obtain the two-dimensional code data, that is, the data codeword stream.

3. The RS error correction decoding method compatible with multiple two-dimensional codes according to claim 1, characterized in that: Error detection and correction of the two-dimensional code data is performed based on the power data correspondence table, specifically: Calculate the corresponding syndrome according to the data codeword stream, and determine whether there is an error based on the syndrome coefficient. If there is an error, calculate the error position polynomial using the Berlekamp-Massey algorithm; The Chien search algorithm is used to find the error position, and the Forney algorithm is used to calculate the error value. The errors in the data block are corrected according to the error position and error value.

4. The RS error correction decoding method compatible with multiple two-dimensional codes according to claim 3, characterized in that: Calculate the corresponding syndrome according to the data codeword stream, and judge whether there is an error based on the syndrome coefficient: The received data codeword stream is regarded as a polynomial R(x), which can be expressed as: R(x)=r0+r1x+r2x 2 +r3x 3 +......+r (n-1) x (n-1) ; In the formula, r0, r1, r2, r3, ..., r (n-1) is the value of the data codeword stream; n is the length of the codeword; The adjoint polynomial is obtained by dividing the polynomial R(x) by the remainder of the generator polynomial. The adjoint polynomial S(x) is expressed as: in: s1=r0+r12+r22 2 +r32 3 +......+r (n-1) 2 (n-1) ; s2=r0+r1(2 2 )+r2(2 2 ) 2 +r3(2 2 ) 3 +......+r (n-1) (2 2 ) (n-1) ; s3=r0+r1(2 3 )+r2(2 3 ) 2 +r3(2 3 ) 3 +......+r (n-1) (2 3 ) (n-1) ; ……; s 2t =r0+r1(2 2t )+r2(2 2t ) 2 +r3(2 2t ) 3 +......+r (n-1) (2 2t ) (n-1) ; In the formula, x is a variable, t is the error correction capability, and s i is the i-th coefficient of the syndrome; If the syndrome coefficient s i If all are 0, it means that there is no error in the received data codeword stream, the decoding process ends, and the data block is output; if the syndrome coefficients are not all 0, it means that there is an error in the received codeword data codeword stream, and correction is performed; The storage start address of the syndrome coefficient is determined according to the type of the two-dimensional code, and when judging whether an error exists based on the syndrome coefficient, the syndrome coefficient is read from the storage start address.

5. The RS error correction decoding method compatible with multiple two-dimensional codes according to claim 4, characterized in that: When calculating the syndrome polynomial, each element in the data codeword stream is mapped to its corresponding power, i.e., syndrome coefficient s, by searching the power data corresponding table stored in the configuration management module. i The subscript i of corresponds directly to the i-th power of the primitive elements of the finite field.

6. The RS error correction decoding method compatible with multiple two-dimensional codes according to claim 5, characterized in that: The error position polynomial calculated by the Berlekamp-Massey algorithm is as follows: Initial parameters are set, including initial error position polynomial L(x)=1; initial difference polynomial △(x)=0; initial iteration number j=0; initial record polynomial ∧(x)=1; For each iteration j, the difference polynomial is updated, expressed as: In the formula, r k is the coefficient of the received data codeword stream; k is the position in the currently processed data codeword stream; The coefficients of the record polynomial obtained in the previous iteration; Determine whether the difference polynomial △(x) is 0. If △(x)=0, keep the current record polynomial ∧(x) unchanged, update the number of iterations j=j+1, and continue the next round of iterations; if △(x)≠0, update the record polynomial ∧(x), expressed as: Where, L (j-1) is the order of the error position polynomial obtained in the previous iteration; Update the order of the error location polynomial L(x), expressed as: L (j) =max(L (j-1) ,jL (j-1) ); When the number of iterations j reaches the error correction capability t, the iteration is stopped and the final record polynomial ∧(x) is the error position polynomial.

7. The RS error correction decoding method compatible with multiple two-dimensional codes according to claim 6, characterized in that: Using the Chien search algorithm to find the error location is as follows: Set the search variable x of the error position polynomial, i.e. the final record polynomial Λ(x) to 1; Based on the power data corresponding table stored in the configuration management module, all values ​​are traversed in the finite field, each value is substituted into the error position polynomial, and the error position polynomial is checked to see if it is zero. If the error position polynomial is zero, the corresponding variable is the error position, where each value is substituted into the error position polynomial to express the formula as follows: In the formula, α i is the i-th power of the primitive element α of the finite field, ∧ j' are the coefficients of the error location polynomial, and L is the order of the error location polynomial.

8. The RS error correction decoding method compatible with multiple two-dimensional codes according to claim 7, characterized in that: The error value is calculated by the Forney algorithm, and the error in the data block is corrected according to the error position and error value: The error value polynomial Ω(x) is calculated by the adjoint polynomial S(x) and the error location polynomial ∧(x), which can be expressed as: Ω(x)=S(x)·∧(x)mod x 2t ; Calculate the derivative of the error location polynomial ∧(x), expressed as: For each error position α i Calculate the error value e i , expressed as: According to each error position and the corresponding error value, error correction is performed by subtracting the error value from the original data codeword stream to restore the original encoded information.

9. A RS error correction decoding system compatible with multiple two-dimensional codes, characterized in that: The system includes a configuration management module, an image acquisition module, a two-dimensional code extraction module and an error correction decoding module, wherein: The configuration management module stores a power data correspondence table, and the construction of the power data correspondence table is specifically as follows: based on the two-dimensional code type required by the user, a finite field and a module value correspondence table is defined, a power table of finite field elements is generated according to the module value of the finite field, and a corresponding relationship table between power and data is constructed based on the power table; The image acquisition module acquires image data using an image sensor; The two-dimensional code extraction module extracts the two-dimensional code data from the image data; The error correction decoding module performs error detection and correction on the two-dimensional code data based on the power data correspondence table to obtain original coding information, wherein the error detection and correction on the two-dimensional code data based on the power data correspondence table is specifically: Calculate the corresponding syndrome according to the data codeword stream, and determine whether there is an error based on the syndrome coefficient. If there is an error, calculate the error position polynomial using the Berlekamp-Massey algorithm; The Chien search algorithm is used to find the error position, and the Forney algorithm is used to calculate the error value. The errors in the data block are corrected according to the error position and error value.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, an RS error correction decoding method compatible with multiple two-dimensional codes as described in any one of claims 1 to 8 is implemented.

Citation Information

Patent Citations

  • Method for decreasing encoding and decoding complexity of RS code

    CN1303763C

Cited By

  • Data processing device, data processing method and electronic equipment

    CN120743620A

  • Data processing device, data processing method, and electronic device

    CN120743620B

  • Method and system for generating bit error rate control scheme of two-dimensional code

    CN121328598A

  • A method and system for generating an error rate control scheme for a two-dimensional code

    CN121328598B