A two-dimensional code generation and analysis method and device
By introducing interval regions and the arrangement of multi-value encoding units into the QR code, discrete QR codes are generated, which solves the problem of QR code decoding failure when the camera moves or the image is blurred, and achieves accurate decoding without the need for precise focusing.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- TSINGHUA UNIVERSITY
- Filing Date
- 2021-01-28
- Publication Date
- 2026-06-05
AI Technical Summary
Existing QR codes have difficulty focusing accurately when the camera is moving or the image is blurry, leading to decoding failure.
By introducing an interval area into the QR code to separate the coding units from each other, and by using an arrangement of multi-value coding units and positioning coding units, discrete QR codes are generated.
It improves the decoding accuracy of QR codes under blurred and motion conditions, enables correct segmentation and matching of coding units without the need for precise focusing, and enhances anti-blurring and anti-interference capabilities.
Smart Images

Figure CN112819122B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of QR code technology, and in particular to a method and apparatus for generating and parsing QR codes. Background Technology
[0002] In recent years, with the development of mobile phone technology, QR code scanning applications have developed comprehensively and have penetrated into all aspects of our daily lives.
[0003] QR codes evolved from one-dimensional barcodes, hence their formal name: two-dimensional barcodes. As the name suggests, two-dimensional barcodes are an extension and folding of one-dimensional barcodes. The commonly used QR code is officially called QuickResponse 2D Bar Code, a QR code encoding method jointly developed by international standardization organizations and national standards. Traditional two-dimensional barcodes contain tightly adjacent encoding units (e.g., ...). Figure 3 As shown in the image, it is a square QR code with multiple functional areas and encoding areas, including three positioning areas in the upper left, upper right, and lower left corners.
[0004] Since two-dimensional barcodes evolved from one-dimensional barcodes, their encoding method is the same: one code point represents one bit of data, with black and white representing 0 and 1. By combining the positioning symbols of the QR code, a machine can obtain a string of data composed of 0s and 1s, and decode it to get the information within.
[0005] With the widespread application of QR codes, numerous patents related to QR codes have emerged, mainly focusing on two directions. One is increasing code capacity, transforming a one-bit black-and-white image into a multi-bit color QR code. Some patents related to two-dimensional color barcodes from the last decade (e.g., CN201110119768.7A A Color Overlay QR Code System and Its Application Method, South China Agricultural University; CN2012100488571A Color Barcode and Color QR Code, Feng Shiwen) have developed one-bit black-and-white QR codes into multi-bit color QR codes, significantly increasing the information encoding capacity of QR codes. Another development direction for color codes is, while increasing capacity, applying QR codes to encryption, anti-counterfeiting, and other fields (e.g., CN201510572367.5A A Method for Generating, Decoding, and a Device for QR Codes, Alibaba Group Holding Limited). The large number of patent applications related to color QR codes reflects the significant progress and advancements China has made in the field of QR codes. Another patent (CN201380059381.4A QR code, Kyodo Printing Co., Ltd.) considers that QR codes are easily affected by noise and shaking during shooting, and discloses a QR code encoding method with four or more positioning patterns, which makes the positioning of QR codes more accurate and stronger in the recognition process.
[0006] However, existing QR code technologies require a clear and precise image focus for decoding, enabling the decoding system to accurately segment and read each encoded unit for subsequent decoding. This presents a technical problem: when the camera moves and focus is difficult, the resulting out-of-focus image cannot be recognized by the decoding system, thus preventing the QR code from being decoded. Summary of the Invention
[0007] The technical solution adopted by the present invention to solve the above-mentioned technical problems is, on the one hand, to provide a QR code generation method, including:
[0008] Based on the information to be encoded, determine the corresponding multiple coding units;
[0009] A QR code is generated, in which the plurality of encoding units are separated from each other by a gap.
[0010] Preferably, determining the corresponding multiple coding units based on the information to be encoded includes determining the multiple coding units corresponding to the information to be encoded based on N different preset coding units, where N>=2.
[0011] Preferably, generating the QR code includes determining four positioning coding units, arranging the plurality of coding units and the four positioning coding units into a two-dimensional array in the QR code, wherein the dimension value of the first dimension of the two-dimensional array is not equal to the dimension value of the second dimension, and the four positioning coding units are located at the four corners of the two-dimensional array, wherein the top left, bottom left, top right, and bottom right corner coding units represent the first value, the second value, the first value, and the second value, respectively.
[0012] Specifically, based on the information to be encoded, the corresponding multiple coding units are determined as follows:
[0013] Based on a pre-established database, an index code of an N-ary number corresponding to the information to be encoded is generated;
[0014] The plurality of coding units are determined based on the index code.
[0015] Specifically, based on the information to be encoded, the corresponding multiple coding units are determined as follows:
[0016] Based on the public code table of L-ary, generate the first index code of the L-ary number corresponding to the information to be encoded;
[0017] Convert the first index code into a second index code in base N;
[0018] The plurality of coding units are determined based on the second index code.
[0019] Secondly, a QR code parsing method is provided, including:
[0020] Obtain a QR code to be parsed, wherein the QR code includes multiple encoding units, and the multiple encoding units are separated from each other by a gap;
[0021] Information corresponding to the QR code is obtained based on the multiple encoding units.
[0022] Preferably, obtaining the information corresponding to the QR code based on the plurality of encoding units includes:
[0023] Determine the index code of the N-ary number based on multiple encoding units;
[0024] Based on the index code and the pre-established database, obtain the information corresponding to the QR code.
[0025] Preferably, obtaining the information corresponding to the QR code based on the plurality of encoding units includes:
[0026] Determine the third index code of the N-ary number based on multiple encoding units;
[0027] Convert the third index code into the fourth index code in base L;
[0028] The information corresponding to the QR code is determined based on the fourth index code and the public code table in base L.
[0029] Preferably, the QR code includes multiple encoding units, including acquiring multiple QR codes to be parsed from a lens;
[0030] The step of obtaining the information corresponding to the QR code based on the plurality of encoding units includes obtaining the information corresponding to each of the plurality of QR codes based on the plurality of encoding units included in each of the plurality of QR codes.
[0031] Thirdly, a QR code generation device is provided, comprising:
[0032] The coding unit determination unit is configured to determine multiple corresponding coding units based on the information to be encoded.
[0033] A QR code generation unit is configured to generate a QR code in which the plurality of encoding units are separated from each other by a gap.
[0034] Fourthly, a QR code parsing device is provided, comprising:
[0035] A QR code acquisition unit is configured to acquire a QR code to be parsed, wherein the QR code includes multiple encoding units, and the multiple encoding units are separated from each other by a gap;
[0036] The corresponding information acquisition unit is configured to acquire the information corresponding to the QR code based on the plurality of encoding units.
[0037] By utilizing any of the methods or devices described above, the technical problem of accurately interpreting the corresponding information from a QR code in a blurred image state can be effectively solved. Attached Figure Description
[0038] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0039] Figure 1 A flowchart of a QR code generation method provided in an embodiment of the present invention;
[0040] Figure 2 A flowchart of a QR code parsing method provided in an embodiment of the present invention;
[0041] Figure 3 A schematic diagram of a traditional QR code provided for an embodiment of the present invention;
[0042] Figure 4 A schematic diagram of a two-row, ten-column discrete four-value QR code provided in one embodiment of the present invention;
[0043] Figure 5 A schematic diagram of a three-row, eight-column discrete eight-value QR code provided in one embodiment of the present invention;
[0044] Figure 6 A schematic diagram of a four-row, ten-column discrete eight-value QR code provided in one embodiment of the present invention;
[0045] Figure 7 A schematic diagram of a four-row, six-column discrete binary QR code provided in one embodiment of the present invention;
[0046] Figure 8 This is a schematic diagram illustrating an implementation method for generating and parsing QR codes using a private index code, according to an embodiment of the present invention.
[0047] Figure 9 This is a schematic diagram illustrating an implementation method of a QR code generation and parsing method using a publicly available index code, according to an embodiment of the present invention.
[0048] Figure 10 This is a structural diagram of a QR code generation device provided in one embodiment of the present invention;
[0049] Figure 11This is a structural diagram of a QR code parsing device provided in one embodiment of the present invention; Detailed Implementation
[0050] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0051] The inventors, through analysis of numerous QR code patents, have shown that existing QR codes generally feature high encoding density, with tightly packed encoding units and no gaps between them, such as... Figure 1 As shown, the encoding units 1 of a traditional QR code are closely adjacent, with no gaps between them. Therefore, decoding a QR code requires a clear image focus and precise positioning so that the decoding system can accurately segment and read each encoding unit to achieve subsequent decoding. This encoding method is characterized by high density, i.e., a large amount of encoding per unit area, but suffers from common problems such as low noise and defocus resistance. The main reason is that the high-density two-dimensional encoding form limits the noise and defocus resistance performance of the encoding, ultimately resulting in the poor defocus resistance of current QR codes, which require accurate focusing before information can be read and decoded. When the camera moves and it is difficult to focus accurately, the defocused image acquired cannot be recognized by the decoding system, thus preventing the decoding of the QR code.
[0052] To address the problem of accurate QR code interpretation in blurred images caused by inaccurate focus or motion blur from moving cameras, this specification provides a method for generating and parsing discrete-unit QR codes. Unlike traditional 2D barcodes, this QR code contains non-coded intervals between its coded units, enabling accurate segmentation and matching of coded units even in blurry images due to defocus or motion. Furthermore, since these non-coded intervals reduce the space utilization of the coded area, this specification incorporates multi-valued units to shorten the QR code length, thereby reducing the consumption of coded space.
[0053] Figure 1 A flowchart of a QR code generation method provided by an embodiment of the present invention. As shown in the figure, the method includes at least the following steps:
[0054] Step 11: Based on the information to be encoded, determine the corresponding multiple coding units.
[0055] In this step, the information to be encoded is the information to be converted into the corresponding QR code, and the encoding unit is a multi-value encoding unit. A multi-value encoding unit refers to an encoding unit that can represent multiple values; that is, for an N-value encoding unit, N colors or patterns can be used to represent N values. Depending on the implementation, for an N-value encoding unit, any N colors or patterns, including black, white, gray, red, blue, green, and yellow, can be used to represent the N values. In specific examples, black, white, and gray can be preferentially chosen to represent specific values among the N values. It is understood that in other embodiments, the number of colors / patterns used to constitute the encoding unit can be increased to achieve an encoding unit with more values.
[0056] Specifically, in different embodiments, the multi-value encoding unit can be implemented in different ways, for example, 2-valued (e.g., Figure 7 The QR code in the illustrated embodiment includes 2-value encoding units, 3-value encoding units, and 4-value encoding units (such as...). Figure 4 The QR code in the illustrated embodiment contains 4-value encoding units and 8-value (e.g., ...) Figure 4 The encoding unit in the illustrated embodiment includes an 8-value encoding unit and a 16-value encoding unit.
[0057] In one embodiment, multiple coding units corresponding to the information to be encoded can be determined based on N different preset coding units, where N>=2.
[0058] According to one implementation, a private code table recording the information to be encoded and the corresponding index code can be stored in a pre-established database. Therefore, in one example of this implementation, an N-ary index code corresponding to the information to be encoded can be generated based on the pre-established database.
[0059] The plurality of coding units are determined based on the index code.
[0060] In one specific example, the index code of the N-ary number corresponding to the information to be encoded can be obtained from a pre-established database. In another specific example, the index code of another number base corresponding to the information to be encoded can be obtained from a pre-established database, and then converted into an N-ary number index code.
[0061] According to another implementation, the index code corresponding to the information to be encoded can also be obtained using a public code table. Therefore, in one example of this implementation, a first index code of an L-ary number corresponding to the information to be encoded can be generated based on a public L-ary code table.
[0062] Convert the first index code into the second index code of the N-ary number;
[0063] The plurality of coding units are determined based on the second index code.
[0064] Step 12: Generate a QR code, in which the multiple encoding units are separated from each other by a gap.
[0065] The intervening region is the area between the coding units in the QR code. Due to the existence of the intervening region, the coding units in the QR code are not in close contact spatially. Therefore, even with a blurred image of the QR code captured under conditions such as defocus or motion, accurate image segmentation and matching can be performed more easily to obtain the QR code's coding units. In other words, the QR code generated using this method has better resistance to blurring and interference. Furthermore, given the spatial discreteness between the coding units of this QR code, this specification also refers to this QR code as a discrete multi-valued QR code.
[0066] In one embodiment, the color of the spacing region is chosen to be different from that of the encoding unit, and a color with high distinguishability, thereby creating a large contrast in color and brightness between the encoding unit and its background non-encoding area, which is beneficial for visual detection. In one example, the four-color encoding unit of the QR code is red, green, blue, and white, then the color of the spacing region can be black, dark blue, or dark green. In another example, the width of the spacing region between adjacent encoding units is 1 / 2 to 1 / 4 of the width of the encoding unit.
[0067] In one embodiment, four positioning coding units can be determined. Multiple coding units and the four positioning coding units are arranged into a two-dimensional array in the QR code. The first dimension of the two-dimensional array is not equal to the second dimension. The four positioning coding units are located at the four corners of the two-dimensional array, where the top-left, bottom-left, top-right, and bottom-right corner coding units represent the first value, the second value, the first value, and the second value, respectively. Since the first dimension of the two-dimensional array is not equal to the second dimension, i.e., the QR code is rectangular, the positioning area only needs to determine the vertical direction of the QR code. In other embodiments, only two or three of the above four positioning coding units can be determined to determine the vertical direction of the QR code. For example, only the top-left and top-right corner coding units can be determined to determine the vertical direction of the QR code.
[0068] In one specific embodiment, four positioning coding units are determined, wherein the value represented by the top left coding unit is 0, the value represented by the bottom left coding unit is non-zero, the value represented by the top right coding unit is 0, and the value represented by the bottom right coding unit is non-zero.
[0069] Figure 2 This is a flowchart illustrating a QR code parsing method provided in an embodiment of the present invention. Figure 2As shown, the method includes at least the following steps:
[0070] Step 21: Obtain the QR code to be parsed, wherein the QR code includes multiple encoding units, and the multiple encoding units are separated from each other by a gap;
[0071] In this step, the QR code to be parsed, the encoding unit, and the interval area are as described above. Figure 1 The QR code, encoding unit, and interval area described in steps 11 and 12 will not be repeated here.
[0072] In one embodiment, the plurality of coding units may be determined based on a preset set of N different coding units, where N>=2.
[0073] In one embodiment, the QR code may include four positioning encoding units. The plurality of encoding units and the four positioning encoding units are arranged in a two-dimensional array. The first dimension of the two-dimensional array is not equal to the second dimension. The four positioning encoding units are located at the four corners of the two-dimensional array, where the top-left, bottom-left, top-right, and bottom-right corner encoding units represent the first value, the second value, the first value, and the second value, respectively. In one example, the four positioning encoding units at the four corners of the two-dimensional array can be removed to obtain the plurality of encoding units.
[0074] Step 22: Obtain the information corresponding to the QR code based on the plurality of encoding units;
[0075] For example Figure 1 In step 11, the implementation method of storing the private code table in a pre-established database can determine the index code of the N-ary number based on multiple encoding units; and obtain the information corresponding to the QR code based on the index code and the pre-established database.
[0076] For example Figure 1 In step 11, using the public code table implementation method, the third index code of the N-ary number can be determined based on multiple coding units; the third index code can be converted into the fourth index code of the L-ary number; and the information corresponding to the QR code can be determined based on the fourth index code and the public code table of the L-ary number.
[0077] In actual production, there may be situations where multiple QR codes appear on a single image (within a single lens). Among these QR codes, some may be clear, some blurry, and some may all be blurry; generally, it's difficult to ensure that all QR codes are clear. Therefore, existing QR code readers must select one QR code and focus on it before reading. However, the QR code parsing method provided in this invention has excellent anti-blurring properties, thus eliminating the need for focusing and enabling the reading and decoding of all blurry codes, achieving multi-code simultaneous reading.
[0078] Therefore, in one embodiment, multiple QR codes to be parsed in a lens can be obtained; and information corresponding to each of the multiple QR codes can be obtained based on the multiple encoding units included in each of the multiple QR codes.
[0079] In one example, after obtaining a pattern containing multiple discrete multi-valued QR codes, a multi-code co-reading technique can be used to read and decode multiple discrete multi-valued QR codes within a single lens using a color camera, thereby obtaining the corresponding information for all discrete multi-valued QR codes.
[0080] Figure 8 This is a schematic diagram illustrating an implementation method for QR code generation and parsing using a private index code, as provided in one embodiment of the present invention. Figure 8 As shown, the QR code generation method includes the following process:
[0081] Establish a database 15 for the information 14 that needs to be encoded, and create a decimal numerical index code for each piece of information;
[0082] Choose an encoding method and code length for an encoding unit. For example, if you choose a 4-value encoding unit, the QR code encoding matrix is 4 rows and 9 columns, then the code length is 32 (4*9 – 4, which is the encoding unit of the 4 rows * 9 columns encoding matrix – the positioning encoding unit at the 4 corners).
[0083] Based on the selected encoding unit value, the decimal index code is converted to the radix of the encoding unit's index code. For example, if a 4-value encoding unit is selected in the second step, this third step will convert the decimal index code to a 4-base index code.
[0084] Each bit of the converted index code represents a coding unit. If the index code length is insufficient, zeros are added in front of the index code.
[0085] The zero-padded index code is converted into encoding units according to its value and arranged to form a discrete QR code 12.
[0086] The QR code generated by the above QR code generation method, and the corresponding QR code parsing method, include the following steps:
[0087] Obtain image 18 of the QR code and arrange all the coding units into a row from left to right and from top to bottom;
[0088] The encoded unit is converted into the number it represents, resulting in a string of numbers;
[0089] Use the obtained number as an index code and input it into its corresponding database 15;
[0090] The database converts the input index code into decimal based on the index code base, and provides the information corresponding to the index code based on the value of the obtained decimal index code, thereby decoding to obtain the encoded information 14.
[0091] like Figure 8 As shown, this embodiment also provides a QR code generation system and a parsing system. The generation system includes a computer 16, an encoded information database 15, and an output device 13. The index code of the information 14 to be encoded is processed by the computer to generate a multi-value discrete QR code pattern 12, which is then output through the output device and affixed to the location to be encoded. The parsing system includes a color camera (not shown in the figure), a computer, and the encoded information database 15. The color camera acquires the multi-value discrete QR code pattern 18, which is then decoded by the computer 16 to obtain the index code, and the encoded information 14 is retrieved from the database or code table.
[0092] In one embodiment, multiple QR codes (discrete multi-value QR codes) within a single lens can be read and parsed simultaneously using multi-code co-reading technology, thereby obtaining the encoding information of all QR codes.
[0093] Figure 9 This is a schematic diagram illustrating an embodiment of the QR code generation and parsing method provided by the present invention, utilizing a publicly available index code. For example... Figure 9 As shown, the QR code generation method includes the following process:
[0094] Choose a publicly available code table 17 and determine the character set to be encoded based on the code table. For example, in one example, the code table is selected using ASCII codes for 128 characters. In another example, the code table is selected using ASCII codes for 256 characters.
[0095] Choose an encoding method and code length for an encoding unit. For example, in one case, if a 4-value encoding unit is chosen, the QR code encoding matrix is 4 rows and 9 columns, then the code length is 32 (4*9 – 4, that is, the encoding unit of the 4 rows * 9 columns encoding matrix – the positioning encoding unit of the 4 corners).
[0096] The information that needs to be encoded is converted into the corresponding code value according to the selected public code table;
[0097] Each bit of the converted code value is converted into the base of the encoding unit to obtain the information code. If the code length of the information code to be encoded is insufficient, a space character is added before or after the information code.
[0098] The information code after the padding characters is converted into encoding units according to their values and arranged to form a multi-value discrete QR code 12.
[0099] The QR code generated by the above QR code generation method, and the corresponding QR code parsing method, include the following steps:
[0100] Obtain the multi-value discrete QR code 18, and arrange all its coding units into a row from left to right and from top to bottom;
[0101] Based on the base of the encoding unit, the encoding unit is converted into a number in its corresponding base to obtain a string of numbers;
[0102] Depending on the selected public code table 17 and the different bases of the encoding units, multiple combinations of numbers are taken from left to right for the string of numbers, and converted to obtain the public code table index code (e.g., binary, decimal, or hexadecimal public code table index code).
[0103] Based on the obtained index code value, the string is obtained from the publicly available encoding table, and the encoded information is decoded to obtain the encoded information 14.
[0104] like Figure 9 As shown, this embodiment also provides a QR code generation system and a parsing system. The generation system includes a computer 16, a public code table 17, and an output device 13. The information 14 to be encoded is processed by the computer, generating an index code and a corresponding multi-value discrete QR code pattern 12 according to the public code table 17. This pattern is then output through the output device and affixed to the location to be encoded. The parsing system includes a color camera (not shown in the figure), a computer, and an encoded information database 15. The color camera acquires the multi-value discrete QR code pattern 18, which is then decoded by the computer 16 to obtain the index code. The encoded information 14 is then retrieved from the database or code table.
[0105] The method is further illustrated below through several specific embodiments.
[0106] Figure 4 This is a schematic diagram of a two-row, ten-column discrete four-value QR code provided in one embodiment of the present invention; as shown. Figure 4 As shown, in this embodiment, the multi-value encoding units (specifically, the four-value encoding units) 2, 3, 4, and 5 are squares, representing four encoding values 0, 1, 2, and 3, respectively. The four-value encoding units 2, 3, 4, and 5, as well as the non-encoding interval area 6, are composed of five colors or patterns, including any five colors from a variety of colors or patterns such as black, white, gray, red, blue, green, and yellow.
[0107] The selection of the non-coding interval region 6 differs from that of the coding unit. In one example, it is chosen to have a color with a higher distinguishability than a predetermined value compared to the coding unit, thereby creating a large color and brightness contrast between the coding unit and its background non-coding region, which is beneficial for visual inspection. This specification does not limit the specific method for measuring color distinguishability. In one example, the width of the non-coding interval region between adjacent coding units is 1 / 2 to 1 / 4 of the width of the coding unit.
[0108] The positioning area consists of positioning coding units at the top left, bottom left, top right, and bottom right corners of the QR code. The value 0 represented by the top left positioning coding unit is less than the value 2 represented by the bottom left positioning coding unit, and the value 0 represented by the top right positioning coding unit is less than the value 2 represented by the bottom right positioning coding unit. Since the QR code is rectangular, the positioning area only needs to determine the top and bottom of the QR code.
[0109] Based on the above method, such as Figure 4 As shown, the 16-bit quaternary value corresponding to the QR code in this embodiment is: 1021320131020312.
[0110] In one example, the QR code can be generated and parsed using a private index code. The corresponding generation methods include:
[0111] Establish a database for the information that needs to be encoded, and create a 16-bit 4-ary numerical index code for each piece of information.
[0112] Choose a 4-value coding unit, a 2-row, 10-column coding matrix;
[0113] Each piece of information is encoded by creating a 16-bit 4-ary numerical index code, which is then converted into a 2-row, 10-column encoding matrix.
[0114] The corresponding parsing methods include:
[0115] The image is acquired and the orientation of the 2-row, 10-column discrete QR code is determined based on the values of the four corner positioning units;
[0116] After removing the four corner coding units, the remaining 16 coding units are converted into their corresponding values. All coding units are arranged in a row from left to right and from top to bottom to obtain a string of numbers.
[0117] The obtained number is used as an index code and input into its corresponding database;
[0118] The database provides the information corresponding to the index code based on the index code's value, thus achieving decoding.
[0119] Figure 5 This is a schematic diagram of a three-row, eight-column discrete eight-value QR code provided in one embodiment of the present invention; as shown. Figure 5 As shown, in this embodiment, the multi-value encoding units (specifically, eight-value encoding units) 2, 3, 4, 5, 8, 9, 10, and 11 are squares, representing eight encoding values: 0, 1, 2, 3, 4, 5, 6, and 7, respectively. The eight-value encoding units 2, 3, 4, 5, 8, 9, 10, and 11, as well as the non-encoding interval 6, are composed of nine colors or patterns, including any nine colors from a variety of colors or patterns such as black, white, gray, red, blue, green, and yellow.
[0120] The color selection for the non-coding interval 6 differs from that of the coding unit. In one example, the selected color has a higher distinguishability than a predetermined value compared to the coding unit, resulting in a large color and brightness contrast between the coding unit and its background non-coding area, which is beneficial for visual inspection. This specification does not specify the exact method for measuring color distinguishability. In one example, the width of the non-coding interval between adjacent coding units is 1 / 2 to 1 / 4 of the width of the coding unit.
[0121] The positioning area consists of positioning coding units at the top left, bottom left, top right, and bottom right corners of the QR code. The value 0 represented by the top left positioning coding unit is less than the value 2 represented by the bottom left positioning coding unit, and the value 0 represented by the top right positioning coding unit is less than the value 2 represented by the bottom right positioning coding unit. Since the QR code is rectangular, the positioning area only needs to determine the top and bottom of the QR code.
[0122] Based on the above method, such as Figure 5 As shown, the 20-bit octal value corresponding to the QR code in this embodiment is: 10243256405764175213.
[0123] In one example, the QR code can be generated and parsed using a private index code. The corresponding generation methods include:
[0124] Establish a database for the information that needs to be encoded, and create a 20-bit octal numerical index code for each piece of information.
[0125] Choose an 8-value encoding unit, and a 3x8 encoding matrix;
[0126] Each piece of information is encoded by creating a 20-bit octal numerical index code, which is then converted into a 3x8 encoding matrix.
[0127] The corresponding parsing methods include:
[0128] The image is acquired and the orientation of the 3-row, 8-column discrete QR code is determined based on the values of the four corner positioning units;
[0129] After removing the four corner coding units, the remaining 20 coding units are converted into their corresponding values. All coding units are arranged in a row from left to right and from top to bottom to obtain a string of numbers.
[0130] The obtained number is used as an index code and input into its corresponding database;
[0131] The database provides the information corresponding to the index code based on the index code's value, thus achieving decoding.
[0132] Figure 6 This is a schematic diagram of a four-row, ten-column discrete eight-value QR code provided in one embodiment of the present invention; as shown. Figure 6 As shown, in this embodiment, the multi-value encoding units (specifically, eight-value encoding units) 2, 3, 4, 5, 8, 9, 10, and 11 are squares, representing eight encoding values: 0, 1, 2, 3, 4, 5, 6, and 7, respectively. The eight-value encoding units 2, 3, 4, 5, 8, 9, 10, and 11, as well as the non-encoding interval 6, are composed of nine colors or patterns, including any nine colors from black, white, gray, red, blue, green, and yellow.
[0133] The color selection for the non-coding interval 6 differs from that of the coding unit. In one example, the selected color has a higher distinguishability than a predetermined value compared to the coding unit, resulting in a large color and brightness contrast between the coding unit and its background non-coding area, which is beneficial for visual inspection. This specification does not specify the exact method for measuring color distinguishability. In one example, the width of the non-coding interval between adjacent coding units is 1 / 2 to 1 / 4 of the width of the coding unit.
[0134] The positioning area consists of positioning coding units at the top left, bottom left, top right, and bottom right corners of the QR code. The value 0 represented by the top left positioning coding unit is less than the value 2 represented by the bottom left coding unit, and the value 0 represented by the top right positioning coding unit is less than the value 2 represented by the bottom right positioning coding unit. Since the QR code is rectangular, the positioning area only needs to determine the top and bottom of the QR code.
[0135] Based on the above method, such as Figure 5 As shown, the 36-bit octal value corresponding to the QR code image in this embodiment is: 256452575051664556575267466364526572.
[0136] In one example, the QR code can be generated and parsed using a public code table. The corresponding generation methods include:
[0137] Choose a publicly available code table and determine the character set to be encoded based on the code table. In this embodiment, ASCII code is chosen as the code table.
[0138] Choose an encoding method and code length for the encoding unit. In this embodiment, an 8-value encoding unit is selected. The QR code encoding matrix is 4 rows and 10 columns, so the code length is 36 bits.
[0139] The text that needs to be encoded, including uppercase and lowercase English letters and symbols, is converted into corresponding code values according to the selected ASCII code table, and 77 (octal) is subtracted from each converted code value.
[0140] Each bit value obtained in the previous step is converted into a color or symbol representing the corresponding value of the encoding unit. If the code length of the information code to be encoded is insufficient, padding is done with blank characters before or after the information code.
[0141] The corresponding parsing methods include:
[0142] Acquire discrete QR code images and determine the orientation of the discrete QR codes based on the positioning units;
[0143] Based on the base of the encoding unit, the encoding unit is converted into a number in its corresponding base, and all the numbers are arranged in a row from left to right and from top to bottom to obtain a string of numbers. In this embodiment, the obtained number string is: 256452575051664556575267466364526572;
[0144] Each two digits of this number string represent an ASCII code, namely: 25 64 52 57 50 51 66 45 56 57 52 6746 63 64 52 65 72.
[0145] Adding 77 (octal) to each code in the number string yields the following ASCII codes: 124 163 151 156 147 150 165 141 125 156 151 166 145 162 163 151 164 171;
[0146] The string is retrieved from the ASCII table based on the obtained index code value, thus achieving decoding. In this embodiment, the string retrieved from the ASCII table is the aforementioned numeric string:
[0147] Tsinghua University.
[0148] Figure 7 This is a schematic diagram of a four-row, six-column discrete binary QR code provided as an embodiment of the present invention; for example... Figure 7 As shown, in this embodiment, the binary encoding units 2 and 7 are squares, representing two encoded values, 0 and 1, respectively. The binary encoding units 2 and 7, as well as the non-encoded interval area 6, are composed of three colors or patterns, including any three colors from a variety of colors or patterns such as black, white, gray, red, blue, green, and yellow.
[0149] The color selection for the non-coding interval 6 differs from that of the coding unit. In one example, the selected color has a higher distinguishability than a predetermined value compared to the coding unit, resulting in a large color and brightness contrast between the coding unit and its background non-coding area, which is beneficial for visual inspection. This specification does not specify the exact method for measuring color distinguishability. In one example, the width of the non-coding interval between adjacent coding units is 1 / 2 to 1 / 4 of the width of the coding unit.
[0150] The positioning area consists of positioning coding units at the top left, bottom left, top right, and bottom right corners of the QR code. The positioning coding units at the top left and top right corners represent a value of 0, while the positioning coding units at the bottom left and bottom right corners represent non-zero values. Since the QR code is rectangular, the positioning area only needs to determine the top and bottom of the QR code.
[0151] Based on the above method, such as Figure 4 As shown, the 20-bit binary value corresponding to the QR code in this embodiment is: 10111010101011011100
[0152] The maximum number it can encode is 2^20 = 1,048,576.
[0153] In one example, the QR code can be generated and parsed using a private index code. The corresponding generation methods include:
[0154] Establish a database for the information that needs to be encoded, and create a 20-bit binary numerical index code for each piece of information;
[0155] Choose a binary encoding unit, a 4x6 encoding matrix;
[0156] The 20-bit binary index code corresponding to each piece of information is converted into a 4-row, 6-column binary encoding matrix to achieve encoding.
[0157] The corresponding parsing methods include:
[0158] The image is acquired and the orientation of the 4-row, 6-column discrete QR code is determined based on the values of the four corner positioning units;
[0159] After removing the four corner coding units, the remaining 20 coding units are converted into their corresponding values. All coding units are arranged in a row from left to right and from top to bottom to obtain a string of binary numbers.
[0160] The obtained number is used as an index code and input into its corresponding database;
[0161] The database provides the information corresponding to the index code based on the index code's value, thus achieving decoding.
[0162] Figure 10 This is a structural diagram of a QR code generation device provided in one embodiment of the present invention. Figure 10 As shown, the device 1000 includes:
[0163] The coding unit determining unit 101 is configured to determine multiple corresponding coding units based on the information to be encoded.
[0164] The QR code generation unit 102 is configured to generate a QR code in which the plurality of encoding units are separated from each other by a gap.
[0165] Figure 11 This is a structural diagram of a QR code parsing device provided in one embodiment of the present invention. Figure 11 As shown, the device 1100 includes:
[0166] The QR code acquisition unit 111 is configured to acquire a QR code to be parsed, wherein the QR code includes multiple encoding units, and the multiple encoding units are separated from each other by a gap;
[0167] The corresponding information acquisition unit 112 is configured to acquire the information corresponding to the QR code based on the plurality of encoding units.
[0168] The foregoing has described 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 may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.
[0169] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.
[0170] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented in hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.
[0171] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for generating a QR code, comprising: Based on the information to be encoded, determine the corresponding multiple coding units; A QR code is generated, in which the plurality of encoding units are separated from each other by a gap, the color of the gap being more distinct from the color of the encoding unit than a predetermined value, and the width of the gap between adjacent encoding units being 1 / 4 to 1 / 2 of the width of the encoding unit; the generation of the QR code includes determining four positioning encoding units, arranging the plurality of encoding units and the four positioning encoding units into a two-dimensional array in the QR code, wherein the dimension value of the first dimension of the two-dimensional array is not equal to the dimension value of the second dimension, and the four positioning encoding units are located at the four corners of the two-dimensional array, wherein the top left, bottom left, top right, and bottom right corner encoding units represent the first value, the second value, the first value, and the second value, respectively.
2. The method according to claim 1, wherein, Based on the information to be encoded, the corresponding multiple coding units are determined, including determining multiple coding units corresponding to the information to be encoded based on N different preset coding units, where N>=2.
3. The method according to claim 1, wherein, Based on the information to be encoded, the corresponding multiple coding units are determined to include: Based on a pre-established database, an index code of an N-ary number corresponding to the information to be encoded is generated; The plurality of coding units are determined based on the index code.
4. The method according to claim 1, wherein, Based on the information to be encoded, the corresponding multiple coding units are determined to include: Based on the public code table of L-ary, generate the first index code of the L-ary number corresponding to the information to be encoded; Convert the first index code into a second index code in base N; The plurality of coding units are determined based on the second index code.
5. A QR code parsing method, comprising: A QR code to be parsed is obtained. The QR code includes multiple encoding units, which are separated by intervals. The color of the interval is more distinct from the color of the encoding unit than a predetermined value. The width of the interval between adjacent encoding units is 1 / 4 to 1 / 2 of the width of the encoding unit. The QR code also includes four positioning encoding units. The multiple encoding units and the four positioning encoding units are arranged in a two-dimensional array. The first dimension of the two-dimensional array is not equal to the second dimension. The four positioning encoding units are located at the four corners of the two-dimensional array, where the top left, bottom left, top right, and bottom right corner encoding units represent the first value, the second value, the first value, and the second value, respectively. Information corresponding to the QR code is obtained based on the multiple encoding units.
6. The method according to claim 5, wherein, Obtaining the information corresponding to the QR code based on the multiple encoding units includes: Determine the index code of the N-ary number based on multiple encoding units; Based on the index code and the pre-established database, obtain the information corresponding to the QR code.
7. The method according to claim 5, wherein, Obtaining the information corresponding to the QR code based on the multiple encoding units includes: Determine the third index code of the N-ary number based on multiple encoding units; Convert the third index code into the fourth index code in base L; The information corresponding to the QR code is determined based on the fourth index code and the public code table in base L.
8. The method according to claim 5, wherein obtaining the QR code to be parsed, the QR code comprising multiple encoding units, includes obtaining multiple QR codes to be parsed from a lens; The step of obtaining the information corresponding to the QR code based on the plurality of encoding units includes obtaining the information corresponding to each of the plurality of QR codes based on the plurality of encoding units included in each of the plurality of QR codes.
9. A QR code generating device, comprising: The coding unit determination unit is configured to determine multiple corresponding coding units based on the information to be encoded. A QR code generation unit is configured to generate a QR code in which multiple encoding units are separated from each other by a gap, the color of the gap being more distinct from the color of the encoding unit than a predetermined value, and the width of the gap between adjacent encoding units being 1 / 4 to 1 / 2 of the width of the encoding unit. Generating the QR code includes determining four positioning encoding units, arranging the multiple encoding units and the four positioning encoding units into a two-dimensional array in the QR code, wherein the dimension value of the first dimension of the two-dimensional array is not equal to the dimension value of the second dimension, and the four positioning encoding units are located at the four corners of the two-dimensional array, wherein the top-left, bottom-left, top-right, and bottom-right corner encoding units represent a first value, a second value, a first value, and a second value, respectively.
10. A QR code parsing device, comprising: A QR code acquisition unit is configured to acquire a QR code to be parsed. The QR code includes multiple encoding units separated by intervals. The color of the intervals is more distinct from the color of the encoding units than a predetermined value. The width of the intervals between adjacent encoding units is 1 / 4 to 1 / 2 of the width of the encoding units. The QR code also includes four positioning encoding units. The multiple encoding units and the four positioning encoding units are arranged in a two-dimensional array. The first dimension of the two-dimensional array is not equal to the second dimension. The four positioning encoding units are located at the four corners of the two-dimensional array, where the top-left, bottom-left, top-right, and bottom-right corner encoding units represent the first value, the second value, the first value, and the second value, respectively. The corresponding information acquisition unit is configured to acquire the information corresponding to the QR code based on the plurality of encoding units.