A two-dimensional code encoding and decoding method, device, equipment and medium

By setting anchor sub-squares in the QR code template and using its position information, the recognition problem of QR codes under image distortion is solved, efficient anti-distortion recognition is achieved, and the correct recognition rate of QR codes is improved.

CN114399010BActive Publication Date: 2024-08-27CHINA TELECOM CORP LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111639976.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-29
Publication Date
2024-08-27
Estimated Expiration
2041-12-29

AI Technical Summary

Technical Problem

Existing QR codes are difficult to recognize correctly when the image is distorted, resulting in a low recognition rate.

Method used

By setting anchor sub-squares in the QR code template and determining the position information of the sub-regions and sub-squares based on the position information of the anchor sub-squares, anti-distortion recognition of the QR code image is achieved.

Benefits of technology

The anti-distortion ability of the QR code is improved, ensuring that the QR code image can be accurately recognized when the image is tilted, stretched, etc., and the correct recognition rate is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114399010B
    Figure CN114399010B
Patent Text Reader

Abstract

The present application discloses a two-dimensional code encoding and decoding method, device, equipment and medium, which are used to improve the correct recognition rate of the two-dimensional code. Since the two-dimensional code template of the present application includes a second number of sub-regions, each sub-region includes a third number of sub-grids, and for each sub-region, the sub-grid at a set position in the sub-region is configured as an anchor sub-grid, the present application can locate the two-dimensional code image based on the anchor sub-grid, and when the two-dimensional code image is subsequently decoded, even when the two-dimensional code image is scanned at different angles, so that the two-dimensional code image displayed in the collected image is distorted, each sub-region and sub-grid contained in the two-dimensional code image can still be determined based on the anchor sub-grid, so that the data information carried by each sub-grid in the two-dimensional code image can be restored to the greatest extent, the anti-distortion ability of the two-dimensional code image can be improved, and the correct recognition rate of the two-dimensional code can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data service technology, and in particular to a two-dimensional code encoding and decoding method, device, equipment and medium. Background Art

[0002] One-dimensional codes express information through bars and spaces arranged in the horizontal direction, but not in the vertical direction, so their capacity is very limited. Two-dimensional codes can express information in both the horizontal and vertical directions, so they can express more information in a smaller area than one-dimensional codes. At the same time, by applying error correction algorithms to two-dimensional codes, the reliability of two-dimensional codes is greatly increased. In recent years, the application of two-dimensional codes has become more and more widespread, and has been rapidly popularized in people's daily lives, providing great convenience to people's lives.

[0003] Although QR codes have been widely promoted, they still have certain limitations in many scenarios, the most prominent of which is the lack of ability to resist image distortion. For example, when the QR code image is scanned at different angles, the QR code image displayed in the captured image may be tilted, stretched, or distorted, making it difficult to correctly identify the QR code, reducing the correct recognition rate of the QR code.

[0004] Therefore, how to improve the correct recognition rate of QR codes is a technical problem that urgently needs to be solved. Summary of the invention

[0005] The present application provides a two-dimensional code encoding and decoding method, device, equipment and medium to improve the correct recognition rate of two-dimensional codes.

[0006] In a first aspect, the present application provides a two-dimensional code encoding method, the method comprising:

[0007] If a two-dimensional code encoding instruction is received, the data to be transmitted and the data volume of the data to be transmitted carried in the encoding instruction are obtained; according to the data volume and the predetermined data carrying capacity of a two-dimensional code template, a first number of two-dimensional code templates required to transmit the data to be transmitted is determined; wherein each two-dimensional code template contains a preset second number of sub-regions, each of the sub-regions contains a preset third number of sub-squares, and for each of the sub-regions, a sub-square at a set position in the sub-region is configured as an anchor sub-square, and the anchor sub-square is configured as a set first color value;

[0008] Determine, according to the first quantity and the data to be transmitted, the sub-data to be transmitted corresponding to each two-dimensional code template to be encoded;

[0009] For each of the two-dimensional code templates, the sub-carrying data corresponding to each sub-square carrying data in the two-dimensional code template is determined according to the sub-data to be transmitted corresponding to the two-dimensional code template and the sorting order of each sub-square in the two-dimensional code template; and each sub-square carrying data is configured as the second color value corresponding to the corresponding sub-carrying data.

[0010] In a second aspect, the present application provides a two-dimensional code decoding method, the method comprising:

[0011] If a two-dimensional code decoding instruction is received, first position information of each anchor point sub-square contained in at least one two-dimensional code image is respectively identified based on a first color value configured in a preset anchor point sub-square;

[0012] For each two-dimensional code image, based on the first position information of each anchor sub-square contained in the two-dimensional code image, determine the second position information of the sub-region to which each anchor sub-square belongs;

[0013] For each of the sub-regions, determine the number of sub-squares contained in the sub-region, and determine third position information of the sub-squares contained in the sub-region;

[0014] According to the third position information of the sub-square in each sub-region, the sub-bearing data corresponding to the second color value configured in each sub-square of the third position information in the two-dimensional code image is read; according to the combination order of the sub-squares in the preset sub-region, the sub-bearing data corresponding to each sub-square carrying data is combined to obtain the data carried by the two-dimensional code image, and the data is saved.

[0015] In a third aspect, the present application provides a two-dimensional code encoding device, the device comprising:

[0016] A first determination module is configured to, if a two-dimensional code encoding instruction is received, obtain the data to be transmitted and the data volume of the data to be transmitted carried in the encoding instruction; determine a first number of two-dimensional code templates required to transmit the data to be transmitted according to the data volume and a predetermined data carrying capacity of a two-dimensional code template; wherein each two-dimensional code template includes a preset second number of sub-regions, each of the sub-regions includes a preset third number of sub-squares, and for each of the sub-regions, a sub-square at a set position in the sub-region is configured as an anchor sub-square, and the anchor sub-square is configured as a set first color value;

[0017] A second determining module, configured to determine the sub-data to be transmitted corresponding to each two-dimensional code template to be encoded according to the first quantity and the data to be transmitted;

[0018] A configuration module is used to determine, for each of the two-dimensional code templates, the sub-bearing data corresponding to each sub-square that carries data in the two-dimensional code template according to the sub-data to be transmitted corresponding to the two-dimensional code template and the sorting order of each sub-square in the two-dimensional code template; and configure each sub-square that carries data to the second color value corresponding to the respective corresponding sub-bearing data.

[0019] In a fourth aspect, the present application provides a two-dimensional code decoding device, the device comprising:

[0020] an identification module, configured to, upon receiving a two-dimensional code decoding instruction, respectively identify first position information of each anchor point sub-square contained in at least one two-dimensional code image based on a first color value configured in a preset anchor point sub-square;

[0021] A third determination module is used to determine, for each two-dimensional code image, second position information of the sub-region to which each anchor sub-square belongs based on the first position information of each anchor sub-square contained in the two-dimensional code image;

[0022] A fourth determination module, configured to determine, for each of the sub-regions, the number of sub-squares contained in the sub-region, and determine third position information of the sub-squares contained in the sub-region;

[0023] The reading module is used to read the sub-bearing data corresponding to the second color value configured in each sub-square of the third position information in the two-dimensional code image according to the third position information of the sub-square in each sub-region, and according to the combination order of the sub-squares in the preset sub-region, combine the sub-bearing data corresponding to each sub-square that carries the data to obtain the data carried by the two-dimensional code image, and save it.

[0024] In a fifth aspect, the present application provides an electronic device, which includes at least a processor and a memory, and the processor is used to implement the steps of any of the above-mentioned two-dimensional code encoding methods when executing a computer program stored in the memory, or to implement the steps of any of the above-mentioned two-dimensional code decoding methods.

[0025] In a sixth aspect, the present application provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of any one of the above-mentioned two-dimensional code encoding methods, or implements the steps of any one of the above-mentioned two-dimensional code decoding methods.

[0026] The two-dimensional code template of the present application includes a second number of sub-regions, each of which includes a third number of sub-squares, and for each sub-region, the sub-square at a set position in the sub-region is configured as an anchor sub-square, and the anchor sub-square is configured as a set first color value. When receiving a two-dimensional code encoding instruction and performing two-dimensional code encoding, the data to be transmitted and the data volume of the data to be transmitted carried in the encoding instruction can be obtained; according to the data volume of the data to be transmitted and the data carrying capacity of a predetermined two-dimensional code template, the first number of two-dimensional code templates required to transmit the data to be transmitted is determined; according to the first number and the data to be transmitted, the sub-data to be transmitted corresponding to each two-dimensional code template to be encoded is determined; for each two-dimensional code template, according to the sub-data to be transmitted corresponding to the two-dimensional code template and the sorting order of each sub-square in the two-dimensional code template, the sub-bearing data corresponding to each sub-square carrying data in the two-dimensional code template is determined; and each sub-square carrying data is configured as the second color value corresponding to the respective corresponding sub-bearing data. Since the present application can locate the two-dimensional code image based on the anchor point sub-squares, when the two-dimensional code image is subsequently decoded, the second position information of each sub-region can be determined based on the first position information of each anchor point sub-square, and then the third position information of the sub-squares contained in each sub-region can be determined. Therefore, even when the two-dimensional code image is scanned at different angles, such as when the two-dimensional code image displayed in the captured image has certain distortion phenomena such as tilt and stretching, the position information of each sub-region and sub-square contained in the two-dimensional code image can be determined based on the anchor point sub-squares, so that the data information carried by each sub-square in the two-dimensional code image can be identified (restored) to the greatest extent, the anti-distortion capability of the two-dimensional code image can be improved, the correct identification of the two-dimensional code can be guaranteed to the greatest extent, the two-dimensional code can be identified quickly and accurately, and the correct recognition rate of the two-dimensional code can be improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] In order to more clearly illustrate the implementation methods in the embodiments of the present application or the related technologies, the following is a brief introduction to the drawings required for use in the embodiments or the related technology descriptions. Obviously, the drawings described below are some embodiments of the present application, and a person skilled in the art can also obtain other drawings based on these drawings.

[0028] Figure 1 A schematic diagram of a two-dimensional code encoding process provided by some embodiments is shown;

[0029] Figure 2a A schematic diagram of a two-dimensional code template provided by some embodiments is shown;

[0030] Figure 2b A schematic diagram of a sub-region provided by some embodiments is shown;

[0031] Figure 3 A schematic diagram of a two-dimensional code decoding process provided by some embodiments is shown;

[0032] Figure 4 A schematic diagram of a process for determining second position information of a sub-region provided by some embodiments is shown;

[0033] Figure 5 A schematic diagram of a two-dimensional code encoding device provided by some embodiments is shown;

[0034] Figure 6 A schematic diagram of a two-dimensional code decoding device provided by some embodiments is shown;

[0035] Figure 7 A schematic diagram of the structure of an electronic device provided by some embodiments is shown. DETAILED DESCRIPTION

[0036] In order to make the purpose, technical solutions and advantages of this application clearer, this application will be further described in detail below in conjunction with the accompanying drawings. Obviously, the embodiments described in this application are only part of the embodiments of this application, rather than all the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0037] It should be noted that the brief description of terms in this application is only for the convenience of understanding the embodiments described below, and is not intended to limit the embodiments of this application. Unless otherwise specified, these terms should be understood according to their common and usual meanings.

[0038] The terms "first", "second", "third", etc. in the specification and claims of this application and the above drawings are used to distinguish similar or similar objects or entities, and do not necessarily mean to limit a specific order or sequence, unless otherwise noted. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances.

[0039] The terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover but not exclude inclusion, for example, a product or device comprising a list of components is not necessarily limited to all the components expressly listed but may include other components not expressly listed or inherent to such product or device.

[0040] The term "module" refers to any known or later developed hardware, software, firmware, artificial intelligence, fuzzy logic, or combination of hardware and / or software code that is capable of performing the functions associated with that element.

[0041] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.

[0042] In order to improve the correct recognition rate of two-dimensional codes, the present application provides a two-dimensional code encoding and decoding method, device, equipment and medium.

[0043] Figure 1 A schematic diagram of a two-dimensional code encoding process provided by some embodiments is shown, such as Figure 1 As shown, the process includes the following steps:

[0044] S101: If a QR code encoding instruction is received, obtain the data to be transmitted and the data volume of the data to be transmitted carried in the encoding instruction; determine a first number of QR code templates required to transmit the data to be transmitted based on the data volume and a predetermined data carrying capacity of a QR code template; wherein each QR code template contains a preset second number of sub-regions, each of the sub-regions contains a preset third number of sub-squares, and for each of the sub-regions, a sub-square at a set position in the sub-region is configured as an anchor sub-square, and the anchor sub-square is configured as a set first color value.

[0045] The two-dimensional code encoding method provided in the embodiment of the present application is applied to an electronic device, which may be, for example, a PC, a mobile terminal or other device, or may be a server or other device.

[0046] In a possible implementation, when a user needs to encode certain data to be transmitted into a QR code, a "code" button in an electronic device can be triggered to trigger a QR code encoding instruction, and the electronic device can receive the QR code encoding instruction. Among them, the present application does not specifically limit the method of triggering the QR code encoding instruction, and it can be flexibly set according to needs. After the electronic device receives the QR code encoding instruction, it can obtain the data to be transmitted carried in the encoding instruction and the size of the data amount to be transmitted.

[0047] Optionally, in order to improve the efficiency of QR code encoding, the electronic device may pre-store a QR code template for encoding. Figure 2a , Figure 2a A schematic diagram of a two-dimensional code template provided by some embodiments is shown, such as Figure 2aAs shown, each QR code template may include a preset second number of sub-areas, wherein the second number may be flexibly set according to demand, and this application does not specifically limit this. For example, the second number may be 16 (4 2 )、64(8 2 )wait.

[0048] See also Figure 2b , Figure 2b A schematic diagram of a sub-region provided by some embodiments is shown, such as Figure 2b As shown, each sub-area in the QR code template may contain a preset third number of sub-squares, wherein the third number may be flexibly set according to demand, and this application does not make any specific limitation on this. For example, the third number may be 729 (27 2 )wait.

[0049] In addition, in order to improve the correct recognition rate of the QR code, in the embodiment of the present application, for each sub-region, the sub-grid at the set position in the sub-region can be configured as the anchor sub-grid. The set position can be flexibly set according to the needs, and this application does not make specific restrictions on this. For example, refer to Figure 2b , the sub-square located at the center of the sub-region in the sub-region can be configured as the anchor sub-square. For example, taking the sub-square containing k rows and k columns, where k is an odd number, the sub-square at the (k+1) / 2th row and the (k+1) / 2th column in the sub-region can be configured as the anchor sub-square.

[0050] In addition, in order to identify the anchor sub-square when decoding the two-dimensional code image (two-dimensional code) formed by the above-mentioned two-dimensional code template encoding, the anchor sub-square can be configured as a set first color value. Among them, the first color value can be flexibly set according to needs, and this application does not make specific restrictions on this. Exemplarily, the first color value can be a color value of gray in the hue, saturation, brightness (HSL) color space.

[0051] In addition, in order to improve the encoding efficiency of the two-dimensional code, the amount of data that a two-dimensional code template can carry (for the convenience of description, referred to as data carrying capacity) can be predetermined. Exemplarily, considering that the number of sub-squares used to carry data in the two-dimensional code template can be predetermined, the amount of data that each sub-square used to carry data can carry can also be predetermined. Therefore, the data carrying capacity of the two-dimensional code template can be determined according to the product of the number of sub-squares used to carry data in the two-dimensional code template and the amount of data that each sub-square can carry.

[0052] In a possible implementation, the number of two-dimensional code templates required to transmit the data to be transmitted (referred to as the first number for the convenience of description) can be determined based on the amount of data to be transmitted and the data carrying capacity of a predetermined two-dimensional code template. Exemplarily, the first number can be determined based on the ratio of the amount of data to be transmitted to the data carrying capacity of a predetermined two-dimensional code template. In a possible implementation, if the ratio is not an integer, the ratio can be rounded up to obtain the first number. Exemplarily, if the ratio of the amount of data to be transmitted to the data carrying capacity of a predetermined two-dimensional code template is 10, the first number is 10. If the ratio of the amount of data to be transmitted to the data carrying capacity of a predetermined two-dimensional code template is 9.5, the ratio can be rounded up and the first number is determined to be 10.

[0053] S102: Determine the sub-data to be transmitted corresponding to each two-dimensional code template to be encoded according to the first number and the data to be transmitted.

[0054] After the first quantity is determined, the transmission data corresponding to each QR code template to be encoded (for the convenience of description, referred to as sub-data to be transmitted) can be determined based on the first quantity and the data to be transmitted. Optionally, the data to be transmitted can be divided into the first number of sub-data to be transmitted, and each QR code template corresponds to one sub-data to be transmitted. Exemplarily, if the first quantity is 10 and the data size of the data to be transmitted is 500KB, the data to be transmitted can be divided into 10 sub-data to be transmitted in order, and each QR code template corresponds to a 50KB sub-data to be transmitted.

[0055] S103: For each of the two-dimensional code templates, determine the sub-bearing data corresponding to each sub-square carrying data in the two-dimensional code template according to the sub-data to be transmitted corresponding to the two-dimensional code template and the sorting order of each sub-square in the two-dimensional code template; and configure each sub-square carrying data to the second color value corresponding to the corresponding sub-bearing data.

[0056] After determining the sub-data to be transmitted corresponding to each QR code template, the sub-bearing data corresponding to each sub-square of the QR code template can be determined according to the sub-data to be transmitted corresponding to the QR code template and the sorting order of each sub-square contained in the QR code template. Figure 2a and Figure 2b, assuming that the sorting order of each sub-region in the two-dimensional code template is from top to bottom and from left to right is: f0, f1, f2, f3, f4, f5...f15, and at the same time, the sorting order of the sub-squares contained in each sub-region is also from top to bottom and from left to right. Taking the sub-squares contained in the f0 sub-region as an example, the sub-squares are D1, D2, D3...Dn, respectively. Then, the data corresponding to each sub-square carrying data in D1, D2, D3...Dn in the f0 sub-region can be determined in sequence (for the convenience of description, referred to as sub-bearing data), and then the sub-bearing data corresponding to each sub-square carrying data in the f1 sub-region can be determined, and so on. It will not be repeated here.

[0057] In a possible implementation, when performing QR code encoding, each data-bearing sub-square can be configured as a second color value corresponding to the respective corresponding sub-bearing data. The present application does not specifically limit the color space to which the second color value belongs, and can be flexibly set according to requirements. Exemplarily, the second color value can be black and white, or a color value in an RGB color space, or a color value in an HSL color space, etc.

[0058] In a possible implementation, considering that when the second color value is black and white, the amount of data carried by each sub-square may be small, resulting in a small amount of data that each two-dimensional code can carry. In order to increase the amount of data that the two-dimensional code can carry, the second color value can be configured as a color value of the RGB color space, or a color value of the HSL color space, etc. In a possible implementation, considering that when the second color value is configured as a color value of the RGB color space, the color difference between the colors of different color values ​​in the RGB color space may be small, which may easily lead to the inability to correctly read the data information carried by the two-dimensional code due to color recognition errors when decoding the two-dimensional code. In order to improve the correct recognition rate of the two-dimensional code, the second color value can be configured as a color value of the HSL color space with better color separation, more uniform spacing, and higher coding density.

[0059] In a possible implementation, when each data-bearing sub-square is configured as the second color value of the HSL color space corresponding to the respective corresponding sub-bearing data, for each data-bearing sub-square, the binary data corresponding to the sub-bearing data corresponding to the data-bearing sub-square is first determined (for convenience of description, referred to as target binary data). The binary data corresponding to the sub-bearing data can be determined by using the existing technology, which will not be described in detail here.

[0060] Optionally, the correspondence between the binary data and the color value of the HSL color space can be predetermined, wherein the color value of the HSL color space corresponding to the binary data can be flexibly set according to the demand, and the present application does not specifically limit this. After determining the target binary data corresponding to the sub-bearing data corresponding to each data-bearing sub-square in the two-dimensional code template, the second color value corresponding to each target binary data can be determined according to the predetermined correspondence between the binary data and the color value of the HSL color space, and each data-bearing sub-square is configured as the second color value corresponding to each.

[0061] In a possible implementation, the anchor sub-squares may be mainly used to locate the two-dimensional code image and improve the distortion resistance of the two-dimensional code image. The anchor sub-squares may not be used to carry data. Optionally, the sub-squares carrying data in the two-dimensional code template may not include anchor sub-squares.

[0062] The present application can configure the second color value as a color value of the HSL color space with better color distinction, more uniform intervals, and higher coding density, thereby increasing the data carrying capacity of the two-dimensional code image, making it possible to transfer confidential documents, transmit electronic documents in emergency environments, download media files in flight environments, download electronic books offline, etc. based on the two-dimensional code image in a network-free working environment. This can not only broaden the application scenarios of the two-dimensional code, but also improve the security protection capabilities of the data carried in the two-dimensional code in special scenarios such as no network.

[0063] For ease of understanding, the QR code encoding process provided by the present application is explained below by a specific embodiment. Assume that each QR code template contains n rows and n columns, a total of n*n sub-regions, and take n as 8 as an example, there are 64 small square sub-regions. Each sub-region contains k rows and k columns, a total of k*k sub-squares. Take k as 27 as an example, there are 729 sub-squares in each sub-region. Exemplarily, the width of each sub-square is 3 pixels, and the width of the QR code image is 648 pixels.

[0064] In the second color value of the HSL color space configured in each sub-square, 2 can be uniformly selected within the H value range of (0, 1). a The point represents the amount of data of a bit, and 2 are uniformly selected in the S value range of [0.55, 1] b Points represent b bits of data, and 2c points are uniformly selected in the L value range of [0.35, 0.65] to represent c bits of data. Each sub-square can represent a+b+c bits of data.

[0065] Exemplarily, assuming that the amount of data that each sub-square can carry is 1 byte (8 bits), then for each sub-square that carries data, the H value of the sub-square can be: 0.03125+i / 16 (i=1, 2, 3...16) for a total of 16 points, indicating that the 0-3 bits (a=4) of each byte of the sub-square have a total of 4 bits of data. The S value of the sub-square can be selected from: 0.55, 0.7, 0.85, 1 for a total of 4 points, indicating that the 4-5 bits (b=2) of each byte of the sub-square have a total of 2 bits of data. The L value of the sub-square can be selected from: 0.35, 0.45, 0.55, 0.65 for a total of 4 points, indicating that the 6-7 bits (c=2) of each byte of the sub-square have a total of 2 bits of data.

[0066] Assuming that each sub-region contains an anchor point sub-square, a first reference color sub-square and a second reference color sub-square, the number of sub-squares used to carry data in each sub-region is k*k-3. The amount of data carried by each sub-region is (k*k-3)*(a+b+c). Taking k as 27 and a+b+c as 8 bits as an example, the amount of data carried by each sub-region is 726 bytes. The corresponding carrying data of the sub-region of each two-dimensional code template is: (i*64+j)*726~(i*64+j)*726+725, where if the sorting of each two-dimensional code template according to the sub-data to be transmitted corresponding to each two-dimensional code template is called the first sorting, then i+1 is the ranking of a certain two-dimensional code template in the first sorting. If for each two-dimensional code template, the sorting order of each sub-square in the two-dimensional code template is called the second sorting, then j+1 is the ranking of a certain sub-region in the second sorting. For example, taking the first sub-area in the first two-dimensional code template as an example, the data carried in the sub-area is 726 bytes of data from the 0th to the 725th of the data to be transmitted. The data carried in other sub-areas can be deduced in the same way, which will not be repeated here.

[0067] The two-dimensional code template of the present application includes a second number of sub-regions, each of which includes a third number of sub-squares, and for each sub-region, the sub-square at a set position in the sub-region is configured as an anchor sub-square, and the anchor sub-square is configured as a set first color value. When receiving a two-dimensional code encoding instruction and performing two-dimensional code encoding, the data to be transmitted and the data volume of the data to be transmitted carried in the encoding instruction can be obtained; according to the data volume of the data to be transmitted and the data carrying capacity of a predetermined two-dimensional code template, the first number of two-dimensional code templates required to transmit the data to be transmitted is determined; according to the first number and the data to be transmitted, the sub-data to be transmitted corresponding to each two-dimensional code template to be encoded is determined; for each two-dimensional code template, according to the sub-data to be transmitted corresponding to the two-dimensional code template and the sorting order of each sub-square in the two-dimensional code template, the sub-bearing data corresponding to each sub-square carrying data in the two-dimensional code template is determined; and each sub-square carrying data is configured as the second color value corresponding to the respective corresponding sub-bearing data. Since the present application can locate the two-dimensional code image based on the anchor point sub-squares, when the two-dimensional code image is subsequently decoded, the second position information of each sub-region can be determined based on the first position information of each anchor point sub-square, and then the third position information of the sub-squares contained in each sub-region can be determined. Therefore, even when the two-dimensional code image is scanned at different angles, such as when the two-dimensional code image displayed in the captured image has certain distortion phenomena such as tilt and stretching, the position information of each sub-region and sub-square contained in the two-dimensional code image can be determined based on the anchor point sub-squares, so that the data information carried by each sub-square in the two-dimensional code image can be identified (restored) to the greatest extent, the anti-distortion capability of the two-dimensional code image can be improved, the correct identification of the two-dimensional code can be guaranteed to the greatest extent, the two-dimensional code can be identified quickly and accurately, and the correct recognition rate of the two-dimensional code can be improved.

[0068] In a possible implementation, in order to facilitate the quick and accurate identification of the boundary of the QR code when decoding the QR code and improve the decoding rate, based on the above embodiment, in the embodiment of the present application, when encoding the QR code, for each QR code template, the anchor sub-square in the sub-area located at the edge of the QR code in the QR code template can be configured as a preset third color value. Figure 2b , the anchor sub-squares f1, f2, f3, f4, f7, etc. located in the sub-regions at the edge of the QR code can be configured as a preset third color value. Specifically, the third color value can be flexibly set according to the needs, and this application does not make specific restrictions on this. Exemplarily, the third color value of the anchor sub-square in the sub-region at the edge can be black, white, etc. Among them, the third color value of the anchor sub-square in the sub-region at the edge is different from the third color value of the sub-region not located at the edge (such as Figure 2bThe first color value of the anchor sub-square in the sub-regions f5, f6, etc. in the two-dimensional code template may be different. Exemplarily, for a certain two-dimensional code template, when the third color value of the anchor sub-square in the sub-region located at the edge of the two-dimensional code template is white, the first color value of the anchor sub-square in the sub-region not located at the edge of the two-dimensional code template may be black, etc. When the third color value of the anchor sub-square in the sub-region located at the edge of the two-dimensional code template is black, the first color value of the anchor sub-square in the sub-region not located at the edge of the two-dimensional code template may be white, etc.

[0069] In one possible implementation, considering that if the first number is not less than 2, that is, the data to be transmitted requires multiple two-dimensional code images (two-dimensional code templates) to be transmitted, in order to facilitate the subsequent decoding of the two-dimensional code images, more quickly and accurately identify and distinguish adjacent two-dimensional code images, when encoding the two-dimensional code, the colors of the anchor sub-squares in the sub-areas located at the edge of two adjacent two-dimensional code images can be configured to different color values, and accordingly, the colors of the anchor sub-squares in the sub-areas not located at the edge of two adjacent two-dimensional code images can also be configured to different color values.

[0070] Specifically, if the first number is not less than 2, each two-dimensional code template can be sorted according to the sub-data to be transmitted corresponding to each two-dimensional code template (for the convenience of description, referred to as the first sorting); then, for each two-dimensional code template, when the anchor sub-square located in the sub-region at the edge of the two other two-dimensional code templates adjacent to the two-dimensional code template is configured as a preset third color value, the color value of the anchor sub-square located in the sub-region at the edge of the two-dimensional code template is adjusted to a non-third color value. When the anchor sub-square located in the sub-region at the edge of the two other two-dimensional code templates adjacent to the two-dimensional code template is configured as a non-third color value, the color value of the anchor sub-square located in the sub-region at the edge of the two-dimensional code template is configured as a third color value.

[0071] Exemplarily, taking the first number of 3 as an example, assuming that each QR code template is sorted according to the sub-data to be transmitted corresponding to each QR code template, the QR code templates are respectively the first template, the second template, and the third template. If the anchor sub-squares in the sub-region located at the edge of the first template are configured as black, and the anchor sub-squares in the sub-region not located at the edge of the first template are configured as white; then the anchor sub-squares in the sub-region located at the edge of the second template can be configured as white, and the anchor sub-squares in the sub-region not located at the edge of the second template can be configured as black. In addition, the anchor sub-squares in the sub-region located at the edge of the third template can be configured as black, and the anchor sub-squares in the sub-region not located at the edge of the third template can be configured as white.

[0072] Since the color values ​​of the anchor sub-squares in the sub-areas located at the edge of two adjacent QR code templates and the color values ​​of the anchor sub-squares in the sub-areas not located at the edge of two adjacent QR code templates are different, when the QR code templates are subsequently decoded, adjacent QR code images can be quickly and accurately identified and distinguished, further improving the correct recognition rate of the QR code.

[0073] In a possible implementation, in order to facilitate the subsequent decoding of the two-dimensional code image, the sorting order of the sub-areas contained in the two-dimensional code image can be quickly and accurately identified to improve the accuracy of the two-dimensional code recognition. At the same time, in order to improve the coding efficiency, for each two-dimensional code template, the first color value of the anchor sub-square in the sub-area to which the first-ranked sub-square belongs in the sorting order of each sub-square in the two-dimensional code template can be pre-configured as a preset fourth color value. The fourth color value can be flexibly configured according to demand, and this application does not make specific limitations on this. For example, refer to Figure 2a The fourth color value may be a color value of gray or other colors. The anchor sub-squares in the sub-region (such as the f0 sub-region) to which the sub-square ranked first in each two-dimensional code template belongs may all be configured as gray.

[0074] In a possible implementation, in order to facilitate subsequent decoding of the QR code image, the first (ranked first) QR code image in the QR code image sorting (first sorting) can be identified. For the QR code template ranked first in the first sorting, the first color value of the anchor point sub-square of the sub-area set in the QR code template ranked first can be adjusted to the set fifth color value. The location of the sub-area and the fifth color value can be flexibly set according to needs, and this application does not make specific limitations on this. For example, refer to Figure 2a , the set sub-region may be the sub-region ranked last in the second sort (such as the fn sub-region). The fifth color value may be black or white, etc. In a possible implementation, in order to facilitate the distinction between the sub-region ranked first in the second sort and the sub-region of the set sub-region, the fourth color value and the fifth color value may be different. Exemplarily, when the color value of the anchor sub-square in the sub-region (such as the f0 sub-region) to which the sub-square ranked first in the second sort belongs is configured as a gray color value (fourth color value), the color value of the anchor sub-square of the set sub-region (such as the fn sub-region) may be adjusted to a color value such as black or white (fifth color value).

[0075] For ease of understanding, the QR code template provided in this application is explained below through a specific embodiment.

[0076] Exemplarily, taking the first number of 3 as an example, assuming that after sorting each QR code template according to the sub-data to be transmitted corresponding to each QR code template, the QR code templates are respectively the first template, the second template, and the third template.

[0077] See also Figure 2a , assuming that in the second sorting of the first template, the fourth color value of the anchor sub-square in the sub-region f0 ranked first (for convenience of description, called the first sub-region) is gray. In the second sorting of the first template, the fifth color value of the anchor sub-square in the sub-region fn ranked last (for convenience of description, called the last sub-region) is white, and the anchor sub-squares in other sub-regions located at the edge except the first sub-region and the last sub-region are configured as white (third color value), and the anchor sub-squares in the sub-regions of the first template that are not located at the edge are configured as black (first color value).

[0078] Optionally, the fourth color value of the anchor sub-square in the first sub-region of the second template is also gray. The fifth color value of the anchor sub-square in the last sub-region of the second template is changed to black, the anchor sub-squares in other sub-regions of the second template located at the edge except the first sub-region and the last sub-region are configured as black, and the anchor sub-squares in the sub-region of the second template not located at the edge are configured as white.

[0079] Optionally, the fourth color value of the anchor sub-square in the first sub-region of the third template is also gray. The fifth color value of the anchor sub-square in the last sub-region of the third template is still black, and the anchor sub-squares in other sub-regions of the third template located at the edge except the first sub-region and the last sub-region are configured as white (the same as the first template), and the anchor sub-squares in the sub-regions of the third template that are not located at the edge are configured as black (the same as the first template).

[0080] In a possible implementation, in order to facilitate subsequent decoding of the QR code image, the last ranked QR code image in the QR code image sorting (first sorting) can be identified, and the first color value of the anchor point sub-square of the set sub-region in the last ranked QR code template can be adjusted to the set sixth color value. The sixth color value can be flexibly configured according to demand, and this application does not specifically limit this.

[0081] In a possible implementation, taking into account that when the QR code is subsequently decoded, the color of the recognized QR code image may have a certain deviation, which may affect the accuracy of the recognized QR code. In order to improve the correct recognition rate of the QR code, for each QR code template, at least one first reference color sub-square and at least one second reference color sub-square can be configured in the QR code template, wherein the first reference color sub-square is configured with a set reference color lower limit value; and the second reference color sub-square is configured with a set reference color upper limit value.

[0082] In a possible implementation, for each two-dimensional code template, a first reference color sub-square and a second reference color sub-square may be configured in the two-dimensional code template. The present application does not specifically limit the positions of the first reference color sub-square and the second reference color sub-square in the two-dimensional code template, and can be flexibly set according to requirements, as long as the pre-configured first reference color sub-square and the second reference color sub-square can be identified when the two-dimensional code is subsequently decoded.

[0083] In one possible implementation, see Figure 2b , it can be that for each QR code template, a first reference color sub-square and a second reference color sub-square are respectively configured in each sub-region of the QR code template. Among them, the present application does not specifically limit the positions of the first reference color sub-square and the second reference color sub-square in the sub-region, and can be flexibly set according to needs. For example, in each sub-region, the sub-square located to the left of the anchor sub-square and adjacent to the anchor sub-square (for the convenience of description, referred to as the left sub-square) can be configured as the first reference color sub-square, and the sub-square located to the right of the anchor sub-square and adjacent to the anchor sub-square (for the convenience of description, referred to as the right sub-square) can be configured as the second reference color sub-square.

[0084] Taking the second color range as H at (0, 1), S at [0.55, 1], and L at [0.35, 0.65], H in the lower limit value of the reference color configured in the first reference color sub-square may be 0.03125, S may be 0.55, and L may be 0.35. H in the upper limit value of the reference color configured in the second reference color sub-square may be 0.96875, S may be 1, and L may be 0.65.

[0085] Based on the same technical concept, on the basis of the above embodiments, in the embodiments of the present application, the present application provides a two-dimensional code decoding method, Figure 3 A schematic diagram of a two-dimensional code decoding process provided by some embodiments is shown, such as Figure 3 As shown, the process includes the following steps:

[0086] S301: If a two-dimensional code decoding instruction is received, first position information of each anchor sub-square contained in at least one two-dimensional code image is respectively identified based on a first color value configured in a preset anchor sub-square.

[0087] The two-dimensional code decoding method provided in the embodiment of the present application is applied to an electronic device, which may be, for example, a PC, a mobile terminal or other device, or may be a server or other device.

[0088] In a possible implementation, when it is necessary to decode the two-dimensional code image, the user can trigger the two-dimensional code decoding instruction by clicking a "scan two-dimensional code" button or the like. After receiving the two-dimensional code decoding instruction, the electronic device can perform a process of identifying (decoding) the two-dimensional code. Optionally, in order to maximize the guarantee that the two-dimensional code can be correctly identified and improve the correct recognition rate of the two-dimensional code even when the two-dimensional code image displayed in the captured image (the image displayed in the capture area) has certain distortion phenomena such as tilt and stretching, the position information of each anchor sub-square contained in each two-dimensional code image can be identified based on the first color value configured in the preset anchor sub-square (referred to as the first position information for the convenience of description).

[0089] In one possible implementation, when the electronic device identifies a QR code image, it can identify the color value of each pixel in the image displayed in the acquisition area. When a first color value is identified, the area corresponding to the first color value (multiple continuous pixels, etc.) can be determined as the area where the anchor sub-square is located, thereby identifying the first position information of each anchor sub-square contained in the QR code image based on the first color value.

[0090] S302: For each two-dimensional code image, based on the first position information of each anchor sub-square contained in the two-dimensional code image, determine the second position information of the sub-region to which each anchor sub-square belongs.

[0091] For each two-dimensional code image, after determining the first position information of each anchor sub-square contained in the two-dimensional code image, the position information of the sub-region to which each anchor sub-square belongs (for the convenience of description, referred to as the second position information) can be determined based on the first position information of each anchor sub-square contained in the two-dimensional code image. Exemplarily, taking the anchor sub-square as the sub-square located at the center of the sub-region as an example, since each anchor sub-square is the sub-square at the center of the corresponding sub-region, therefore, refer to Figure 4 , Figure 4 A schematic diagram of a process for determining the second position information of a sub-region provided by some embodiments is shown. When determining each non-edge sub-region, the second position information of the sub-region may be determined based on eight adjacent anchor sub-squares around the anchor sub-square of the sub-region. Figure 4 Taking the sub-region f5 in the figure as an example, when determining the sub-region f5, we can first determine the eight adjacent anchor sub-squares (the anchor sub-squares of sub-regions f0, f1, f2, f4, f6, f8, f9, and f10 respectively) surrounding the anchor sub-square of the sub-region, and then determine the midpoint of the line connecting the anchor sub-square and the eight adjacent anchor sub-squares (marked by a small circle in the figure), and connect these eight points (midpoints) in sequence to determine the second position information of the sub-region f5.

[0092] As another example, for an anchor sub-square located at an edge, when determining the second position information of the sub-region to which the anchor sub-square belongs, the sub-region to which the anchor sub-square belongs can be determined based on the connecting line of the anchor sub-squares adjacent to the anchor sub-square and the reverse extension line of the connecting line. Taking the determination of the first sub-region f0 as an example, the three adjacent anchor sub-squares around the anchor sub-square f0 (i.e., the anchor sub-squares in the sub-regions f1, f4, and f5) can be determined first, and then the midpoint of the connecting line between the anchor sub-square f0 and the three adjacent anchor sub-squares around it can be determined first ( Figure 4 Then, extend each line in the opposite direction to determine the points on the extended line that are symmetrical to each midpoint, with the anchor point sub-square of f0 as the center ( Figure 4 Then, the points indicated by the three small circles in the upper left corner and the three small circles in the lower right corner are connected in sequence, thereby obtaining the second position information of the sub-region f0. The second position information of sub-regions at other positions can be obtained by analogy according to the above method, which will not be repeated here.

[0093] Since the present application can determine the second position information of each sub-area based on the first position information of each anchor point sub-square, even when the QR code image is scanned at different angles, causing the QR code image displayed in the captured image to have certain distortion such as tilt and stretching, each sub-area can be identified (restored) to the greatest extent, thereby improving the anti-distortion capability of the QR code image, ensuring that the QR code can be correctly identified to the greatest extent, and thereby improving the correct recognition rate of the QR code.

[0094] S303: For each of the sub-regions, determine the number of sub-squares contained in the sub-region, and determine third position information of the sub-squares contained in the sub-region.

[0095] In a possible implementation manner, after the second position information of each sub-region is determined, the number of sub-squares contained in each sub-region may be determined.

[0096] In a possible implementation, when determining the number of sub-squares included in each sub-region, the number of sub-squares included in each sub-region may be determined according to the number of sub-squares included in a preset sub-region (third number).

[0097] In addition, when determining the number of sub-squares contained in each sub-region, the width of the anchor sub-square in the sub-region and the width of the sub-region may be determined first, and then the number of sub-squares contained in the sub-region may be determined based on the ratio of the width of the sub-region to the width of the anchor sub-square in the sub-region. In a possible implementation, the square of the odd number closest to the ratio may be determined as the number of sub-squares contained in the sub-region. For example, if the ratio of the width of the sub-region to the width of the anchor sub-square in the sub-region is 27, the number of sub-squares contained in the sub-region may be determined to be 27. 2 , that is, 729. For example, if the ratio of the width of the sub-region to the width of the anchor sub-square in the sub-region is 27.8, the number of sub-squares contained in the sub-region can also be determined to be 27. 2 , that is, 729. For example, if the ratio of the width of the sub-region to the width of the anchor sub-square in the sub-region is 26.5, the number of sub-squares contained in the sub-region can also be determined to be 27. 2 , that is 729.

[0098] After the number of sub-squares contained in each sub-region is determined, the third position information of the sub-squares contained in each sub-region can be determined based on the number of sub-squares contained in each sub-region (the third number). Exemplarily, the sub-region can be evenly divided into a third number of uniform sub-squares, thereby determining the third position information of the sub-squares contained in each sub-region.

[0099] S304: According to the third position information of the sub-square in each sub-region, read the sub-bearing data corresponding to the second color value configured in each sub-square of the third position information in the two-dimensional code image, and according to the combination order of the sub-squares in the preset sub-region, combine the sub-bearing data corresponding to each sub-square that carries the data to obtain the data carried by the two-dimensional code image.

[0100] After the third position information of the sub-square in each sub-region is determined, the sub-bearing data corresponding to the second color value configured in each sub-square of the third position information in the two-dimensional code image can be read respectively according to the third position information.

[0101] Exemplarily, taking the second color value as the color value of the HSL color space as an example, when reading the sub-bearing data corresponding to the second color value configured in the sub-square of each third position information in the two-dimensional code image, it can be that for each sub-square of the third position information, the second color value configured in the sub-square of the third position information is first determined; then, based on the correspondence between the predetermined binary data and the color value of the HSL color space, the binary data corresponding to the second color value (for the convenience of description, referred to as target binary data) is determined, and the target binary data is used as the sub-bearing data corresponding to the second color value configured in the sub-square of the third position information.

[0102] After the sub-bearing data corresponding to each sub-square is determined, the sub-bearing data corresponding to each sub-square bearing data can be combined according to the combination order of the sub-squares in the preset sub-region to obtain the data carried by the two-dimensional code image. Exemplarily, for each sub-region, the sub-bearing data corresponding to each sub-square bearing data contained in the sub-region can be combined in the order of the sub-squares from top to bottom and from left to right to obtain the bearing data in the sub-region; and then the bearing data in each sub-region can be combined in the order of the sub-region from top to bottom and from left to right to obtain the data carried by the two-dimensional code image and save it.

[0103] Since the present application can determine the second position information of each sub-region based on the first position information of each anchor point sub-square, and then determine the third position information of the sub-squares contained in each sub-region, even when the angle at which the two-dimensional code image is scanned is different, so that the two-dimensional code image displayed in the captured image has certain distortion phenomena such as tilt and stretching, each sub-region and the sub-squares contained in each sub-region can be identified (restored) to the greatest extent, thereby improving the anti-distortion ability of the two-dimensional code image, ensuring that the two-dimensional code can be correctly identified to the greatest extent, and then improving the correct recognition rate of the two-dimensional code.

[0104] In a possible implementation, in order to improve the efficiency of determining the anchor sub-squares, for each two-dimensional code image, the first position information of each anchor sub-square located at the edge of the two-dimensional code image can be determined based on the third color value of the anchor sub-square in the sub-region where the two-dimensional code image is located at the edge. Then, based on the first position information of each anchor sub-square located at the edge, the edge region of the two-dimensional code image is determined. After the edge region of the two-dimensional code image is determined, the first position information of each anchor sub-square located in the inner region of the two-dimensional code image can be determined based on the preset first color value in the inner region of the two-dimensional code image.

[0105] Since the present application can first determine the edge area of ​​the two-dimensional code image based on the third color value, and then determine each anchor point sub-square located in the internal area of ​​the two-dimensional code image based on the edge area, each anchor point sub-square contained in the two-dimensional code image can be quickly and accurately determined.

[0106] In one possible implementation, when decoding a two-dimensional code image, if the color value of any anchor sub-square in the two-dimensional code image is identified as a preset fourth color value, the sub-region to which the anchor sub-square belongs can be determined as the first sub-region, and starting from the sub-region (first sub-region) to which the anchor sub-square belongs, according to the combination order of the sub-squares in the preset sub-region, the sub-data corresponding to each data-carrying sub-square can be quickly and accurately combined to obtain (restore) the data carried by the two-dimensional code image.

[0107] In a possible implementation, taking into account that when an electronic device recognizes a QR code image, the acquisition area may contain not only the QR code image (QR code) but may also contain, for example, irrelevant images around the QR code, in order to improve the efficiency of determining the anchor sub-square, before determining the position of the anchor sub-square, the area or approximate area (for the convenience of description, collectively referred to as the area where the QR code is located) where the QR code image (QR code) is located in the image displayed in the acquisition area may be determined first, and then, when determining the anchor sub-square based on the area where the QR code is located, the efficiency of determining the anchor sub-square can be improved compared to when determining the anchor sub-square based on the entire image displayed in the acquisition area.

[0108] In a possible implementation, when determining the area where the QR code is located, for each QR code image, at least one sub-image can be selected from the image displayed in the acquisition area according to the set pixel interval. The pixel interval and the size of the sub-image can be flexibly set according to the needs, and this application does not specifically limit this. For example, sub-images of set sizes can be selected from the upper, middle, lower, etc. positions of the image displayed in the acquisition area.

[0109] For each selected sub-image, the color value of the pixel value in the sub-image can be counted. In a possible implementation, for each sub-image, the number of pixel points whose color value of the pixel value in the sub-image is higher than the median value of the set reference color (for convenience of description, referred to as the fourth number), and the number of pixel points whose color value of the pixel value is lower than the median value of the set reference color (for convenience of description, referred to as the fifth number). For convenience of description, taking the lower limit of the H value in the reference color as 0, the upper limit of the H value in the reference color as 1, and the median value of the H value in the reference color as 0.5 as an example, the fourth number of pixel points whose color value of the pixel value in the sub-image is higher than 0.5, and the fifth number of pixel points whose color value of the pixel value in the sub-image is lower than 0.5 can be determined respectively.

[0110] Considering that when the sub-image is a sub-image located in a two-dimensional code, the number of pixel points whose color values ​​of the pixel values ​​in the sub-image are higher than the median value of the reference color and lower than the median value of the reference color is usually substantially the same, that is, the fourth number and the fifth number are usually substantially the same. If the sub-image is not a sub-image located in a two-dimensional code, the number of pixel points whose color values ​​of the pixel values ​​in the sub-image are higher than the median value of the reference color and lower than the median value of the reference color is usually quite different, that is, the fourth number and the fifth number are usually quite different. In order to quickly determine whether the sub-image is a sub-image located in a two-dimensional code, it can be determined whether the ratio of the fourth number to the fifth number is within a set ratio range. If the ratio of the fourth number to the fifth number is within a set ratio range, it can be considered that the sub-image is a sub-image located in a two-dimensional code. Among them, the ratio range can be flexibly set according to demand, and this application does not make specific restrictions on this. Exemplarily, the ratio range is 0.9-1.1, etc.

[0111] In one possible implementation, when a sub-image is determined to be a sub-image located in a QR code, starting from the sub-image, based on the first color value configured in the preset anchor sub-square, the first position information of the anchor sub-square contained in the sub-image can be first identified, and then based on the interval between the preset anchor sub-squares and the first color value, the first position information of each anchor sub-square contained in the QR code image can be quickly and accurately identified.

[0112] In a possible implementation, considering that if the first number is not less than 2, it is usually necessary to fuse the data of multiple two-dimensional code images and output (display) them uniformly after decoding each two-dimensional code image (for the convenience of description, it is called decoding completion). In order to know whether the decoding has been completed, in a possible implementation, for each two-dimensional code image, when the color value of the anchor sub-square of the set sub-area in the two-dimensional code image is identified as the set fifth color value, the two-dimensional code image can be used as the first two-dimensional code image among the multiple two-dimensional code images carrying the data to be transmitted (the first-ranked two-dimensional code image in the first sorting, for the convenience of description, it is called the first two-dimensional code image). In a possible implementation, since the color value of the anchor sub-square of the set sub-area of ​​the first two-dimensional code image is different from the color value of the anchor sub-square of the set sub-area of ​​other two-dimensional code images, when multiple two-dimensional code images are played in a loop according to a certain order and a set frequency, when the multiple two-dimensional code images are decoded, when the two-dimensional code image to be decoded is identified as the first two-dimensional code image, it can be further determined whether the data carried by the first two-dimensional code image has been obtained (acquired) based on the two-dimensional code decoding instruction. If the data carried by the first QR code image has not been obtained based on the QR code decoding instruction, it can be considered that this is the first time that the first QR code image is recognized, and the QR code image can be decoded to obtain the data carried by the QR code image.

[0113] If the data carried by the first QR code image has been obtained (acquired) based on the QR code decoding instruction, it can be considered that this is the second time the first QR code image has been identified, and it can be considered that the decoding process of each QR code image has been completed, that is, the decoding is completed, and the data carried by each QR code image currently saved and obtained based on the QR code decoding instruction can be fused. For example, starting from the data of the first QR code image, the data of each acquired QR code image can be fused in turn to obtain (restore) the same data as the data to be transmitted in the above embodiment, and end this decoding process.

[0114] In a possible implementation, if a color value of the anchor sub-square of a sub-area is set to a set sixth color value in a certain QR code image, the QR code image is considered to be the last QR code image among multiple QR code images carrying data to be transmitted. After decoding the QR code, the data carried by each QR code image currently saved based on the QR code decoding instruction may be fused. Exemplarily, the data carried by each QR code image currently saved based on the QR code decoding instruction may be fused in sequence from the data of the first QR code image to the data of the last QR code image, thereby obtaining (restoring) the same data as the data to be transmitted in the above embodiment, and ending the decoding process.

[0115] In a possible implementation, considering that the first position information of each anchor sub-square contained in the first two-dimensional code image has been obtained when decoding the first two-dimensional code image, usually, when parsing multiple two-dimensional code images based on the same decoding instruction, these multiple two-dimensional code images are a group of two-dimensional code images corresponding to the same data to be transmitted, and the position information of the anchor sub-square contained in each two-dimensional code image is not much different. If each two-dimensional code image re-identifies the position information of the anchor sub-square, it may take a lot of time. In order to improve the efficiency of two-dimensional code recognition, for each two-dimensional code image, if it is known that before the two-dimensional code image, the data carried by other two-dimensional code images have been obtained based on the two-dimensional code decoding instruction, it can be considered that the currently decoded two-dimensional code image is not the first two-dimensional code image (the first two-dimensional code image), and the first position information of each anchor sub-square contained in the two-dimensional code image can be determined based on the first color value configured in the preset anchor sub-square and the first position information of each anchor sub-square contained in other two-dimensional code images that have been determined to be before the two-dimensional code image in the first sorting. Exemplarily, the first position information of each anchor sub-square contained in the two-dimensional code image may be determined based on the first position information of each anchor sub-square contained in the previous adjacent two-dimensional code image that ranks before the two-dimensional code image in the first sorting.

[0116] Since the present application can determine the position information of each anchor sub-square contained in the QR code image based on the position information of the anchor sub-squares of other QR code images located before the QR code image in the first sorting, the efficiency of QR code recognition can be improved.

[0117] In a possible implementation, considering that when recognizing a two-dimensional code image, there may be a certain offset in the color transfer process, which may cause a certain error in the second color value and affect the accurate recognition rate of the two-dimensional code, in order to improve the correct recognition rate of the two-dimensional code and the reliability of the two-dimensional code, on the basis of the above-mentioned embodiments, in the embodiment of the present application, after determining the second color value configured in the sub-grid of the third position information, according to the correspondence between the predetermined binary data and the color value of the HSL color space, before determining the target binary data corresponding to the second color value, the second color value can also be corrected. Exemplarily, the embodiment of the present application provides the following three correction methods for the second color value.

[0118] The first correction method for the second color value is:

[0119] For each two-dimensional code image, if it is recognized that the two-dimensional code image contains a set first reference color sub-square and a set second reference color sub-square, the lowest value (for convenience of description, referred to as the actual color lower limit value) and the highest value (for convenience of description, referred to as the actual color upper limit value) in the second color value configured for each sub-square of the third position information in the sub-region can be determined for each sub-region in the two-dimensional code image. Then, by comparing the actual color upper limit value with the reference color upper limit value configured in the second reference color sub-square, and comparing the actual color lower limit value with the reference color lower limit value configured in the first reference color sub-square, the color value correction coefficient of the sub-region is determined. Exemplarily, taking the S value as an example, if the reference color upper limit value of the S value is 1 and the reference color lower limit value is 0.55, and the actual color upper limit value of the S value of a sub-region is 0.8 and the actual color lower limit value is 0.44, then it can be considered that the recognized second color value is 80% of the ideal second color value. Exemplarily, the color value correction coefficient can be determined as the reciprocal of 80%, that is, 1.25.

[0120] After the color value correction coefficient is determined, the second color value of the sub-square of each third position information of the determined sub-region can be corrected based on the color value correction coefficient. Exemplarily, the product of the second color value of the sub-square of each third position in the identified sub-region and the color value correction coefficient can be determined as the corrected second color value, and the target binary data corresponding to the corrected second color value is determined according to the predetermined correspondence between the binary data and the color value of the HSL color space.

[0121] The second correction method for the second color value is:

[0122] For each two-dimensional code image, if it is identified that the two-dimensional code image contains a set first reference color sub-square and a set second reference color sub-square, the lowest value (actual color lower limit value) and the highest value (actual color upper limit value) of the second color values ​​of all sub-squares in the two-dimensional code image can be determined. Then, by comparing the actual color upper limit value with the reference color upper limit value configured in the second reference color sub-square, and comparing the actual color lower limit value with the reference color lower limit value configured in the first reference color sub-square, the color value correction coefficient of the two-dimensional code image is determined. Among them, the process of determining the color value correction coefficient is the same as that in the above embodiment, and will not be repeated here.

[0123] After the color value correction coefficient is determined, the second color value of each sub-square of the determined two-dimensional code image can be corrected based on the color value correction coefficient. Exemplarily, the product of the second color value of the identified sub-square of the two-dimensional code image and the color value correction coefficient can be determined as the corrected second color value, and the target binary data corresponding to the corrected second color value is determined according to the predetermined correspondence between the binary data and the color value of the HSL color space.

[0124] Among them, the third correction method for the second color value is:

[0125] For each two-dimensional code image, if it is recognized that each sub-region of the two-dimensional code image contains the first reference color sub-square and the second reference color sub-square, the lowest value (for convenience of description, referred to as the actual color lower limit value) and the highest value (for convenience of description, referred to as the actual color upper limit value) of the second color value configured for each sub-square of the third position information in the sub-region can be determined for each sub-region in the two-dimensional code image. Then, by comparing the actual color upper limit value with the reference color upper limit value configured in the second reference color sub-square in the sub-region, and comparing the actual color lower limit value with the reference color lower limit value configured in the first reference color sub-square in the sub-region, the color value correction coefficient of the sub-region is determined.

[0126] After the color value correction coefficient is determined, the second color value of the sub-square of each third position information of the determined sub-region can be corrected based on the color value correction coefficient. Exemplarily, the product of the second color value of the sub-square of each third position in the identified sub-region and the color value correction coefficient can be determined as the corrected second color value, and the target binary data corresponding to the corrected second color value is determined according to the predetermined correspondence between the binary data and the color value of the HSL color space.

[0127] Based on the same technical concept, the present application provides a two-dimensional code encoding device, Figure 5 A schematic diagram of a two-dimensional code encoding device provided by some embodiments is shown. Figure 5 As shown, the device comprises:

[0128] The first determination module 51 is used for, if a two-dimensional code encoding instruction is received, obtaining the data to be transmitted and the data volume of the data to be transmitted carried in the encoding instruction; determining the first number of two-dimensional code templates required to transmit the data to be transmitted according to the data volume and the predetermined data carrying capacity of a two-dimensional code template; wherein each two-dimensional code template includes a preset second number of sub-regions, each of the sub-regions includes a preset third number of sub-squares, and for each of the sub-regions, a sub-square at a set position in the sub-region is configured as an anchor sub-square, and the anchor sub-square is configured as a set first color value;

[0129] A second determining module 52, configured to determine the sub-data to be transmitted corresponding to each two-dimensional code template to be encoded according to the first quantity and the data to be transmitted;

[0130] The configuration module 53 is used to determine, for each of the two-dimensional code templates, the sub-bearing data corresponding to each sub-square that carries data in the two-dimensional code template according to the sub-data to be transmitted corresponding to the two-dimensional code template and the sorting order of each sub-square in the two-dimensional code template; and configure each sub-square that carries data to the second color value corresponding to the respective corresponding sub-bearing data.

[0131] In a possible implementation, the anchor point sub-squares in the sub-region at the edge of each two-dimensional code template are configured as a preset third color value.

[0132] In a possible implementation, the device further includes:

[0133] An adjustment module is used to sort each QR code template according to the sub-data to be transmitted corresponding to each QR code template if the first number is not less than 2; for each QR code template, if the anchor sub-square located in the sub-area at the edge in the two other QR code templates before and after the QR code template is adjacent to the QR code template is configured as a preset third color value, then the color value of the anchor sub-square located in the sub-area at the edge of the QR code template is adjusted to a non-third color value.

[0134] In a possible implementation, for each two-dimensional code template, in the sorting order of each sub-region in the two-dimensional code template, the first color value of the anchor point sub-square in the sub-region ranked first is configured as a preset fourth color value.

[0135] In a possible implementation manner, the adjustment module is further configured to adjust, for the first-ranked QR code template, a first color value of an anchor point sub-square of a set sub-region in the QR code template to a set fifth color value.

[0136] In a possible implementation, the adjustment module is further configured to adjust, for the last ranked QR code template in the sorting, the first color value of the anchor point sub-square of the set sub-region in the QR code template to a set sixth color value.

[0137] In a possible implementation, the configuration module is specifically used to determine, for each sub-square that carries data, the target binary data corresponding to the sub-data corresponding to the sub-square that carries the data; determine the second color value corresponding to the target binary data based on the correspondence between the predetermined binary data and the color values ​​of the hue, saturation, and brightness HSL color space; and configure the sub-square that carries the data to the second color value.

[0138] In a possible implementation, for each QR code template, the QR code template includes at least one first reference color sub-square and at least one second reference color sub-square, wherein the first reference color sub-square is configured with a set reference color lower limit value; and the second reference color sub-square is configured with a set reference color upper limit value.

[0139] Based on the same technical concept, the present application provides a two-dimensional code encoding device, Figure 6 A schematic diagram of a two-dimensional code decoding device provided by some embodiments is shown. Figure 6 As shown, the device comprises:

[0140] The identification module 61 is used to identify the first position information of each anchor sub-square contained in at least one two-dimensional code image based on the first color value configured in the preset anchor sub-square when receiving the two-dimensional code decoding instruction;

[0141] A third determination module 62 is used to determine, for each two-dimensional code image, second position information of the sub-region to which each anchor sub-square belongs based on the first position information of each anchor sub-square contained in the two-dimensional code image;

[0142] A fourth determining module 63 is used to determine, for each of the sub-regions, the number of sub-squares contained in the sub-region, and determine third position information of the sub-squares contained in the sub-region;

[0143] The reading module 64 is used to read the sub-bearing data corresponding to the second color value configured in each sub-square of the third position information in the two-dimensional code image according to the third position information of the sub-square in each sub-region, and according to the combination order of the sub-squares in the preset sub-region, combine the sub-bearing data corresponding to each sub-square that carries the data to obtain the data carried by the two-dimensional code image, and save it.

[0144] In a possible implementation manner, the recognition module 61 is specifically configured to determine, for each two-dimensional code image, first position information of each anchor sub-square of the two-dimensional code image located at the edge based on a preset third color value of the anchor sub-square in the sub-region of the two-dimensional code image located at the edge;

[0145] Based on the first position information of each anchor point sub-square located at the edge, the edge area of ​​the two-dimensional code image is determined; and in the internal area of ​​the two-dimensional code image, based on the first color value, the first position information of each anchor point sub-square located in the internal area is determined.

[0146] In a possible implementation, the reading module 64 is specifically used to, if it is identified that the color value of any anchor point sub-square is a preset fourth color value, then starting from the sub-region to which the anchor point sub-square belongs, according to the combination order of the sub-squares in the preset sub-region, combine the sub-data corresponding to each data-bearing sub-square to obtain the data carried by the two-dimensional code image.

[0147] In a possible implementation, the recognition module 61 is further used to select, for each two-dimensional code image, at least one sub-image according to a set pixel interval from the image displayed in the acquisition area when the two-dimensional code image is recognized; for each sub-image, determine respectively a fourth number of pixels in the sub-image whose color values ​​of the pixel values ​​are higher than a set median value of the reference color, and a fifth number of pixels in the sub-image whose color values ​​are lower than the set median value of the reference color, and determine whether a ratio of the fourth number to the fifth number is within a set ratio range; if so, determine the sub-image as a sub-image located in the two-dimensional code image, and based on the position information of the sub-image, perform a step of respectively identifying the first position information of each anchor sub-square contained in at least one two-dimensional code image based on the first color value configured in the preset anchor sub-square.

[0148] In a possible implementation, the device further includes:

[0149] A fusion module is used to set the color value of the anchor sub-square of the sub-area to the set fifth color value for each QR code image if the QR code image is identified, use the QR code image as the first QR code image among multiple QR code images that carry data to be transmitted, and determine whether the data carried by the first QR code image corresponding to the fifth color value has been obtained based on the QR code decoding instruction. If so, the data carried by each QR code image currently saved based on the QR code decoding instruction is fused and the decoding process is terminated.

[0150] In a possible implementation, the fusion module is also used to, if the color value of the anchor sub-square of the sub-area is set to a set sixth color value in the identified QR code image, use the QR code image as the last QR code image among multiple QR code images that carry data to be transmitted, fuse the data carried by each QR code image currently saved based on the QR code decoding instruction, and end the decoding process.

[0151] In a possible implementation, the identification module 61 is specifically used to determine, for each two-dimensional code image, the first position information of each anchor sub-square contained in the two-dimensional code image based on the first color value configured in the preset anchor sub-square and the first position information of each anchor sub-square contained in the other two-dimensional code image, if the data carried by other two-dimensional code images has been obtained before the two-dimensional code image based on the two-dimensional code decoding instruction.

[0152] In a possible implementation, the reading module 64 is specifically used to determine, for each sub-square of the third position information, a second color value configured in the sub-square of the third position information; determine the target binary data corresponding to the second color value based on a correspondence between predetermined binary data and color values ​​in a hue, saturation, and brightness HSL color space; and use the target binary data as sub-carrier data corresponding to the second color value configured in the sub-square of the third position information.

[0153] In a possible implementation manner, the reading module 64 is further configured to determine, for each sub-region in the two-dimensional code image, an actual color lower limit value and an actual color upper limit value of the second color value configured for each sub-square of the third position information in the sub-region if it is recognized that the two-dimensional code image contains the set first reference color sub-square and the second reference color sub-square;

[0154] Determine the color value correction coefficient of the sub-area by comparing the actual color upper limit value with the reference color upper limit value configured in the second reference color sub-square, and comparing the actual color lower limit value with the reference color lower limit value configured in the first reference color sub-square;

[0155] Based on the color value correction coefficient, the second color value of the sub-grid configuration of each third position information of the determined sub-area is corrected, and based on the corrected second color value, a subsequent step of determining the target binary data corresponding to the second color value is performed according to the correspondence between the predetermined binary data and the color value of the hue, saturation, and brightness HSL color space.

[0156] Based on the same technical concept, the present application also provides an electronic device, Figure 7A schematic diagram of the structure of an electronic device provided by some embodiments is shown. Figure 7 As shown, the electronic device includes: a processor 71, a communication interface 72, a memory 73 and a communication bus 74, wherein the processor 71, the communication interface 72, and the memory 73 communicate with each other through the communication bus 74;

[0157] A computer program is stored in the memory 73. When the program is executed by the processor 71, the processor 71 executes the computer program stored in the memory to implement the steps of any of the above-mentioned two-dimensional code encoding methods, or implement the steps of any of the above-mentioned two-dimensional code decoding methods.

[0158] Since the principle of solving the problem by the above electronic device is similar to the two-dimensional code encoding method and the two-dimensional code decoding method, the implementation of the above electronic device can refer to the implementation of the method, and the repeated parts will not be repeated.

[0159] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0160] The communication interface 72 is used for communication between the above electronic device and other devices.

[0161] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

[0162] The above-mentioned processor can be a general-purpose processor, including a central processing unit, a network processor (Network Processor, NP), etc.; it can also be a digital signal processing processor (Digital Signal Processing, DSP), an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, etc.

[0163] Based on the same technical concept, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program that can be executed by an electronic device. When the program runs on the electronic device, the electronic device implements the steps of any one of the above-mentioned two-dimensional code encoding methods, or implements the steps of any one of the above-mentioned two-dimensional code decoding methods.

[0164] Since the principle of solving the problem by the above-mentioned computer-readable storage medium is similar to that of the two-dimensional code encoding method and the two-dimensional code decoding method, the implementation of the above-mentioned computer-readable storage medium can refer to the implementation of the method, and the repeated parts will not be repeated.

[0165] The above-mentioned computer-readable storage medium can be any available medium or data storage device that can be accessed by the processor in the electronic device, including but not limited to magnetic storage such as floppy disks, hard disks, magnetic tapes, magneto-optical disks (MO), etc., optical storage such as CD, DVD, BD, HVD, etc., and semiconductor storage such as ROM, EPROM, EEPROM, non-volatile memory (NANDFLASH), solid-state drive (SSD), etc.

[0166] Based on the same technical concept, the present application provides a computer program product, which includes: computer program code, when the computer program code runs on a computer, it enables the computer to implement the QR code encoding method and QR code decoding method described in any method embodiment applied to an electronic device.

[0167] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof, and all or part of the embodiments may be implemented in the form of a computer program product. The computer program product includes one or more computer instructions, and when the computer instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present application are generated.

[0168] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.

[0169] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0170] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0171] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0172] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

Claims

1. A two-dimensional code encoding method, It is characterized in that The method comprises: If a two-dimensional code encoding instruction is received, the data to be transmitted and the data volume of the data to be transmitted carried in the encoding instruction are obtained; according to the data volume and the predetermined data carrying capacity of a two-dimensional code template, a first number of two-dimensional code templates required to transmit the data to be transmitted is determined; wherein each two-dimensional code template contains a preset second number of sub-regions, each of the sub-regions contains a preset third number of sub-squares, and for each of the sub-regions, a sub-square at a set position in the sub-region is configured as an anchor sub-square, and the anchor sub-square is configured as a set first color value; Determine, according to the first quantity and the data to be transmitted, the sub-data to be transmitted corresponding to each two-dimensional code template to be encoded; For each of the two-dimensional code templates, determine the sub-bearing data corresponding to each sub-square that carries data in the two-dimensional code template according to the sub-data to be transmitted corresponding to the two-dimensional code template and the sorting order of each sub-square in the two-dimensional code template; and configure each sub-square that carries data to the second color value corresponding to the corresponding sub-bearing data; The anchor point sub-squares in the sub-region at the edge of each two-dimensional code template are configured as a preset third color value.

2. The method according to claim 1, It is characterized in that The method further comprises: If the first number is not less than 2, sorting each two-dimensional code template according to the sub-data to be transmitted corresponding to each two-dimensional code template; For each QR code template, if the anchor sub-square located in the sub-area at the edge in the two other QR code templates before and after the QR code template is configured as a preset third color value, the color value of the anchor sub-square located in the sub-area at the edge in the QR code template is adjusted to a value other than the third color value.

3. The method according to any one of claims 1-2, It is characterized in that For each two-dimensional code template, in the sorting order of each sub-region in the two-dimensional code template, the first color value of the anchor point sub-square in the sub-region ranked first is configured as the preset fourth color value.

4. The method according to claim 2, It is characterized in that The method further comprises: For the first-ranked two-dimensional code template in the sorting, the first color value of the anchor point sub-square of the set sub-region in the two-dimensional code template is adjusted to the set fifth color value.

5. The method according to claim 2, It is characterized in that The method further comprises: For the last-ranked two-dimensional code template in the sorting, the first color value of the anchor point sub-square of the set sub-region in the two-dimensional code template is adjusted to the set sixth color value.

6. The method according to claim 1, It is characterized in that The step of configuring each data-bearing sub-square to a second color value corresponding to the corresponding sub-bearing data includes: For each sub-square that carries data, determine the target binary data corresponding to the sub-carrying data corresponding to the sub-square that carries the data; determine the second color value corresponding to the target binary data based on the predetermined correspondence between the binary data and the color value of the hue, saturation, and brightness HSL color space; and configure the sub-square that carries the data to the second color value.

7. The method according to claim 1 or 6, It is characterized in that For each QR code template, the QR code template includes at least one first reference color sub-square and at least one second reference color sub-square, wherein the first reference color sub-square is configured with a set reference color lower limit value; and the second reference color sub-square is configured with a set reference color upper limit value.

8. A two-dimensional code decoding method, It is characterized in that The method comprises: If a two-dimensional code decoding instruction is received, first position information of each anchor point sub-square contained in at least one two-dimensional code image is respectively identified based on a first color value configured in a preset anchor point sub-square; For each two-dimensional code image, based on the first position information of each anchor sub-square contained in the two-dimensional code image, determine the second position information of the sub-region to which each anchor sub-square belongs; For each of the sub-regions, determine the number of sub-squares contained in the sub-region, and determine third position information of the sub-squares contained in the sub-region; According to the third position information of the sub-square in each sub-region, the sub-bearing data corresponding to the second color value configured in each sub-square of the third position information in the two-dimensional code image is read; according to the combination order of the sub-squares in the preset sub-region, the sub-bearing data corresponding to each sub-square carrying data is combined to obtain the data carried by the two-dimensional code image, and the data is saved.

9. The method according to claim 8, It is characterized in that The step of respectively identifying the first position information of each anchor sub-square contained in at least one two-dimensional code image based on the first color value configured in the preset anchor sub-square comprises: For each two-dimensional code image, based on a preset third color value of the anchor sub-square in the sub-region where the two-dimensional code image is located at the edge, determine first position information of each anchor sub-square of the two-dimensional code image located at the edge; Based on the first position information of each anchor point sub-square located at the edge, the edge area of ​​the two-dimensional code image is determined; and in the internal area of ​​the two-dimensional code image, based on the first color value, the first position information of each anchor point sub-square located in the internal area is determined.

10. The method according to claim 8, It is characterized in that The step of combining the sub-bearing data corresponding to each sub-square that carries data to obtain the data carried by the two-dimensional code image according to the combination order of the sub-squares in the preset sub-region includes: If the color value of any anchor sub-square is identified as a preset fourth color value, starting from the sub-region to which the anchor sub-square belongs, according to the combination order of the sub-squares in the preset sub-region, the sub-data corresponding to each data-bearing sub-square is combined to obtain the data carried by the QR code image.

11. The method according to claim 8, It is characterized in that After receiving the two-dimensional code decoding instruction, before respectively identifying the first position information of each anchor point sub-square contained in at least one two-dimensional code image based on the first color value configured in the preset anchor point sub-square, the method further includes: For each two-dimensional code image, the image displayed in the acquisition area when the two-dimensional code image is identified is selected, and at least one sub-image is selected according to the set pixel interval; for each sub-image, a fourth number of pixel points in the sub-image whose color values ​​are higher than the set reference color median value, and a fifth number of pixel points whose color values ​​are lower than the set reference color median value are determined respectively, and it is judged whether the ratio of the fourth number to the fifth number is within the set ratio range. If so, the sub-image is determined as a sub-image located in the two-dimensional code image, and subsequent steps are performed based on the position information of the sub-image.

12. The method according to claim 8, It is characterized in that After respectively identifying the first position information of each anchor sub-square contained in at least one two-dimensional code image based on the first color value configured in the preset anchor sub-square, and before determining, for each two-dimensional code image, based on the first position information of each anchor sub-square contained in the two-dimensional code image, the second position information of the sub-region to which each anchor sub-square belongs, the method further includes: For each QR code image, if the QR code image is identified, the color value of the anchor sub-square of the sub-area is set to the set fifth color value, and the QR code image is used as the first QR code image among multiple QR code images that carry data to be transmitted, and a judgment is made as to whether the data carried by the first QR code image corresponding to the fifth color value has been obtained based on the QR code decoding instruction. If so, the data carried by each QR code image currently saved based on the QR code decoding instruction is merged, and the decoding process is terminated.

13. The method according to claim 8, It is characterized in that The method further comprises: If the color value of the anchor sub-square of the sub-area is set to the set sixth color value in the identified QR code image, the QR code image is used as the last QR code image among multiple QR code images carrying data to be transmitted, the data carried by each QR code image currently saved based on the QR code decoding instruction is merged, and the decoding process is terminated.

14. The method according to claim 8, It is characterized in that The step of respectively identifying the first position information of each anchor sub-square contained in at least one two-dimensional code image based on the first color value configured in the preset anchor sub-square comprises: For each QR code image, if the data carried by other QR code images has been obtained based on the QR code decoding instruction before the QR code image, the first position information of each anchor sub-square contained in the QR code image is determined based on the first color value configured in the preset anchor sub-square and the first position information of each anchor sub-square contained in the other QR code images.

15. The method according to claim 8, It is characterized in that The sub-bearing data corresponding to the second color value configured in each sub-square of the third position information in the two-dimensional code image is read, including: For each sub-square of the third position information, determine the second color value configured in the sub-square of the third position information; determine the target binary data corresponding to the second color value based on the correspondence between the predetermined binary data and the color value of the hue, saturation and brightness HSL color space; and use the target binary data as the sub-carrier data corresponding to the second color value configured in the sub-square of the third position information.

16. The method according to claim 15, It is characterized in that After determining the second color value configured in the sub-square of the third position information, and before determining the target binary data corresponding to the second color value according to the predetermined correspondence between the binary data and the color value of the hue, saturation, and brightness HSL color space, the method further includes: If it is identified that the two-dimensional code image includes the set first reference color sub-square and second reference color sub-square, for each sub-region in the two-dimensional code image, determine the actual color lower limit value and the actual color upper limit value of the second color value configured for each sub-square of the third position information in the sub-region; Determine the color value correction coefficient of the sub-area by comparing the actual color upper limit value with the reference color upper limit value configured in the second reference color sub-square, and comparing the actual color lower limit value with the reference color lower limit value configured in the first reference color sub-square; Based on the color value correction coefficient, the second color value of the sub-grid configuration of each third position information of the determined sub-region is corrected, and subsequent steps are performed based on the corrected second color value.

17. A two-dimensional code encoding device, It is characterized in that The device comprises: A first determination module is configured to, if a two-dimensional code encoding instruction is received, obtain the data to be transmitted and the data volume of the data to be transmitted carried in the encoding instruction; determine a first number of two-dimensional code templates required to transmit the data to be transmitted according to the data volume and a predetermined data carrying capacity of a two-dimensional code template; wherein each two-dimensional code template includes a preset second number of sub-regions, each of the sub-regions includes a preset third number of sub-squares, and for each of the sub-regions, a sub-square at a set position in the sub-region is configured as an anchor sub-square, and the anchor sub-square is configured as a set first color value; A second determining module, configured to determine the sub-data to be transmitted corresponding to each two-dimensional code template to be encoded according to the first quantity and the data to be transmitted; A configuration module is used to determine, for each of the two-dimensional code templates, the sub-bearing data corresponding to each sub-square that carries data in the two-dimensional code template according to the sub-data to be transmitted corresponding to the two-dimensional code template and the sorting order of each sub-square in the two-dimensional code template; and configure each sub-square that carries data to a second color value corresponding to the respective corresponding sub-bearing data; The anchor point sub-squares in the sub-region at the edge of each two-dimensional code template are configured as a preset third color value.

18. A two-dimensional code decoding device, It is characterized in that The device comprises: an identification module, configured to, upon receiving a two-dimensional code decoding instruction, respectively identify first position information of each anchor point sub-square contained in at least one two-dimensional code image based on a first color value configured in a preset anchor point sub-square; A third determination module is used to determine, for each two-dimensional code image, second position information of the sub-region to which each anchor sub-square belongs based on the first position information of each anchor sub-square contained in the two-dimensional code image; A fourth determination module, configured to determine, for each of the sub-regions, the number of sub-squares contained in the sub-region, and determine third position information of the sub-squares contained in the sub-region; The reading module is used to read the sub-bearing data corresponding to the second color value configured in each sub-square of the third position information in the two-dimensional code image according to the third position information of the sub-square in each sub-region, and according to the combination order of the sub-squares in the preset sub-region, combine the sub-bearing data corresponding to each sub-square that carries the data to obtain the data carried by the two-dimensional code image, and save it.

19. An electronic device, It is characterized in that The electronic device includes at least a processor and a memory, and the processor is used to implement the steps of a two-dimensional code encoding method as described in any one of claims 1 to 7 when executing a computer program stored in the memory, or to implement the steps of a two-dimensional code decoding method as described in any one of claims 8 to 16.

20. A computer-readable storage medium, It is characterized in that It stores a computer program, which, when executed by a processor, implements the steps of a two-dimensional code encoding method as described in any one of claims 1-7, or implements the steps of a two-dimensional code decoding method as described in any one of claims 8-16.