A barcode generation method, system and electronic device

By introducing information bits and supervision bits into the barcode, combined with Hamming coding, BCH loop coding or fusion coding, the error detection and correction function of the barcode is realized, solving the scanning error problem caused by only having the error detection function in the prior art, and improving the accuracy and efficiency of the application.

CN116187372BActive Publication Date: 2025-07-04HARBIN INST OF TECH SHENZHEN GRADUATE SCHOOL
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211418454.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-14
Publication Date
2025-07-04
Estimated Expiration
2042-11-14

AI Technical Summary

Technical Problem

The existing barcode encoding methods only have error detection functions and cannot correct errors, which will affect subsequent operational efficiency when scanning errors occur, especially when scanning large quantities of items are damaged.

Method used

By combining barcode encoding rules with error correction code encoding rules, information bits and supervision bits are generated, and Hanming encoding, BCH loop encoding or fusion encoding are used to add error correction codes to achieve error detection and correction functions.

Benefits of technology

Improves the accuracy and efficiency of barcode applications, reduces the probability of detection errors, and ensures the accuracy and efficiency of scanning under light and angle problems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116187372B_ABST
    Figure CN116187372B_ABST
Patent Text Reader

Abstract

This specification discloses a bar code generation method, system and electronic device, which can detect and correct errors in bar code codewords to ensure the accuracy and efficiency of bar code applications. The method includes: obtaining information to be encoded, and determining the encodable number of digits of the target bar code; setting the number of parity digits and the number of information digits according to the encodable number of digits and a preset error correction coding method; using a preset information coding method to encode the information to be encoded to generate information bit data that conforms to the number of information digits; using the preset error correction coding method to generate parity bit data that conforms to the parity bit data; generating the target bar code according to the combination result of the information bit data and the parity bit data. The system includes an information acquisition module, a parameter setting module, an information bit encoding module, a parity bit encoding module and a bar code generation module. The computer program of the electronic device is used to implement the bar code generation method.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of digital information encoding, and particularly relates to a barcode generation method, system and electronic device. Background Art

[0002] Since the 1970s, with the continuous development and progress of related technologies, barcodes have been popularized and widely used. Now it is most commonly seen on the product packaging for supermarket shopping, and the encoding of any product is unique. By establishing a one-to-one correspondence between barcodes and item information such as price, batch, date, origin, etc. through a database.

[0003] In actual application scenarios, when scanning a barcode, due to light problems, angle problems or operator problems, the barcode scanning may be incorrect. Therefore, the existing encoding methods for barcodes generally have an error detection function. Taking the EAN barcode as an example, it represents a product with thirteen digits, encodes each digit according to its specific rules to form a black and white barcode. The error detection method of this barcode mainly uses one digit as a check digit, and according to a calculation method, calculates the thirteenth digit from the first twelve digits. If the calculation result does not match the check digit, it is determined that the barcode is incorrect. However, such a method only realizes error detection but not error correction, and cannot solve the problem, affecting subsequent application operations. Summary of the Invention

[0004] In view of this, the embodiments of the present specification provide a barcode generation method, system and electronic device, which can perform error detection and correction on barcode codewords to ensure the accuracy and efficiency of barcode applications.

[0005] According to a first aspect, the embodiments of the present specification provide a barcode generation method, the method comprising:

[0006] Obtain the information to be encoded, and determine the encodable number of digits of the target barcode;

[0007] Set the number of parity bits and the number of information bits according to the encodable number of digits and a preset error correction coding method;

[0008] Encode the information to be encoded using a preset information encoding method to generate information bit data that conforms to the number of information bits;

[0009] Generate parity bit data corresponding to the information bit data and conforming to the number of parity bits using the preset error correction coding method;

[0010] Generate the target barcode according to the combination result of the information bit data and the parity bit data.

[0011] Optionally, the preset error correction coding method adopts the Hamming coding method;

[0012] Set the number of parity bits and the number of information bits according to the number of bits that can be encoded and the Hamming coding method, including:

[0013] Calculate and determine the number of parity binary bits according to the number of bits that can be encoded:

[0014] 2 k ≥g + 1

[0015] where g = G * β represents the number of encodable binary bits corresponding to the number of bits G that can be encoded, β represents the base conversion coefficient, and k represents the number of parity binary bits;

[0016] Calculate and determine the number of parity bits according to the number of parity binary bits:

[0017]

[0018] where K represents the number of parity bits;

[0019] Determine the number of information bits according to the number of bits that can be encoded and the number of parity bits:

[0020] N = G - K

[0021] where N represents the number of information bits.

[0022] Optionally, generate parity bit data that conforms to the information bit data based on the information bit data, including:

[0023] Generate K-bit parity bit data corresponding to the N-bit information bit data using the Hamming coding method, where the first min(k) binary bits of the parity bit data are encoded according to the Hamming coding method.

[0024] Optionally, the preset error correction coding method uses the BCH cyclic coding method;

[0025] Set the number of parity bits and the number of information bits according to the number of bits that can be encoded and the BCH cyclic coding method, including:

[0026] Set the number of correctable bits t, and look up and determine the number of information binary bits n corresponding to the number of correctable bits t according to the generator polynomial table corresponding to the number of bits that can be encoded;

[0027] Calculate and determine the number of parity binary bits according to the number of bits that can be encoded and the number of information binary bits:

[0028] k = g - n

[0029] where g = G * β represents the number of encodable binary bits corresponding to the number of bits G that can be encoded, β represents the base conversion coefficient, and k represents the number of parity binary bits;

[0030] Determine the number of parity bits according to the calculated number of supervised binary bits:

[0031]

[0032] Wherein, K represents the number of parity bits;

[0033] Determine the number of information bits according to the encodable bits and the number of parity bits:

[0034] N = G - K

[0035] Wherein, N represents the number of information bits.

[0036] Optionally, generating parity bit data corresponding to the information bit data and conforming to the parity bit data includes:

[0037] Look up and determine the generator polynomial corresponding to the correctable bit number t according to the generator polynomial table;

[0038] Generate K-bit parity bit data based on the generator polynomial formula using the BCH cyclic coding method, wherein the first k-bit binary bits of the parity bit data are encoded according to the BCH cyclic coding method.

[0039] Optionally, the preset error correction coding method adopts a fusion coding method;

[0040] Set the number of parity bits and the number of information bits according to the encodable bits and the fusion coding method, including:

[0041] Calculate and determine the number of supervised binary bits according to the encodable bits:

[0042] 2 k ≥ g + 1

[0043] Wherein, g = G * β represents the encodable binary bits corresponding to the encodable bits G, β represents the base conversion coefficient, and k represents the number of supervised binary bits;

[0044] Determine the number of codeword types corresponding to the supervised binary bits, and determine the number of parity bits based on the number of codeword types:

[0045] 10 K-1 <2 min(k) <10 K

[0046] Wherein, K represents the number of parity bits;

[0047] Determine the number of information bits according to the encodable bits and the number of parity bits:

[0048] N = G - K

[0049] Among them, N represents the number of bits of the said information.

[0050] Optionally, generating parity bit data corresponding to the said information bit data and conforming to the said parity bit data includes:

[0051] Generating Hamming codes of min(k) bits in binary corresponding to the N-bit said information bit data;

[0052] According to a preset base conversion mapping relationship, mapping and converting the said Hamming codes into K-bit decimal data as the K-bit said parity bit data.

[0053] Optionally, the said preset information encoding method adopts the EAN encoding method.

[0054] In a second aspect, an embodiment of this specification further provides a barcode generation system, and the said system includes:

[0055] An information acquisition module, configured to acquire information to be encoded and determine the encodable number of bits of the target barcode;

[0056] A parameter setting module, configured to set the number of parity bits and the number of information bits according to the encodable number of bits and a preset error correction encoding method;

[0057] An information bit encoding module, configured to encode the information to be encoded by using a preset information encoding method to generate information bit data conforming to the said number of information bits;

[0058] A parity bit encoding module, which adopts the said preset error correction encoding method to generate parity bit data corresponding to the said information bit data and conforming to the said parity bit data; and

[0059] A barcode generation module, configured to generate the target barcode according to the combined result of the said information bit data and the said parity bit data,

[0060] The said system is used to execute the barcode generation method as described in the first aspect.

[0061] In a third aspect, an embodiment of this specification further provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, and when the processor executes the said program, it implements the barcode generation method as described in the first aspect.

[0062] As can be seen from the above, a barcode generation method, system, and electronic device provided by one or more optional embodiments of this specification have the following beneficial technical effects:

[0063] The barcode generation method realizes the error detection and correction function by adding an error correction code. The encodable part is divided into information bits and parity bits. To ensure the error correction ability of the added error correction code, according to the selected preset error correction coding method, the parity bit number and the information bit number are set in combination with the encodable bit number. For the information bits, the information to be encoded is encoded to generate information bit data and written into the information bits; for the parity bits, an error correction code is generated according to the selected preset error correction coding method and written into the parity bits. Finally, the target barcode is generated based on the combination result of the information bit data and the parity bit data. In this way, the target barcode can provide an error detection and correction function while representing the information to be encoded, ensuring the accuracy and efficiency in the application process of the target barcode. BRIEF DESCRIPTION OF THE DRAWINGS

[0064] The features and advantages of the present invention will be more clearly understood by referring to the accompanying drawings. The drawings are schematic and should not be construed as imposing any limitation on the present invention. In the drawings:

[0065] Figure 1 FIG. shows a schematic diagram of a barcode generation method provided by one or more alternative embodiments of this specification;

[0066] Figure 2 FIG. shows a schematic diagram of a method for setting the parity bit number and the information bit number when using the Hamming coding method in a barcode generation method provided by one or more alternative embodiments of this specification;

[0067] Figure 3 FIG. shows a schematic diagram of a method for setting the parity bit number and the information bit number when using the BCH cyclic coding method in a barcode generation method provided by one or more alternative embodiments of this specification;

[0068] Figure 4 FIG. shows a schematic diagram of a method for setting the parity bit number and the information bit number when using the fusion coding method in a barcode generation method provided by one or more alternative embodiments of this specification;

[0069] Figure 5 FIG. shows a schematic diagram of a method for generating parity bit data when using the fusion coding method in a barcode generation method provided by one or more alternative embodiments of this specification;

[0070] Figure 6 FIG. shows a schematic diagram of the structure of a barcode generation system provided by one or more alternative embodiments of this specification;

[0071] Figure 7 FIG. shows a schematic diagram of the structure of an electronic device for barcode generation provided by one or more alternative embodiments of this specification. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0072] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are some, but not all, of the embodiments of the present invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative efforts belong to the scope of protection of the present invention.

[0073] Since the 1970s, with the continuous development and progress of related technologies, barcodes have been popularized and widely used. Now it is most commonly seen on the product packaging for supermarket shopping, and the code for any product is unique. By establishing a one-to-one correspondence between barcodes and item information, such as price, batch, date, origin, etc., through a database.

[0074] In actual application scenarios, when scanning barcodes, due to light problems, angle problems, or operator problems, barcode scanning errors may occur. Therefore, the existing barcode encoding methods generally have an error detection function. Taking the EAN barcode as an example, it represents a product with thirteen digits, encodes each digit according to its specific rules to form a black-and-white barcode. The error detection method of this barcode mainly uses one digit as a check digit, and according to a calculation method, calculates the thirteenth digit from the first twelve digits. If the calculation result does not match the check digit, it is determined that the barcode is in error.

[0075] However, in the actual application process of barcodes, the most important purpose is to scan and read the accurate information represented by the barcode. Only implementing the error detection function does not help achieve the purpose of reading accurate information, and even detecting barcode errors will affect the work efficiency of subsequent operations. For example, in the scenario of barcode scanning and reading of a large number of items, both the accuracy and scanning efficiency of the entire process have relatively high requirements. Only implementing the error detection function cannot correct errors, and the associated personnel need to perform re-scanning and detection, which will instead affect the overall execution efficiency.

[0076] To address the above problems, the objective of the technical solution in this specification is to propose a barcode generation method that can implement an error correction function, combines the barcode encoding rule with the error correction code encoding rule, adds an error correction code for implementing the error correction function on the basis of generating information bits corresponding to the information to be encoded, and the generated barcode has both error detection and error correction functions, which can ensure the accuracy and efficiency in the application process of barcodes.

[0077] Based on the above objective, on the one hand, the embodiments of this specification provide a barcode generation method.

[0078] Such as Figure 1As shown, a bar code generation method provided by one or more optional embodiments of this specification includes:

[0079] S1: Obtain the information to be encoded and determine the encodable number of digits of the target bar code.

[0080] The information to be encoded refers to the content information actually carried by the bar code. For example, for a bar code applied to the outer packaging of a commodity, the corresponding information to be encoded can be item information, such as price, batch number, production date, place of origin, production standard and other related information. Bar codes can also be applied in the field of biomedical testing to record information associated with the sample to be tested. For example, a bar code can be attached to a test tube containing the sample to be tested. At this time, the information to be encoded corresponding to the bar code can be time information, sample identity information, test operation information, etc. related to the sample to be tested. The information to be encoded can come from existing data information in the database or can be collected immediately through an information input device.

[0081] In an actual application scenario, the information to be encoded will be encoded and represented in the encodable part of the bar code, and the corresponding encodable number of digits characterizes the upper limit of the data capacity that the bar code can represent. For example, in a specific application scenario in the field of biomedical monitoring, the bar code used is a 14-digit bar code, where the first 5 digits represent fixed content and the last 9 digits are encodable digits for encoding specific information.

[0082] S2: Set the number of parity digits and information digits according to the encodable number of digits and a preset error correction coding method.

[0083] To implement the error detection and correction function, error correction codes need to be added to the encodable part of the target bar code. Therefore, the encodable part of the target bar code can be divided into information bits and parity bits. The information bits are used to carry the information to be encoded, and the parity bits are used to carry the error correction codes for implementing the error detection and correction function. The error correction codes can be generated according to a preset error correction coding method, and the number of parity digits and information digits can be set according to the preset error correction coding method in combination with the encodable number of digits.

[0084] S3: Use a preset information coding method to encode the information to be encoded to generate information bit data that conforms to the number of information digits;

[0085] The information bits of the target bar code are used to carry the information to be encoded. The information to be encoded can be encoded using a preset information coding method to generate the information bit data. Among them, the preset information coding method can adopt the coding methods commonly used for bar codes. For example, the EAN series coding method or the UPC series coding method can be selected. In this specification, the EAN-13 coding rule is selected for illustration.

[0086] S4: Using the preset error correction coding method, generate parity bit data corresponding to the information bit data and conforming to the check bit data.

[0087] The parity bits of the target barcode are used to carry error correction codes. The preset error correction coding method can be used to generate the error correction codes in the parity bits of the target barcode as the parity bit data.

[0088] S5: Generate the target barcode according to the combination result of the information bit data and the parity bit data.

[0089] After determining the information bit data and the parity bit data, the target barcode can be generated according to the combination result of the information bit data and the parity bit data.

[0090] The barcode generation method realizes the error detection and correction function by adding error correction codes, divides the encodable part into information bits and parity bits, and to ensure the error correction ability of the added error correction codes, according to the selected preset error correction coding method, the number of parity bits and information bits are set in combination with the number of encodable bits. For the information bits, the information to be encoded is encoded to generate information bit data and written into the information bits; for the parity bits, error correction codes are generated according to the selected preset error correction coding method and written into the parity bits. Finally, the target barcode is generated based on the combination result of the information bit data and the parity bit data. In this way, the target barcode can provide an error detection and correction function while representing the information to be encoded, ensuring the accuracy and efficiency in the application process of the target barcode.

[0091] In a barcode generation method provided in one or more optional embodiments of this specification, the preset error correction coding method can adopt the Hamming coding method. According to the coding principle of linear block codes, the Hamming coding method can realize the error correction of information bits.

[0092] Figure 2 It is a schematic diagram of the method for setting the number of parity bits and information bits when adopting the Hamming coding method.

[0093] As Figure 2 shown, the number of parity bits and information bits can be set by the following steps:

[0094] S201: Calculate and determine the number of supervisory binary digits according to the number of encodable bits:

[0095] 2 k ≥g + 1

[0096] where g = G * β represents the number of encodable binary digits corresponding to the number of encodable bits G, β represents the base conversion coefficient, and k represents the number of supervisory binary digits.

[0097] S202: Determine the number of parity bits according to the calculated number of supervised binary digits:

[0098]

[0099] Where K represents the number of parity bits.

[0100] S203: Determine the number of information bits according to the number of encodable bits and the number of parity bits:

[0101] N = G - K

[0102] Where N represents the number of information bits.

[0103] According to the coding error correction theory, whether any coding has the ability to detect errors and correct errors is related to the minimum distance of the coding. The so-called minimum coding distance refers to the minimum difference in the number of binary digits between any two legal code combinations in a coding system.

[0104] According to the error correction theory:

[0105] L - 1 = D + C, D ≥ C

[0106] Where L is the code distance, D is the number of error detection bits, and C is the number of error correction bits. That is, the larger the minimum coding distance L, the larger the number of error detection bits D and the number of error correction bits C, and the error correction ability is always less than or equal to the error detection ability. If several error detection bits can be added to the information coding, increasing L can obviously improve the error detection and error correction abilities.

[0107] For the Hamming coding method, to ensure the error correction ability of the parity bits, the set number of parity bits needs to meet the following conditions:

[0108]

[0109] Where n and k represent the number of information binary digits and the number of supervised binary digits respectively in the g-bit encodable binary digits. Thus, the value range of the number of supervised binary digits can be determined.

[0110] Taking the encodable bits G = 9 as an example, under the EAN-13 coding rule, one decimal digit consists of 7 binary digits, and the value of the base conversion coefficient β is 7.

[0111] 2 k ≥ g + 1 = 9 * 7 + 1

[0112] It can be determined that the number of supervised binary digits k ≥ 6. That is, to meet the error correction function for 9-bit encodable data, at least 6-bit binary error correction codes are required.

[0113] The minimum value of the supervised binary digit k is 6. Considering that the value of the radix conversion coefficient β is 7, the supervised bit K is set as follows:

[0114]

[0115] Thus, among the 9 encodable bits, the information bit number N is set to 8.

[0116] Therefore, it can be determined that among the 9 encodable bits, 8 decimal digits are selected for information bit encoding, and 1 bit is selected for supervised bit encoding.

[0117] In a barcode generation method provided in this specification or multiple alternative embodiments, in the case where the preset error correction coding method adopts the Hamming coding method, N-bit information bit data is generated by using the preset information coding method, and K-bit supervised bit data corresponding to the N-bit information bit data is generated by using the Hamming coding method. Among them, the first min(k) binary bits of the supervised bit data are encoded according to the Hamming coding method.

[0118] Taking the encodable bit number G = 9 as an example, the preset information coding method selects the EAN-13 coding rule. Among the 9 encodable bits, 8 decimal digits are selected for information bit encoding, and 1 bit is selected for supervised bit encoding.

[0119] The information to be encoded can be encoded into information bit information of 8 decimal digits by using the EAN-13 coding rule. For the supervised bit, 1-bit decimal digit supervised bit data corresponding to the 8-bit decimal digit information bit information is generated by using the Hamming coding method.

[0120] For the 1-bit decimal digit supervised bit data, the first 6 bits of the corresponding 7-bit binary bits are encoded according to the Hamming coding method, and the last bit is fixedly set to 0 or 1.

[0121] Taking the encodable bit number G = 9 as an example, before performing error correction coding by using the Hamming coding method in the embodiments of this specification, the independent error probability of a single binary bit:

[0122] P tot = 1.5 - 2 * 10 -3

[0123] And by performing error correction coding by using the Hamming coding method in the embodiments of this specification, one-bit error correction can be achieved. After one-bit error correction, the error detection probability of the barcode is reduced to:

[0124] P' tot = 1.10865 * 10 -6 ~ 1.97055 * 10 -6

[0125] It can be determined therefrom that using the Hamming coding method in the embodiments of this specification for error correction coding can greatly reduce the probability of detection errors and effectively improve the accuracy and efficiency of the actual application of barcodes.

[0126] In a barcode generation method provided by one or more alternative embodiments of this specification, the preset error correction coding method may adopt the BCH cyclic coding method. The BCH cyclic coding uses a generating polynomial for coding and adds a certain number of parity bits. When decoding, the generating polynomial is also used to implement error correction according to a specific calculation method.

[0127] Figure 3 It is a schematic diagram of the method for setting the parity bit number and the information bit number when adopting the BCH cyclic coding method. As Figure 3 shown, setting the parity bit number and the information bit number may adopt the following steps:

[0128] S301: Set the correctable bit number t, and look up and determine the information binary bit number n corresponding to the correctable bit number t according to the generating polynomial table corresponding to the encodable bit number;

[0129] S302: Calculate and determine the parity binary bit number according to the encodable bit number and the information binary bit number:

[0130] k = g - n

[0131] where g = G * β represents the encodable binary bit number corresponding to the encodable bit number G, β represents the base conversion coefficient, and k represents the parity binary bit number;

[0132] S303: Calculate and determine the parity bit number according to the parity binary bit number:

[0133]

[0134] where K represents the parity bit number;

[0135] S304: Determine the information bit number according to the encodable bit number and the parity bit number:

[0136] N = G - K

[0137] where N represents the information bit number.

[0138] Taking the encodable bit number G = 9 as an example, under the EAN-13 coding rule, one decimal digit consists of 7 binary digits, and the encodable binary bit number g = G * β = 63.

[0139] As shown in Table 1 below, it is the generating polynomial table corresponding to the encodable bit number G = 9.

[0140] Table 1

[0141]

[0142] Among them, n represents the number of information binary digits, t represents the number of correctable digits, and g(x) represents the generating polynomial.

[0143] In order to balance the barcode encoding data capacity and error correction ability, the value of the correctable digit t can be set to 2, and correspondingly, the information binary digit n = 51 can be determined.

[0144] The number of parity binary digits:

[0145] k = g - n = 63 - 51 = 12

[0146] Calculate and determine the number of parity bits according to the number of parity binary digits:

[0147]

[0148] Therefore, the number of parity bits K is set to 2. Correspondingly, the number of information bits N is set to 7.

[0149] Thus, it can be determined that among the 9 encodable bits, 7 decimal digits are selected for information bit encoding, and 2 bits are selected for parity bit encoding.

[0150] In a barcode generation method provided in this specification or multiple alternative embodiments, for the case where the preset error correction coding method adopts the BCH cyclic coding method, N-bit information bit data is generated using the preset information coding method, and K-bit parity bit data corresponding to the N-bit information bit data is generated using the BCH cyclic coding method.

[0151] For the K-bit parity bit data, first, the generating polynomial g(x) corresponding to the number of correctable digits t is found and determined according to the generating polynomial table, and then cyclic coding is performed based on the generating polynomial g(x) as the parity bit data. Among them, the first k binary bits of the parity bit data are encoded according to the BCH cyclic coding method.

[0152] Taking the encodable bit G = 9 as an example, the preset information coding method selects the EAN-13 coding rule. Among the 9 encodable bits, 7 decimal digits are selected for information bit encoding, and 2 bits are selected for parity bit encoding.

[0153] The information to be encoded can be encoded into information bits of 7 - digit decimal digits according to the EAN - 13 encoding rule. For the parity bits, the BCH cyclic encoding method is used to generate the parity bit data of 2 - digit decimal digits. Among them, the used generating polynomial g(x)=12471. For the 2 - digit decimal - digit parity bit data, the first 12 bits of the corresponding 14 - bit binary bits are encoded according to the BCH cyclic encoding method, and the remaining two binary bits are fixedly set to 0 or 1.

[0154] Taking the encodable bit number G = 9 as an example, before performing error - correcting encoding using the BCH cyclic encoding method in the embodiment of this specification, the independent error probability of a single binary bit:

[0155] P tot =1.5 - 2*10 -3

[0156] While using the BCH cyclic encoding method in the embodiment of this specification for error - correcting encoding can achieve two - bit error correction. After error correction, the error probability of barcode detection is reduced to:

[0157] P′ tot =1.35*10 -9 ~1.69*10 -9

[0158] It can be determined therefrom that using the BCH cyclic encoding method in the embodiment of this specification for error - correcting encoding can greatly reduce the error probability of detection and effectively improve the accuracy and efficiency of the actual application of barcodes.

[0159] In a barcode generation method provided by one or more alternative embodiments of this specification, the preset error - correcting encoding method can adopt a fusion encoding method. The fusion encoding method combines the Hamming encoding method with the preset information encoding method of the barcode itself, which is more convenient for barcode printing and recognition on the basis of realizing the error - detection and error - correction functions.

[0160] Figure 4 It is a schematic diagram of the method for setting the parity bit number and information bit number when adopting the fusion encoding method.

[0161] As Figure 4 shown, setting the parity bit number and information bit number can adopt the following steps:

[0162] S401: Calculate and determine the parity binary bit number according to the encodable bit number:

[0163] 2 k ≥g + 1

[0164] Among them, g = G * β represents the number of encodable binary digits corresponding to the number of encodable digits G, β represents the radix conversion coefficient, and k represents the number of supervisory binary digits.

[0165] S402: Determine the number of types of codewords corresponding to the supervisory binary digits, and determine the number of supervisory digits based on the number of types of codewords:

[0166] 10 K-1 <2 min(k) <10 K

[0167] Among them, K represents the number of supervisory digits.

[0168] S403: Determine the number of information digits based on the number of encodable digits and the number of supervisory digits:

[0169] N = G - K

[0170] Among them, N represents the number of information digits.

[0171] Taking the number of encodable digits G = 9 as an example, under the EAN-13 encoding rule, one decimal digit is composed of 7 binary digits, and the number of encodable binary digits g = G * β = 63.

[0172] Correspondingly, it can be calculated and determined that the number of supervisory binary digits k ≥ 6. That is, adopting the fusion coding method, to meet the error correction function for 9-bit encodable data, at least 6-bit Hamming error correction code of binary digits is required.

[0173] When the number of supervisory binary digits k takes the minimum value min(k) = 6, the number of types of codewords corresponding to 6 binary digits is 2 6 = 64 types. Determine the number of supervisory digits based on the number of types of codewords:

[0174] 10 K-1 <2 6 <10 K

[0175] It can be determined that the number of supervisory digits K = 2. Correspondingly, the number of information digits N = 7.

[0176] Thus, it can be determined that among 9 encodable digits, 7 decimal digits are selected for information digit encoding, and 2 digits are selected for supervisory digit encoding. Among them, the 2 selected supervisory digits are used to map and represent the Hamming error correction code of 6 binary digits.

[0177] In a bar code generation method provided in this specification or multiple alternative embodiments, in the case where the preset error correction coding method adopts a fusion coding method, N-bit information bit data is generated by using a preset information coding method, and K-bit parity bit data corresponding to the N-bit information bit data is generated by using the fusion coding method.

[0178] Figure 5 It is a schematic diagram of a method for generating parity bit data when using the fusion coding method. As Figure 5 shown, the following steps can be adopted to generate parity bit data that conforms to the parity bit data corresponding to the information bit data:

[0179] S501: Generate min(k)-bit binary Hamming codes corresponding to the N-bit information bit data.

[0180] S502: According to a preset base conversion mapping relationship, map and convert the Hamming codes into K-bit decimal data as the K-bit parity bit data.

[0181] Taking the encodable bit number G = 9 as an example, under the EAN-13 coding rule, one decimal digit consists of 7 binary digits. The information bit number N is set to 7, and N* = 49-bit binary information bit data is generated by using a preset information coding method.

[0182] When generating the parity bit data, first generate Hamming codes corresponding to the 49-bit binary information data, with a total of 6 binary digits. Then, map and convert the 6-bit binary Hamming codes into 2-bit decimal data as the parity bit data according to a preset base conversion mapping relationship.

[0183] The following Table 2 shows the EAN-13 coding rule table.

[0184] Table 2

[0185] Numeric character Subset A Subset B Subset C 0 0001101 0100111 1110010 1 0011001 0110011 1100110 2 0010011 0011011 1101100 3 0111101 0100001 1000010 4 0100011 0011101 1011100 5 0110001 0111001 1001110 6 0101111 0000101 1010000 7 0111011 0010001 1000100 8 0110111 0001001 1001000 9 0001011 0010111 1110100

[0186] One decimal digit can have 30 binary codewords, and two decimal digits can have at most 900 combinations. For the 6-bit binary Hamming code parity bit data, there are at most 64 codewords, and this can be used to achieve a one-to-one correspondence through mapping. The preset base conversion mapping relationship is used to record the mapping relationship between the 6-bit binary Hamming codes and the 2-bit decimal parity bit data.

[0187] In this way, the fusion coding method can perfectly integrate the Hamming coding method and the EAN coding method. The generated information bit data and parity bit data are combined and corresponding to generate the target bar code, which conforms to the bar code coding rule and is more convenient for printing and scanning recognition.

[0188] Taking the example where the number of encodable bits G = 9, before performing error correction coding using the fusion coding method in the embodiments of this specification, the independent error probability of a single binary bit is:

[0189] P tot = 1.5 - 2 * 10 -3

[0190] While using the fusion coding method in the embodiments of this specification for error correction coding can achieve one-bit error correction. After error correction, the probability of barcode detection error is reduced to:

[0191] P' tot = 3.3420 * 10 -4 ~ 4.4597 * 10 -4

[0192] It can be determined therefrom that using the fusion coding method in the embodiments of this specification for error correction coding can greatly reduce the probability of detection error and effectively improve the accuracy and efficiency of the actual application of barcodes.

[0193] It should be noted that the method of one or more embodiments of this specification can be executed by a single device, such as a computer or a server, etc. The method of this embodiment can also be applied to a distributed scenario and completed by multiple devices cooperating with each other. In this case of a distributed scenario, one of these multiple devices can only execute one or more steps of the method of one or more embodiments of this specification, and these multiple devices will interact with each other to complete the described method.

[0194] It should be noted that the above describes specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be executed in a different order than in the embodiments and still achieve the desired result. Additionally, the processes depicted in the drawings do not necessarily require the specific order or sequential order shown to achieve the desired result. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0195] Based on the same inventive concept, corresponding to the method of any of the above embodiments, the embodiments of this specification also provide a barcode generation system.

[0196] Referring to Figure 6 , the barcode generation system includes:

[0197] An information acquisition module, configured to acquire information to be encoded and determine the number of encodable bits of the target barcode;

[0198] A parameter setting module, configured to set the number of parity bits and the number of information bits according to the number of encodable bits and a preset error correction coding method;

[0199] An information bit encoding module, configured to encode the information to be encoded by using a preset information encoding method to generate information bit data that conforms to the number of information bits;

[0200] A parity bit encoding module, which uses the preset error correction encoding method to generate parity bit data that conforms to the parity bit data corresponding to the information bit data; and

[0201] A bar code generation module, configured to generate the target bar code according to the combination result of the information bit data and the parity bit data.

[0202] In a bar code generation system provided in one or more alternative embodiments of this specification, the preset error correction encoding method uses a Hamming encoding method. The parameter setting module is further configured to calculate and determine the number of supervisory binary digits according to the number of encodable bits:

[0203] 2 k ≥g + 1

[0204] Wherein, g = G * β represents the number of encodable binary digits corresponding to the number of encodable bits G, β represents a base conversion coefficient, and k represents the number of supervisory binary digits;

[0205] Calculate and determine the number of parity bits according to the number of supervisory binary digits:

[0206]

[0207] Wherein, K represents the number of parity bits;

[0208] Determine the number of information bits according to the number of encodable bits and the number of parity bits:

[0209] N = G - K

[0210] Wherein, N represents the number of information bits.

[0211] In a bar code generation system provided in one or more alternative embodiments of this specification, the parity bit encoding module is further configured to generate K-bit parity bit data corresponding to N-bit information bit data by using the Hamming encoding method, wherein the first min(k) binary bits of the parity bit data are encoded according to the Hamming encoding method.

[0212] In a bar code generation system provided in one or more alternative embodiments of this specification, the preset error correction encoding method uses a BCH cyclic encoding method. The parameter setting module is further configured to set the number of parity bits and the number of information bits according to the number of encodable bits and the BCH cyclic encoding method, including:

[0213] Set the correctable bit number t, and look up and determine the information binary bit number n corresponding to the correctable bit number t according to the generating polynomial table corresponding to the encodable bit number;

[0214] Calculate and determine the parity binary bit number according to the encodable bit number and the information binary bit number:

[0215] k = g - n

[0216] where g = G * β represents the encodable binary bit number corresponding to the encodable bit number G, β represents the base conversion coefficient, and k represents the parity binary bit number;

[0217] Calculate and determine the parity bit number according to the parity binary bit number:

[0218]

[0219] where K represents the parity bit number;

[0220] Determine the information bit number according to the encodable bit number and the parity bit number:

[0221] N = G - K

[0222] where N represents the information bit number.

[0223] In a barcode generation system provided by one or more alternative embodiments of this specification, the parity bit encoding module is further configured to look up and determine the generating polynomial corresponding to the correctable bit number t according to the generating polynomial table; generate K-bit parity bit data by using the BCH cyclic encoding method based on the generating polynomial formula, where the first k binary bits of the parity bit data are encoded according to the BCH cyclic encoding method.

[0224] In a barcode generation system provided by one or more alternative embodiments of this specification, the preset error correction encoding method adopts a fusion encoding method. The parameter setting module is further configured to calculate and determine the parity binary bit number according to the encodable bit number:

[0225] 2 k ≥g + 1

[0226] where g = G * β represents the encodable binary bit number corresponding to the encodable bit number G, β represents the base conversion coefficient, and k represents the parity binary bit number;

[0227] Determine the number of codeword types corresponding to the parity binary bit, and determine the parity bit number based on the number of codeword types:

[0228] 10 K-1 <2 min(k) <10K

[0229] Among them, K represents the number of supervision bits.

[0230] Determine the number of information bits according to the number of encodable bits and the number of supervision bits:

[0231] N = G - K

[0232] Among them, N represents the number of information bits.

[0233] In a barcode generation system provided by one or more alternative embodiments of this specification, the supervision bit encoding module is further configured to generate a minimum (k)-bit binary Hamming code corresponding to the N-bit information bit data; according to a preset base conversion mapping relationship, map and convert the Hamming code into K-bit decimal data as the K-bit supervision bit data.

[0234] In a barcode generation system provided by one or more alternative embodiments of this specification, the information bit encoding module encodes the information to be encoded using the EAN encoding method.

[0235] For the convenience of description, when describing the above device, it is divided into various modules according to functions and described separately. Of course, when implementing one or more embodiments of this specification, the functions of each module can be implemented in the same or multiple software and / or hardware.

[0236] The device in the above embodiment is used to implement the corresponding method in the foregoing embodiment, and has the beneficial effects of the corresponding method embodiment, which will not be elaborated here.

[0237] Figure 7 FIG. shows a more specific schematic diagram of the hardware structure of an electronic device provided in this embodiment. The device may include: a processor 1010, a memory 1020, an input / output interface 1030, a communication interface 1040, and a bus 1050. Among them, the processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040 are communicatively connected to each other inside the device through the bus 1050.

[0238] The processor 1010 may be implemented in a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, etc., and is used to execute relevant programs to implement the technical solutions provided by the embodiments of this specification.

[0239] The memory 1020 can be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage devices, dynamic storage devices, etc. The memory 1020 can store an operating system and other application programs. When implementing the technical solutions provided in the embodiments of this specification through software or firmware, the relevant program codes are stored in the memory 1020 and are called and executed by the processor 1010.

[0240] The input / output interface 1030 is used to connect to the input / output module to implement information input and output. The input / output module can be configured as a component in the device (not shown in the figure) or can be externally connected to the device to provide corresponding functions. Among them, the input device can include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output device can include a display, a speaker, a vibrator, an indicator light, etc.

[0241] The communication interface 1040 is used to connect to a communication module (not shown in the figure) to implement communication interaction between this device and other devices. Among them, the communication module can implement communication in a wired manner (such as USB, network cable, etc.) or can implement communication in a wireless manner (such as mobile network, WIFI, Bluetooth, etc.).

[0242] The bus 1050 includes a path for transmitting information between various components of the device (such as the processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040).

[0243] It should be noted that although the above device only shows the processor 1010, the memory 1020, the input / output interface 1030, the communication interface 1040, and the bus 1050, in the specific implementation process, the device may also include other components necessary for normal operation. In addition, those skilled in the art can understand that the above device may also only include the components necessary for implementing the solution of the embodiments of this specification and does not necessarily include all the components shown in the figure.

[0244] The electronic device in the above embodiment is used to implement the corresponding method in the foregoing embodiment and has the beneficial effects of the corresponding method embodiment, which will not be elaborated here.

[0245] Based on the same inventive concept, corresponding to the method in any of the above embodiments, the present disclosure also provides a non-transitory computer-readable storage medium. The non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to cause the computer to execute the barcode generation method as described in any of the foregoing embodiments.

[0246] The computer-readable medium of this embodiment includes permanent and non-permanent, removable and non-removable media, and information storage can be implemented by any method or technology. The information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette tapes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information accessible by a computing device.

[0247] The computer instructions stored in the storage medium of the above embodiment are used to cause the computer to execute the barcode generation method described in any of the above embodiments, and have the beneficial effects of the corresponding method embodiments, which will not be elaborated here.

[0248] Those skilled in the art can understand that all or part of the processes of implementing the methods in the above 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 disc, a read-only memory (ROM), a random access memory (RAM), a flash memory, a hard disk drive (HDD), or a solid-state drive (SSD), etc.; the storage medium can also include a combination of the above types of memories.

[0249] The systems, devices, modules, or units illustrated in the above embodiments can be specifically implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer can be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or any combination of these devices.

[0250] For the convenience of description, when describing the above devices, they are divided into various units according to functions and described separately. Of course, when implementing this application, the functions of each unit can be implemented in the same or multiple software and / or hardware.

[0251] Those skilled in the art should understand that the embodiments of this specification can be provided as methods, systems, or computer program products. Therefore, this specification can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, this specification can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.

[0252] It should also be noted that the term "comprising", "including" or any other variation thereof is intended to cover a non-exclusive inclusion, such that a process, method, commodity or device comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements that are inherent to such process, method, commodity or device. Without further limitation, an element defined by the phrase "comprising a..." does not exclude the presence of additional identical elements in the process, method, commodity or device comprising the element.

[0253] This application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. This application can also be practiced in a distributed computing environment where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.

[0254] Each embodiment in this specification is described in a progressive manner. For the same or similar parts among the embodiments, reference can be made to each other. Each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and reference can be made to the corresponding part of the method embodiment for the relevant content.

[0255] Those of ordinary skill in the art should understand that the discussion of any of the above embodiments is only exemplary and is not intended to imply that the scope of the present disclosure (including the claims) is limited to these examples; under the concept of the present disclosure, the technical features between the above embodiments or different embodiments can also be combined, the steps can be implemented in any order, and there are many other variations in different aspects of one or more embodiments of this specification as described above, which are not provided in detail for the sake of brevity.

[0256] Although the present disclosure has been described in connection with specific embodiments thereof, many alternatives, modifications, and variations of these embodiments will be apparent to those of ordinary skill in the art in light of the foregoing description. For example, other memory architectures (e.g., dynamic RAM (DRAM)) may be used with the embodiments discussed.

[0257] One or more embodiments of this specification are intended to cover all such alternatives, modifications, and variations that fall within the broad scope of the appended claims. Accordingly, any omissions, modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of one or more embodiments of this specification shall be included within the scope of protection of the present disclosure.

Claims

1. A bar code generation method, characterized in that, The method includes: Obtain the information to be encoded and determine the encodable number of digits of the target barcode; Set the number of parity digits and the number of information digits according to the encodable number of digits and a preset error correction coding method; Use a preset information coding method to encode the information to be encoded to generate information bit data that conforms to the number of information digits; Use the preset error correction coding method to generate parity bit data that corresponds to the information bit data and conforms to the number of parity digits; Generate the target barcode according to the combination result of the information bit data and the parity bit data; Among them, the preset error correction coding method uses the Hamming coding method; Setting the number of parity digits and the number of information digits according to the encodable number of digits and the Hamming coding method includes: Calculate and determine the number of parity binary digits according to the encodable number of digits: Among them, represents the number of bits that can be encoded the corresponding number of binary bits that can be encoded, represents the radix conversion coefficient, represents the number of supervisory binary bits; Calculate and determine the number of parity digits according to the number of parity binary digits: Among them, represents the number of supervision bits; Determine the number of information digits according to the encodable number of digits and the number of parity digits: Among them, represents the number of bits of the said information; Alternatively, the preset error correction coding method uses the BCH cyclic coding method; Setting the number of parity digits and the number of information digits according to the encodable number of digits and the BCH cyclic coding method includes: Set the number of correctable bits , look up and determine the number of information binary digits corresponding to the number of correctable bits according to the generation polynomial table corresponding to the number of encodable bits ; ; Calculate and determine the number of parity binary digits according to the encodable number of digits and the number of information binary digits: Among them, represents the number of bits that can be encoded the corresponding number of binary bits that can be encoded, represents the radix conversion coefficient, represents the number of parity binary bits; Calculate and determine the number of parity digits according to the number of parity binary digits: Among them, represents the number of supervision digits; Determine the number of information digits according to the encodable number of digits and the number of parity digits: Among them, represents the number of bits of the said information; Alternatively, the preset error correction coding method uses a fusion coding method; Setting the number of parity digits and the number of information digits according to the encodable number of digits and the fusion coding method includes: Calculate and determine the number of parity binary digits according to the encodable number of digits: Among them, represents the number of bits that can be encoded the corresponding number of binary bits that can be encoded, represents the radix conversion coefficient, represents the number of parity-check binary bits; Determine the number of codeword types corresponding to the parity binary digits, and determine the number of parity digits based on the number of codeword types: Among them, represents the number of supervision digits; Determine the number of information digits according to the encodable number of digits and the number of parity digits: Among them, represents the number of bits of the said information.

2. According to the method described in claim 1, it is characterized in that generating parity bit data that conforms to the parity bit data based on the information bit data includes: Generate, using the Hamming coding method, bits of parity bit data corresponding to the bits of information bit data, where the first binary bits of the parity bit data are encoded according to the Hamming coding method.

3. The method according to claim 1, characterized in that, Generating parity bit data that corresponds to the information bit data and conforms to the parity bit data includes: Determine the generator polynomial corresponding to the correctable bit number according to the lookup of the generated polynomial table corresponding to; Generate using the BCH cyclic coding method based on the said generating polynomial bits of the said parity bit data, where the first binary bits are encoded according to the BCH cyclic coding method.

4. The method according to claim 1, wherein Generating parity bit data that corresponds to the information bit data and conforms to the parity bit data includes: Generate the Hamming code corresponding to the bit binary information bit data; According to the preset binary conversion mapping relationship, map and convert the Hamming code into -bit decimal data as -bit parity bit data of the said 5. The method according to claim 1, characterized in that, The preset information coding method uses the EAN coding method.

6. A barcode generation system, characterized in that, The system includes: An information acquisition module, configured to acquire the information to be encoded and determine the encodable number of digits of the target barcode; A parameter setting module, configured to set the number of parity digits and the number of information digits according to the encodable number of digits and a preset error correction coding method; An information bit coding module, configured to use a preset information coding method to encode the information to be encoded to generate information bit data that conforms to the number of information digits; A parity bit coding module, which uses the preset error correction coding method to generate parity bit data that corresponds to the information bit data and conforms to the number of parity digits; and A barcode generation module, configured to generate the target barcode according to the combination result of the information bit data and the parity bit data; Among them, the preset error correction coding method uses the Hamming coding method; The parameter setting module specifically includes: Calculate and determine the number of parity binary digits according to the encodable number of digits: Among them, represents the number of bits that can be encoded the corresponding number of binary bits that can be encoded, represents the radix conversion coefficient, represents the number of supervisory binary bits; Determine the number of parity bits according to the calculated number of supervised binary bits: Among them, represents the number of supervision digits; Determine the number of information bits according to the number of encodable bits and the number of parity bits: Among them, indicates the number of bits of the said information; Alternatively, the preset error correction coding method adopts the BCH cyclic coding method; The parameter setting module specifically includes: Set the number of correctable bits , and look up and determine the information binary digits corresponding to the number of correctable bits according to the generation polynomial table corresponding to the number of encodable bits ; ; Calculate and determine the number of supervised binary bits according to the number of encodable bits and the number of information binary bits: Among them, represents the number of bits that can be encoded the corresponding number of binary bits that can be encoded, represents the radix conversion coefficient, represents the number of supervisory binary bits; Determine the number of parity bits according to the calculated number of supervised binary bits: Among them, represents the number of supervision digits; Determine the number of information bits according to the number of encodable bits and the number of parity bits: Among them, represents the number of bits of the said information; Alternatively, the preset error correction coding method adopts the fusion coding method; The parameter setting module specifically includes: Calculate and determine the number of supervised binary bits according to the number of encodable bits: Among them, represents the number of bits that can be encoded the corresponding number of binary bits that can be encoded, represents the radix conversion coefficient, represents the number of supervisory binary bits; Determine the number of codeword types corresponding to the supervised binary bits, and determine the number of parity bits based on the number of codeword types: Among them, represents the number of supervision bits; Determine the number of information bits according to the number of encodable bits and the number of parity bits: Among them, represents the number of bits of the said information.

7. An electronic device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, When the processor executes the program, the method described in any one of claims 1 to 5 is implemented.

Citation Information

Patent Citations

  • Encoding and decoding method for detecting and correcting two-bit errors, encoder / decoder and processor

    CN110492889A

  • Device and method for automatically correcting accessed data of storage device

    WO2017101283A1