CN114399010B - Two-dimensional code encoding and decoding method, device, equipment and medium - Google Patents

Two-dimensional code encoding and decoding method, device, equipment and medium Download PDF

Info

Publication number
CN114399010B
CN114399010B CN202111639976.XA CN202111639976A CN114399010B CN 114399010 B CN114399010 B CN 114399010B CN 202111639976 A CN202111639976 A CN 202111639976A CN 114399010 B CN114399010 B CN 114399010B
Authority
CN
China
Prior art keywords
sub
dimensional code
square
data
anchor
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202111639976.XA
Other languages
Chinese (zh)
Other versions
CN114399010A (en
Inventor
王坤山
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Telecom Corp Ltd
Original Assignee
China Telecom Corp Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China Telecom Corp Ltd filed Critical China Telecom Corp Ltd
Priority to CN202111639976.XA priority Critical patent/CN114399010B/en
Publication of CN114399010A publication Critical patent/CN114399010A/en
Application granted granted Critical
Publication of CN114399010B publication Critical patent/CN114399010B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K19/00Record carriers for use with machines and with at least a part designed to carry digital markings
    • G06K19/06Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code
    • G06K19/06009Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code with optically detectable marking
    • G06K19/06037Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code with optically detectable marking multi-dimensional coding
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K19/00Record carriers for use with machines and with at least a part designed to carry digital markings
    • G06K19/06Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code
    • G06K19/06009Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code with optically detectable marking
    • G06K19/06046Constructional details
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K7/00Methods or arrangements for sensing record carriers, e.g. for reading patterns
    • G06K7/10Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation
    • G06K7/14Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation using light without selection of wavelength, e.g. sensing reflected white light
    • G06K7/1404Methods for optical code recognition
    • G06K7/1408Methods for optical code recognition the method being specifically adapted for the type of code
    • G06K7/14172D bar codes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K19/00Record carriers for use with machines and with at least a part designed to carry digital markings
    • G06K19/06Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code
    • G06K2019/06215Aspects not covered by other subgroups
    • G06K2019/06225Aspects not covered by other subgroups using wavelength selection, e.g. colour code

Landscapes

  • Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Health & Medical Sciences (AREA)
  • Electromagnetism (AREA)
  • General Health & Medical Sciences (AREA)
  • Toxicology (AREA)
  • Artificial Intelligence (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)
  • Compression, Expansion, Code Conversion, And Decoders (AREA)

Abstract

The application discloses a two-dimensional code encoding and decoding method, a device, equipment and a medium, which are used for improving the correct recognition rate of a two-dimensional code. Because the two-dimensional code template comprises the second number of subareas, each subarea comprises the third number of subareas, and the subareas at the set positions in the subareas are configured as anchor subareas for each subarea, the two-dimensional code template can position a two-dimensional code image based on the anchor subareas, and when the two-dimensional code image is decoded later, even if the two-dimensional code image is scanned at different angles, the distortion phenomenon exists in the two-dimensional code image displayed in the acquired image, each subarea and each subarea contained in the two-dimensional code image can be determined based on the anchor subareas, so that the data information carried by each subarea in the two-dimensional code image can be restored to the greatest extent, the distortion resistance of the two-dimensional code image can be improved, and the correct recognition rate of the two-dimensional code can be improved.

Description

Two-dimensional code encoding and decoding method, device, equipment and medium
Technical Field
The present application relates to the field of data service technologies, and in particular, to a method, an apparatus, a device, and a medium for encoding and decoding a two-dimensional code.
Background
The one-dimensional code expresses information by bars and spaces arranged in the horizontal direction, and does not express information in the vertical direction, and the capacity is very limited. The two-dimensional code can express information in the horizontal direction and the vertical direction at the same time, so that more information can be expressed in a smaller area than the one-dimensional code. Meanwhile, by applying an error correction algorithm to the two-dimensional code, the reliability of the two-dimensional code is greatly improved. In recent years, the application of the two-dimensional code is more and more extensive, the two-dimensional code is rapidly popularized in daily life of people, and great convenience is provided for the life of people.
Although the two-dimensional code has been widely popularized at present, the existing two-dimensional code has certain limitations in many scenes, and the most prominent is that the capability of the existing two-dimensional code for resisting image distortion is insufficient. For example, when the scanned angles of the two-dimensional code images are different, distortion phenomena such as certain inclination, stretching and the like of the two-dimensional code images displayed in the acquired images may exist, so that the two-dimensional code is difficult to be correctly identified, and the correct identification rate of the two-dimensional code is reduced.
Therefore, how to improve the correct recognition rate of the two-dimensional code is a technical problem to be solved.
Disclosure of Invention
The application provides a two-dimensional code encoding and decoding method, a device, equipment and a medium, which are used for improving the correct recognition rate of a two-dimensional code.
In a first aspect, the present application provides a two-dimensional code encoding method, the method including:
If a two-dimensional code coding instruction is received, acquiring data to be transmitted and the data quantity of the data to be transmitted, which are carried in the coding instruction; determining a first number of two-dimensional code templates required for transmitting the data to be transmitted according to the data quantity and a predetermined data bearing capacity of one two-dimensional code template; each two-dimensional code template comprises a preset second number of subareas, each subarea comprises a preset third number of subareas, and for each subarea, the subareas at the preset position in the subarea are configured as anchor subareas, and the anchor subareas are configured as set first color values;
determining 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;
aiming at each two-dimensional code template, determining sub-bearing data corresponding to each sub-square of bearing data in the two-dimensional code template according to sub-data to be transmitted corresponding to the two-dimensional code template and the ordering sequence of each sub-square in the two-dimensional code template; and configuring each sub-square carrying data into a second color value corresponding to the corresponding sub-carrying data.
In a second aspect, the present application provides a two-dimensional code decoding method, the method including:
If a two-dimensional code decoding instruction is received, respectively identifying first position information of each anchor sub-square contained in at least one two-dimensional code image based on a first color value configured in a preset anchor sub-square;
determining second position information of a subarea to which each anchor sub-square belongs based on the first position information of each anchor sub-square contained in each two-dimensional code image;
Determining the number of sub-squares contained in each sub-area according to each sub-area, and determining third position information of the sub-squares contained in the sub-area;
And reading sub-bearing data corresponding to a 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-area, combining the sub-bearing data corresponding to the sub-square of each bearing data according to the preset combination sequence of the sub-squares in the sub-area to obtain the data carried by the two-dimensional code image, and storing the data.
In a third aspect, the present application provides a two-dimensional code encoding apparatus, the apparatus comprising:
The first determining module is used for acquiring data to be transmitted and the data quantity of the data to be transmitted, which are carried in the encoding instruction, if the two-dimensional code encoding instruction is received; determining a first number of two-dimensional code templates required for transmitting the data to be transmitted according to the data quantity and a predetermined data bearing capacity of one two-dimensional code template; each two-dimensional code template comprises a preset second number of subareas, each subarea comprises a preset third number of subareas, and for each subarea, the subareas at the preset position in the subarea are configured as anchor subareas, and the anchor subareas are configured as set first color values;
the second determining module is used for determining 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;
The configuration module is used for determining 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 ordering sequence of each sub-square in the two-dimensional code template; and configuring each sub-square carrying data into a second color value corresponding to the corresponding sub-carrying data.
In a fourth aspect, the present application provides a two-dimensional code decoding apparatus, the apparatus comprising:
The identification module is used for respectively identifying the first position information of each anchor sub-square contained in at least one two-dimensional code image based on a first color value configured in a preset anchor sub-square if a two-dimensional code decoding instruction is received;
the third determining module is used for determining second position information of a subarea to which each anchor sub-square belongs according to the first position information of each anchor sub-square contained in each two-dimensional code image;
A fourth determining module, configured to determine, for each sub-area, a number of sub-squares included in the sub-area, and determine third location information of the sub-squares included in the sub-area;
The reading module is used for reading 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-area, combining the sub-bearing data corresponding to the sub-square of each bearing data according to the preset combination sequence of the sub-squares in the sub-area to obtain the data carried by the two-dimensional code image, and storing the data.
In a fifth aspect, the present application provides an electronic device, where the electronic device includes at least a processor and a memory, where the processor is configured to implement a step of a two-dimensional code encoding method according to any one of the above or implement a step of a two-dimensional code decoding method according to any one of the above when executing a computer program stored in the memory.
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 two-dimensional code encoding methods described above, or implements the steps of any one of the two-dimensional code decoding methods described above.
The two-dimensional code template comprises a second number of subareas, each subarea comprises a third number of subareas, and the subareas at the set positions in each subarea are configured as anchor subareas, and the anchor subareas are configured as set first color values. When a two-dimensional code encoding instruction is received and two-dimensional code encoding is carried out, data to be transmitted and the data quantity of the data to be transmitted carried in the encoding instruction can be obtained; determining a first number of two-dimensional code templates required for transmitting data to be transmitted according to the data amount of the data to be transmitted and the data bearing capacity of a predetermined two-dimensional code template; determining 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; aiming at each two-dimensional code template, determining sub-bearing data corresponding to each sub-square carrying data in the two-dimensional code template according to sub-data to be transmitted corresponding to the two-dimensional code template and the ordering sequence of each sub-square in the two-dimensional code template; and configuring each sub-square carrying data into a second color value corresponding to the corresponding sub-carrying data. The method and the device can position the two-dimensional code image based on the anchor sub-square, and can determine the second position information of each sub-area based on the first position information of each anchor sub-square when the two-dimensional code image is decoded, further determine the third position information of the sub-square contained in each sub-area, so that the position information of each sub-area and the sub-square contained in the two-dimensional code image can be determined based on the anchor sub-square even if the two-dimensional code image is different in scanning angle and the like, and the two-dimensional code image displayed in the acquired image has certain distortion phenomena such as inclination, stretching and the like, thereby maximally identifying (restoring) the data information borne by each sub-square in the two-dimensional code image, enhancing the anti-distortion capability of the two-dimensional code image, maximally ensuring that the two-dimensional code can be correctly identified, rapidly and accurately identifying the two-dimensional code, and enhancing the correct identification rate of the two-dimensional code.
Drawings
In order to more clearly illustrate the embodiments of the present application or the implementation of the related art, the drawings that are required for the embodiments or the related art description will be briefly described, and it is apparent that the drawings in the following description are some embodiments of the present application and that other drawings may be obtained according to these drawings for a person having ordinary skill in the art.
Fig. 1 illustrates a schematic diagram of a two-dimensional code encoding process provided by some embodiments;
Fig. 2a illustrates a schematic diagram of a two-dimensional code template provided by some embodiments;
FIG. 2b illustrates a sub-region schematic provided by some embodiments;
fig. 3 illustrates a schematic diagram of a two-dimensional code decoding process provided by some embodiments;
FIG. 4 illustrates a process diagram for determining second location information for a sub-region provided by some embodiments;
fig. 5 illustrates a schematic diagram of a two-dimensional code encoding apparatus provided by some embodiments;
fig. 6 illustrates a schematic diagram of a two-dimensional code decoding apparatus provided in some embodiments;
Fig. 7 illustrates a schematic structural diagram of an electronic device provided in some embodiments.
Detailed Description
For the purpose of promoting an understanding of the principles and advantages of the application, reference will now be made in detail to the drawings and specific examples, some but not all of which are illustrated in the accompanying drawings. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
It should be noted that the brief description of the terminology in the present application is for the purpose of facilitating understanding of the embodiments described below only and is not intended to limit the embodiments of the present application. Unless otherwise indicated, these terms should be construed in their ordinary and customary meaning.
The terms first, second, third and the like in the description and in the claims and in the above-described figures are used for distinguishing between similar or similar objects or entities and not necessarily for describing a particular sequential or chronological order, unless otherwise indicated. It is to be understood that the terms so used are interchangeable under appropriate circumstances.
The terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a product or apparatus that comprises a list of elements is not necessarily limited to all elements explicitly listed, but may include other elements not expressly listed or inherent to such product or apparatus.
The term "module" refers to any known or later developed hardware, software, firmware, artificial intelligence, fuzzy logic, or combination of hardware or/and software code that is capable of performing the function associated with that element.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present application, and not for limiting the same; although the application has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some or all of the technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit of the application.
In order to improve the correct recognition rate of the two-dimensional code, the application provides a two-dimensional code coding and decoding method, a device, equipment and a medium.
Fig. 1 shows a schematic diagram of a two-dimensional code encoding process provided by some embodiments, as shown in fig. 1, the process includes the following steps:
s101: if a two-dimensional code coding instruction is received, acquiring data to be transmitted and the data quantity of the data to be transmitted, which are carried in the coding instruction; determining a first number of two-dimensional code templates required for transmitting the data to be transmitted according to the data quantity and a predetermined data bearing capacity of one two-dimensional code template; each two-dimensional code template comprises a preset second number of sub-areas, each sub-area comprises a preset third number of sub-squares, and for each sub-area, the sub-squares at the preset position in the sub-area are configured as anchor sub-squares, and the anchor sub-squares are configured as set first color values.
The two-dimensional code encoding method provided by the embodiment of the application is applied to electronic equipment, and the electronic equipment can be equipment such as a PC (personal computer), a mobile terminal and the like, and can also be equipment such as a server and the like.
In a possible implementation manner, when a user needs to encode certain data to be transmitted into a two-dimensional code, a "code" button in the electronic device and the like can be triggered to trigger a two-dimensional code encoding instruction, and the electronic device can receive the two-dimensional code encoding instruction. The method for triggering the two-dimensional code coding instruction is not particularly limited, and the method can be flexibly set according to requirements. After receiving the two-dimension code coding instruction, the electronic device can acquire the data to be transmitted and the data quantity of the data to be transmitted, which are carried in the coding instruction.
Optionally, in order to improve the encoding efficiency of the two-dimensional code, a two-dimensional code template for encoding may be pre-stored in the electronic device. Referring to fig. 2a, fig. 2a illustrates a schematic diagram of a two-dimensional code template provided by some embodiments, as shown in fig. 2a, each two-dimensional code template may include a preset second number of sub-regions, where the second number may be flexibly set according to requirements, and the application is not limited in this way. By way of example, the second number may be 16 (4 2)、64(82), or the like.
Referring to fig. 2b, fig. 2b illustrates a schematic view of a sub-area provided by some embodiments, as shown in fig. 2b, each sub-area in the two-dimensional code template may include a preset third number of sub-squares, where the third number may be flexibly set according to requirements, and the application is not limited in this way. By way of example, the third number may be 729 (27 2), or the like.
In addition, in order to improve the correct recognition rate of the two-dimensional code, in the embodiment of the present application, for each sub-area, the sub-square at the set position in the sub-area may be configured as an anchor sub-square. The setting position can be flexibly set according to the requirement, and the application is not particularly limited to the setting position. For example, referring to fig. 2b, in the sub-area, the sub-square located at the center of the sub-area may be configured as an anchor sub-square, for example, taking k rows and k columns of sub-squares included in the sub-area, where k is an odd number as an example, and the (k+1)/2 th row and (k+1)/2 column of sub-square in the sub-area may be configured as an anchor sub-square.
In addition, in order to identify an anchor sub-square when decoding a two-dimensional code image (two-dimensional code) formed by the two-dimensional code template encoding, the anchor sub-square may be configured to have a set first color value. The first color value may be flexibly set according to the requirement, which is not particularly limited in the present application. Illustratively, the first color value may be a color value of hue, saturation, brightness (HSL) color space gray, or the like.
In addition, in order to improve the two-dimensional code encoding efficiency, the amount of data that can be carried by one two-dimensional code template (referred to as the data carrying capacity for convenience of description) may be predetermined. For example, considering that the number of sub-squares for carrying data in the two-dimensional code template is predeterminable, the amount of data that can be carried by each sub-square for carrying data is also predeterminable, and therefore, the data carrying capacity of the two-dimensional code template can be determined according to the product of the number of sub-squares for carrying data in the two-dimensional code template and the amount of data that can be carried by each sub-square.
In one possible embodiment, the number of two-dimensional code templates (referred to as the first number for convenience of description) required for transmitting the data to be transmitted may be determined according to the data amount of the data to be transmitted and a predetermined data carrying amount of one two-dimensional code template. For example, the first number may be determined according to a ratio of a data amount of data to be transmitted to a predetermined data carrying amount of one two-dimensional code template. In one possible embodiment, the ratio may be rounded up to a first number if the ratio is not an integer. Illustratively, if the ratio of the data amount of the data to be transmitted to the predetermined data carrying amount of one two-dimensional code template is 10, the first number is 10. If the ratio of the data amount of the data to be transmitted to the predetermined data carrying capacity of one two-dimensional code template is 9.5, the ratio may be rounded up, and the first number may be determined to be 10.
S102: and determining 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.
After the first number is determined, transmission data (called sub-data to be transmitted for convenience of description) corresponding to each two-dimensional code template to be encoded can be determined according to the first number and the data to be transmitted. Optionally, the data to be transmitted may be divided into a first number of sub-data to be transmitted, and each two-dimensional code template corresponds to one sub-data to be transmitted. For example, if the first number is 10 and the data amount of the data to be transmitted is 500KB, the data to be transmitted may be divided into 10 sub-data to be transmitted in average in sequence, and each two-dimensional code template corresponds to one sub-data to be transmitted of 50 KB.
S103: aiming at each two-dimensional code template, determining sub-bearing data corresponding to each sub-square of bearing data in the two-dimensional code template according to sub-data to be transmitted corresponding to the two-dimensional code template and the ordering sequence of each sub-square in the two-dimensional code template; and configuring each sub-square carrying data into a second color value corresponding to the corresponding sub-carrying data.
After determining the sub-data to be transmitted corresponding to each two-dimensional code template, determining 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 ordering sequence of each sub-square contained in the two-dimensional code template. For example, referring to fig. 2a and 2b, it is assumed that the order of ordering each sub-region in the two-dimensional code template in the order from top to bottom and from left to right is: f0, f1, f2, f3, f4, f5 … … f15, meanwhile, the sorting order of the sub-squares included in each sub-area is also from top to bottom and from left to right, taking the sub-squares included in the f0 sub-area as D1, D2 and D3 … … Dn as examples, the data (for convenience of description, called sub-bearing data) corresponding to the sub-squares of each bearing data in the f0 sub-area can be determined in turn, then the sub-bearing data corresponding to the sub-squares of each bearing data in the f1 sub-area is determined, and so on, and no further description is given here.
In one possible implementation manner, when two-dimensional code encoding is performed, each sub-square carrying data can be configured to be a second color value corresponding to each corresponding sub-carrying data. The color space to which the second color value belongs is not particularly limited, and can be flexibly set according to requirements. The second color value may be, for example, a black-and-white color, a color value of an RGB color space, a color value of an HSL color space, or the like.
In one possible implementation, it is considered that when the second color value is black and white, the amount of data carried by each sub-square may be smaller, so that the amount of data that each two-dimensional code can carry may be smaller. In order to increase the amount of data that the two-dimensional code can carry, the second color value may be configured as a color value of an RGB color space, a color value of an HSL color space, or the like. In one possible implementation, it is considered that when the second color value is configured as a color value of the RGB color space, since color differences between colors of different color values of the RGB color space may be small, it is easy to cause that when the two-dimensional code is decoded, data information carried by the two-dimensional code may not be correctly read due to a color recognition error or the like. 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 partition, more uniform interval and higher coding density.
In one possible implementation, when each sub-square of the bearer data is configured as the second color value of the HSL color space corresponding to the sub-bearer data corresponding to each sub-square of the bearer data, binary data (referred to as target binary data for convenience of description) corresponding to the sub-bearer data corresponding to the sub-square of the bearer data is determined first. The binary data corresponding to the subcarrier data may be determined by using the prior art, which is not described herein.
Alternatively, the correspondence between binary data and the color values of the HSL color space may be predetermined, where the color values of the HSL color space corresponding to the binary data may be flexibly set according to the requirement, which is not specifically limited in the present application. After determining the target binary data corresponding to the sub-bearer data corresponding to each sub-square of the bearer data in the two-dimensional code template, determining the respective second color value of each target binary data according to the corresponding relation between the predetermined binary data and the color value of the HSL color space, and configuring each sub-square of the bearer data as the respective second color value.
In one possible implementation manner, the anchor sub-square may be mainly used for positioning the two-dimensional code image, so as to improve the distortion resistance of the two-dimensional code image, and the anchor sub-square may not be used for carrying data, and optionally, the sub-square carrying data in the two-dimensional code template may not include the anchor sub-square.
The second color value can be configured into the color value of the HSL color space with better color partition, more uniform interval and higher coding density, so that the data bearing capacity of the two-dimensional code image can be improved, confidential file transfer, emergency environment electronic file transfer, flying environment media file downloading, electronic book offline downloading and the like can be carried out based on the two-dimensional code image under a network-free working environment, the application scene of the two-dimensional code can be widened, and the safety guarantee capability of the data borne in the two-dimensional code under special scenes without a network and the like can be improved.
For convenience of understanding, the two-dimensional code encoding process provided by the application is explained by a specific embodiment. Each two-dimensional code template is assumed to comprise n rows and n columns, n is taken as an example, and n is taken as 8, and 64 small square sub-regions are all included. Wherein each sub-region comprises k rows and k columns, and k is k in total. Taking k as 27 as an example, 729 sub-tiles are shared in each sub-area. Illustratively, each sub-square is 3 pixels wide and the two-dimensional code image is 648 pixels wide.
In the second color value of the HSL color space configured in each sub-square, 2 a points can be uniformly selected in the H value range of (0, 1) to represent the data quantity of a bits, 2 b points can be uniformly selected in the S value range of [0.55,1] to represent the data quantity of b bits, 2c points can be uniformly selected in the L value range of [0.35,0.65] to represent the data quantity of c bits, and each sub-square can represent the data quantity of a+b+c bits.
For example, assuming that the amount of data that each sub-square can carry is 1byte (8 bits), for each sub-square carrying data, the H value of the sub-square may be: 0.03125+i/16 (i=1, 2,3 … …, 16) is 16 bits, and represents the data amount of 4 bits in total of 0 to 3 bits (a=4) of each byte of the sub-square. The S value of the sub-square may be selected from: 0.55, 0.7, 0.85, 1 total 4 dots, representing a total of 2 bits of data amount of 4 to 5 bits (b=2) per byte of the sub-square. The L value of the sub-square may be selected from: 0.35, 0.45, 0.55, 0.65 total 4 dots, representing a total data amount of 2 bits per 6 to 7 bits (c=2) of each byte of the sub-square.
Assuming that each sub-area includes an anchor sub-square, a first reference color sub-square and a second reference color sub-square, the number of sub-squares used for carrying data in each sub-area is k x k-3. The amount of data carried by each sub-region is (k-3) (a+b+c). Taking k as 27 and a+b+c as 8 bits as an example, each sub-area carries 726 bytes of data. The bearing data corresponding to the subareas of each two-dimensional code template are as follows: and (i.64+j) 726 to (i.64+j) 726+725, wherein if the sorting of each two-dimensional code template is called a first sorting according to the sub-data to be transmitted corresponding to each two-dimensional code template, i+1 is the ranking of a certain two-dimensional code template in the first sorting. If the ordering order of each sub-square in each two-dimensional code template is called a second ordering for each two-dimensional code template, j+1 is the ranking of a certain sub-area in the second ordering. Taking the first sub-area in the first two-dimensional code template as an example, the bearing data in the sub-area is the data quantity of the 0 th to 725 th 726 bytes in the data to be transmitted. The bearer data of other sub-areas may be similar, and will not be described in detail herein.
The two-dimensional code template comprises a second number of subareas, each subarea comprises a third number of subareas, and the subareas at the set positions in each subarea are configured as anchor subareas, and the anchor subareas are configured as set first color values. When a two-dimensional code encoding instruction is received and two-dimensional code encoding is carried out, data to be transmitted and the data quantity of the data to be transmitted carried in the encoding instruction can be obtained; determining a first number of two-dimensional code templates required for transmitting data to be transmitted according to the data amount of the data to be transmitted and the data bearing capacity of a predetermined two-dimensional code template; determining 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; aiming at each two-dimensional code template, determining sub-bearing data corresponding to each sub-square carrying data in the two-dimensional code template according to sub-data to be transmitted corresponding to the two-dimensional code template and the ordering sequence of each sub-square in the two-dimensional code template; and configuring each sub-square carrying data into a second color value corresponding to the corresponding sub-carrying data. The method and the device can position the two-dimensional code image based on the anchor sub-square, and can determine the second position information of each sub-area based on the first position information of each anchor sub-square when the two-dimensional code image is decoded, further determine the third position information of the sub-square contained in each sub-area, so that the position information of each sub-area and the sub-square contained in the two-dimensional code image can be determined based on the anchor sub-square even if the two-dimensional code image is different in scanning angle and the like, and the two-dimensional code image displayed in the acquired image has certain distortion phenomena such as inclination, stretching and the like, thereby maximally identifying (restoring) the data information borne by each sub-square in the two-dimensional code image, enhancing the anti-distortion capability of the two-dimensional code image, maximally ensuring that the two-dimensional code can be correctly identified, rapidly and accurately identifying the two-dimensional code, and enhancing the correct identification rate of the two-dimensional code.
In a possible implementation manner, in order to facilitate fast and accurate identification of a boundary where a two-dimensional code is located when decoding the two-dimensional code, and improve decoding rate, on the basis of the foregoing embodiment, in the embodiment of the present application, when encoding the two-dimensional code, for each two-dimensional code template, anchor sub-squares in a sub-region located at an edge of the two-dimensional code in the two-dimensional code template may be configured to be a preset third color value. Referring to fig. 2b, anchor sub-squares in sub-areas such as f1, f2, f3, f4, and f7 at the edge of the two-dimensional code may be configured to be a preset third color value. Specifically, the third color value may be flexibly set according to the requirement, which is not particularly limited in the present application. Illustratively, the third color value of the anchor sub-square located in the sub-area of the edge may be black, white, etc. Wherein the third color value of the anchor sub-square in the sub-area located at the edge may be different from the first color value of the anchor sub-square in the sub-area not located at the edge (e.g., sub-areas f5, f6, etc. in fig. 2 b). For example, for a certain two-dimensional code template, when the third color value of the anchor sub-square in the sub-area of the two-dimensional code template, which is located in the edge, is white, the first color value of the anchor sub-square in the sub-area of the two-dimensional code template, which is not located in the edge, may be black, and so on. When the third color value of the anchor sub-square in the sub-area of the two-dimensional code template, which is located at the edge, is black, the first color value of the anchor sub-square in the sub-area of the two-dimensional code template, which is not located at the edge, may be white, and so on.
In one possible implementation manner, considering that if the first number is not less than 2, that is, if the data to be transmitted needs to be transmitted with a plurality of two-dimensional code images (two-dimensional code templates), in order to facilitate the subsequent process of decoding the two-dimensional code images, the colors of anchor sub-squares in the sub-regions of the two-dimensional code images that are located at the edges can be configured to be different color values when the two-dimensional code images are encoded, and correspondingly, the colors of anchor sub-squares in the sub-regions of the two-dimensional code images that are not located at the edges can be also configured to be different color values.
Specifically, if the first number is not less than 2, each two-dimensional code template may be ordered according to the sub-data to be transmitted corresponding to each two-dimensional code template (for convenience of description, referred to as a first ordering); then, for each two-dimensional code template, when the anchor sub-square in the sub-area located at the edge in the front and rear two other two-dimensional code templates adjacent to the two-dimensional code template is configured to be a preset third color value, the color value of the anchor sub-square in the sub-area located at the edge in the two-dimensional code template is adjusted to be a non-third color value. And when the anchor sub-square in the sub-area positioned at the edge in the front two other two-dimensional code templates adjacent to the two-dimensional code templates is configured to be a non-third color value, configuring the color value of the anchor sub-square in the sub-area positioned at the edge in the two-dimensional code templates to be a third color value.
Taking the first number as 3 as an example, assuming that after each two-dimensional code template is sequenced according to the sub-data to be transmitted corresponding to each two-dimensional code template, the two-dimensional code templates are a first template, a second template and a third template respectively, if anchor sub-squares of the first template in the sub-region of the edge are configured to be black, anchor sub-squares of the first template in the sub-region of the edge are configured to be white; the anchor sub-tiles of the second template in the sub-regions of the edge may be configured to be white and the anchor sub-tiles of the second template not in the sub-regions of the edge may be configured to be black. In addition, anchor sub-tiles of the third template in sub-regions of the edge may be configured to be black and anchor sub-tiles of the third template not in sub-regions of the edge may be configured to be white.
Because the color values of the anchor sub-squares in the sub-regions of the two adjacent two-dimensional code templates, which are positioned at the edges, and the color values of the anchor sub-squares in the sub-regions of the two adjacent two-dimensional code templates, which are not positioned at the edges, are different, the adjacent two-dimensional code images can be rapidly and accurately identified and distinguished when the two-dimensional code templates are decoded subsequently, and the correct identification rate of the two-dimensional codes is further improved.
In a possible implementation manner, in order to facilitate the subsequent decoding of the two-dimensional code image, the ordering sequence of the sub-regions included in the two-dimensional code image may be quickly and accurately identified, so as to improve the two-dimensional code identification accuracy, and 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-region to which the first sub-square is ranked in the ordering sequence (for convenience of description, referred to as the second ordering) of each sub-square in the two-dimensional code template may be configured as a preset fourth color value. The fourth color value can be flexibly configured according to requirements, which is not particularly limited in the application. For example, referring to fig. 2a, the fourth color value may be a color value of a color such as gray. Anchor sub-squares in the sub-area (e.g., f0 sub-area) to which the first sub-square of each two-dimensional code template belongs can be configured to be gray.
In one possible implementation manner, in order to facilitate subsequent decoding of the two-dimensional code image, a first (ranked first) two-dimensional code image in the two-dimensional code image ranking (first ranking) may be identified, and for a two-dimensional code template ranked first in the first ranking, a first color value of an anchor sub-square of a set sub-area in the ranked first two-dimensional code template may be adjusted to a set fifth color value. The position of the setting sub-region and the fifth color value can be flexibly set according to the requirement, which is not particularly limited in the application. Illustratively, referring to FIG. 2a, the set subregion may be the last subregion (e.g., fn subregion) in the second rank. The fifth color value may be black or white, etc. In one possible embodiment, the fourth color value and the fifth color value may be different in order to facilitate distinguishing the first ranked sub-region in the second ranking from the set sub-region. For example, when the color value of the anchor sub-square in the sub-area (e.g., f0 sub-area) to which the first sub-square is ranked in the second ranking is configured to be the gray color value (the fourth color value), the color value of the anchor sub-square in the set sub-area (e.g., fn sub-area) may be adjusted to be a color value (the fifth color value) such as black or white.
For convenience of understanding, the two-dimensional code template provided by the application is explained by a specific embodiment.
Taking the first number as3 as an example, it is assumed that after each two-dimensional code template is ordered according to the sub-data to be transmitted corresponding to each two-dimensional code template, the two-dimensional code templates are a first template, a second template and a third template respectively.
Referring to fig. 2a, assume that in the second ranking of the first template, the fourth color value of the anchor sub-square in the first ranked sub-area f0 (referred to as the top sub-area for convenience of description) is gray. In the second ranking of the first template, the fifth color value of the anchor sub-square in the last sub-area fn (referred to as the last sub-area for convenience of description) is white, the anchor sub-square in the other sub-areas located at the edge except the first sub-area and the last sub-area is configured to be white (third color value), and the anchor sub-square in the sub-area not located at the edge of the first template is configured to be black (first color value).
Optionally, the fourth color value of the anchor sub-square in the head region of the second template is also gray. The fifth color value of the anchor sub-square of the last subregion of the second template is changed to black, the anchor sub-square of the second template in other subregions of the edge except the first subregion and the last subregion is configured to black, and the anchor sub-square of the second template in the subregions not located at the edge is configured to white.
Optionally, the fourth color value of the anchor sub-square in the head region of the third template is also gray. The fifth color value of the anchor sub-square of the last subregion of the third template remains black, the anchor sub-squares of the third template in other subregions of the edge than the first and last subregions are configured to be white (same as the first template), and the anchor sub-squares of the third template in subregions not located at the edge are configured to be black (same as the first template).
In one possible implementation manner, in order to facilitate subsequent decoding of the two-dimensional code image, a last-ranked two-dimensional code image in the two-dimensional code image ranking (first ranking) may be identified, and the first color value of the anchor sub-square of the set sub-area in the last-ranked two-dimensional code template may be adjusted to a set sixth color value. The sixth color value may be flexibly configured according to requirements, which is not particularly limited in the present application.
In one possible implementation manner, considering that certain deviation may exist in the color of the identified two-dimensional code image during the subsequent decoding of the two-dimensional code, and thus the accuracy of the identified two-dimensional code may be affected, in order to improve the correct identification rate of the two-dimensional code, for each two-dimensional code template, at least one first reference color sub-square and at least one second reference color sub-square may be configured in the two-dimensional code template, where a set reference color lower limit value is configured in the first reference color sub-square; the second reference color sub-square is provided with a set reference color upper limit value.
In one possible implementation, for each two-dimensional code template, one first reference color sub-square and one second reference color sub-square may be configured in the two-dimensional code template. The positions of the first reference color sub-square and the second reference color sub-square in the two-dimensional code template are not particularly limited, and the positions can be flexibly set according to requirements, so long as the preset first reference color sub-square and second reference color sub-square can be identified when the two-dimensional code is decoded later.
In a possible implementation manner, referring to fig. 2b, for each two-dimensional code template, a first reference color sub-square and a second reference color sub-square are respectively configured in each sub-area of the two-dimensional code template. The positions of the first reference color sub-square and the second reference color sub-square in the subarea are not particularly limited, and can be flexibly set according to requirements, and in an exemplary embodiment, a sub-square (for convenience of description, referred to as a left sub-square) located on the left side of the anchor sub-square and adjacent to the anchor sub-square in each subarea may be configured as the first reference color sub-square, and a sub-square (for convenience of description, referred to as a right sub-square) located on the right side of the anchor sub-square and adjacent to the anchor sub-square may be configured as the second reference color sub-square.
Taking the range of the second color as H at (0, 1), S at [0.55,1], and L at [0.35,0.65] as an example, H in the lower limit value of the reference color arranged in the first reference color sub-square may be 0.03125, S may be 0.55, and L may be 0.35. The reference color upper limit value arranged in the second reference color sub-square may be 0.96875, s may be 1, and l may be 0.65.
Based on the same technical concept, in the embodiments of the present application, the present application provides a two-dimensional code decoding method, and fig. 3 shows a schematic diagram of a two-dimensional code decoding process provided by some embodiments, as shown in fig. 3, where the process includes the following steps:
s301: and if a two-dimensional code decoding instruction is received, respectively identifying first position information of each anchor sub-square contained in at least one two-dimensional code image based on a first color value configured in the preset anchor sub-square.
The two-dimensional code decoding method provided by the embodiment of the application is applied to electronic equipment, and the electronic equipment can be equipment such as a PC (personal computer), a mobile terminal and the like, and can also be equipment such as a server and the like.
In one possible implementation, when the two-dimensional code image needs to be decoded, the user may trigger the two-dimensional code decoding instruction by clicking a "scan two-dimensional code" button or the like. After receiving the two-dimension code decoding instruction, the electronic equipment can perform the process of identifying (decoding) the two-dimension code. Optionally, in order to ensure that the two-dimensional code can be correctly identified to the greatest extent even when distortion phenomena such as certain inclination and stretching exist in the two-dimensional code image displayed in the acquired image (the image displayed in the acquisition area), the correct identification rate of the two-dimensional code is improved, and the position information (called as first position information for convenience of description) of each anchor sub-square included in each two-dimensional code image can be respectively identified based on the first color value configured in the preset anchor sub-square.
In a possible implementation manner, when the electronic device identifies the two-dimensional code image, the color value of each pixel point in the image displayed in the acquisition area can be identified, and when the first color value is identified, the area (a plurality of continuous pixel points and the like) corresponding to the first color value can be determined as the area where the anchor sub-square is located, so that the first position information of each anchor sub-square contained in the two-dimensional code image can be identified based on the first color value.
S302: and determining second position information of a subarea to which each anchor sub-square belongs based on the first position information of each anchor sub-square contained in each two-dimensional code image.
After the first position information of each anchor sub-square included in the two-dimensional code image is determined for each two-dimensional code image, the position information (referred to as second position information for convenience of description) of the sub-area to which each anchor sub-square belongs may be determined based on the first position information of each anchor sub-square included in the two-dimensional code image. By way of example, taking an anchor sub-grid as a sub-grid located at a central position of a sub-region, since each anchor sub-grid is a sub-grid located at a central position of a corresponding sub-region, referring to fig. 4, fig. 4 illustrates a schematic process for determining second location information of a sub-region provided by some embodiments, when determining each sub-region that is not an edge, the second location information of the sub-region may be determined based on 8 adjacent anchor sub-grids located around the anchor sub-grid of the sub-region. Taking the sub-area f5 in fig. 4 as an example, when determining the sub-area f5, adjacent 8 anchor sub-squares (anchor sub-squares of f0, f1, f2, f4, f6, f8, f9, and f10 sub-areas respectively) located around the anchor sub-square of the sub-area may be determined first, then midpoints (marked with small circles in the figure) of connection lines between the anchor sub-square and the adjacent 8 anchor sub-squares are determined, and these 8 points (midpoints) are sequentially connected, so as to determine the second position information of the sub-area f 5.
For another example, for an anchor sub-square located at an edge, when determining the second location information of the sub-area to which the anchor sub-square belongs, the sub-area to which the anchor sub-square belongs may be determined based on a connection line of the anchor sub-square adjacent to the anchor sub-square and a reverse extension line of the connection line. Taking the first subregion f0 as an example, adjacent 3 anchor point subregions (i.e., anchor point subregions in f1, f4 and f5 subregions) around the anchor point subregion f0 can be determined first, then the midpoints of the connecting lines of the anchor point subregions of f0 and the adjacent 3 anchor point subregions (three small circles in the upper right corner of f0 shown in fig. 4) are determined first, then each connecting line is reversely prolonged, on the extension line, the anchor point subregions of f0 are taken as the center, the symmetrical points of each midpoint (three small circles in the upper left corner of f0 shown in fig. 4) are determined, and then the points shown by the three small circles in the upper left corner and the three small circles in the lower right corner are sequentially connected, so that the second position information of the subregion f0 is obtained. The second position information of the sub-region at other positions can be obtained by analogy according to the above method, and will not be described herein.
Because the application can determine the second position information of each sub-area based on the first position information of each anchor point sub-square, even if the two-dimensional code image is scanned at different angles, the two-dimensional code image displayed in the acquired image has certain distortion phenomena such as inclination, stretching and the like, each sub-area can be identified (restored) to the greatest extent, so that the anti-distortion capability of the two-dimensional code image can be improved, the two-dimensional code can be ensured to be correctly identified to the greatest extent, and the correct identification rate of the two-dimensional code is improved.
S303: for each sub-area, determining the number of sub-squares contained in the sub-area, and determining third position information of the sub-squares contained in the sub-area.
In one possible embodiment, after the second location information of each sub-area is determined, the number of sub-tiles included in each sub-area may be determined.
In one possible embodiment, in 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 a preset number of sub-squares (third number) included in one sub-region.
In addition, when determining the number of sub-squares included in each sub-area, it is also possible to determine the width of the anchor sub-square in the sub-area and the width of the sub-area first, and then determine the number of sub-squares included in the sub-area based on the ratio of the width of the sub-area to the width of the anchor sub-square in the sub-area. In one possible embodiment, the square of the odd number closest to the ratio may be determined as the number of sub-squares contained in the sub-area. By way of example, if the ratio of the width of a sub-region to the width of an anchor sub-square in that sub-region is 27, the number of sub-squares contained in that sub-region may be determined to be 27 2, 729. As a further example, if the ratio of the width of a sub-region to the width of an anchor sub-square in the sub-region is 27.8, the number of sub-squares contained in the sub-region may also be determined to be 27 2, i.e., 729. As a further example, if the ratio of the width of a sub-region to the width of an anchor sub-square in the sub-region is 26.5, the number of sub-squares contained in the sub-region may also be determined to be 27 2, i.e., 729.
After the number of sub-squares included in each sub-region is determined, third position information of the sub-squares included in each sub-region may be determined based on the number of sub-squares (third number) included in each sub-region. For example, the sub-area may be divided into a third number of uniform sub-tiles on average, thereby determining third location information of the sub-tiles included in each sub-area.
S304: and reading sub-bearing data corresponding to a 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-area, and combining the sub-bearing data corresponding to the sub-square of each bearing data according to the preset combination sequence of the sub-squares in the sub-area to obtain the data carried by the two-dimensional code image.
After determining the third position information of the sub-square in each sub-area, respectively reading 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 according to the third position information.
For example, taking the second color value as the color value of the HSL color space as an example, when the sub-bearer data corresponding to the second color value configured in the sub-square of each third position information in the two-dimensional code image is read, the second color value configured in the sub-square of each third position information may be determined first for the sub-square of each third position information; and then, according to the corresponding relation between the predetermined binary data and the color value of the HSL color space, determining binary data (called target binary data for convenience of description) corresponding to the second color value, and taking the target binary data as sub-bearing data corresponding to the second color value configured in the sub-square of the third position information.
After the sub-bearing data corresponding to each sub-square is determined, the sub-bearing data corresponding to each sub-square bearing the data can be combined according to the preset sub-square combination sequence in the sub-square to obtain the data carried by the two-dimensional code image. For each sub-area, the sub-bearer data corresponding to the sub-square of each bearer data contained in the sub-area may be combined according to the sequence of the sub-square from top to bottom and from left to right, so as to obtain the bearer data in the sub-area; and then combining the bearing data in each subarea according to the sequence from top to bottom and from left to right of the subareas, so as to obtain the data carried by the two-dimensional code image, and storing the data.
The application can determine the second position information of each sub-area based on the first position information of each anchor sub-square, and further determine the third position information of the sub-square contained in each sub-area, so that even if the two-dimensional code image is scanned at different angles, the two-dimensional code image displayed in the acquired image has certain distortion phenomena such as inclination, stretching and the like, the sub-square contained in each sub-area and each sub-area can be identified (restored) to the greatest extent, the anti-distortion capability of the two-dimensional code image can be improved, the two-dimensional code can be accurately identified to the greatest extent, and the correct identification rate of the two-dimensional code can be improved.
In one possible implementation manner, in order to improve efficiency of determining the anchor sub-square, for each two-dimensional code image, first location information of each anchor sub-square of the edge where the two-dimensional code image is located may be determined based on a preset third color value of the anchor sub-square of the edge where the two-dimensional code image is located. And then determining the edge area of the two-dimensional code image based on the first position information of each anchor sub-square positioned at the edge. After determining the edge area of the two-dimensional code image, determining the first position information of each anchor sub-square located in the inner area of the two-dimensional code image based on a preset first color value in the inner area of the two-dimensional code image.
According to the method and the device, the edge area of the two-dimensional code image can be determined based on the third color value, and then each anchor point sub-square in the inner area of the two-dimensional code image is determined based on the edge area, so that each anchor point sub-square contained in the two-dimensional code image can be determined rapidly and accurately.
In a possible implementation manner, when decoding a two-dimensional code image, if the color value of any anchor sub-square in the two-dimensional code image is identified to be a preset fourth color value, the sub-area to which the anchor sub-square belongs can be determined to be a first sub-area, and the sub-bearing data corresponding to the sub-square of each bearing data can be quickly and accurately combined according to the combination sequence of the sub-squares in the preset sub-area from the sub-area (first sub-area) to which the anchor sub-square belongs, so that the data carried by the two-dimensional code image can be obtained (restored).
In a possible implementation manner, considering that the electronic device may not only include a two-dimensional code image (two-dimensional code) but also include, for example, an irrelevant image around the two-dimensional code in the acquisition area when identifying the two-dimensional code image, in order to improve the efficiency of determining the anchor sub-square, an area or a rough area (for convenience of description, collectively referred to as an area where the two-dimensional code is located) where the two-dimensional code image (two-dimensional code) is located in the image displayed in the acquisition area may be determined before determining the position of the anchor sub-square, and then, when determining the anchor sub-square based on the area where the two-dimensional code is located, the efficiency of determining the anchor sub-square may be improved compared with when determining the anchor sub-square based on the whole image displayed in the acquisition area.
In one possible implementation manner, when determining the area where the two-dimensional code is located, for each two-dimensional code image, at least one sub-image may be selected according to a set pixel point interval from the image displayed in the acquisition area. The pixel point interval and the size of the sub-image can be flexibly set according to requirements, and the application is not particularly limited. For example, sub-images of a set size, etc. may be selected at upper, middle, lower, etc. portions of an image displayed in the acquisition region, respectively.
For each sub-image selected, the color values of the pixel values in that sub-image may be counted. In one possible embodiment, for each sub-image, the number of pixels in the sub-image whose color value is higher than the median value of the set reference color (referred to as the fourth number for convenience of description) and the number of pixels in the sub-image whose color value is lower than the median value of the set reference color (referred to as the fifth number for convenience of description) may be separately determined. For convenience of description, taking an example in which the lower limit value of the H value in the reference color is 0, the upper limit value of the H value in the reference color is 1, and the median value of the H value in the reference color is 0.5, the fourth number of pixel points in which the H value of the color value of the pixel value in the sub-image is higher than 0.5, and the fifth number of pixel points in which the H value of the color value of the pixel value in the sub-image is lower than 0.5 may be determined, respectively.
It is considered that when the sub-image is a sub-image located in the two-dimensional code, the number of pixel points in which the color value of the pixel value is higher than the median value of the reference color and lower than the median value of the reference color is generally substantially the same, that is, the fourth number and the fifth number are generally substantially the same. And when the sub-image is not a sub-image located in the two-dimensional code, the color values of the pixel values in the sub-image are larger in number of pixels higher than the median value of the reference color and lower than the median value of the reference color, that is, the fourth number and the fifth number are larger in number. In order to quickly determine whether the sub-image is a sub-image located in the two-dimensional code, whether the ratio of the fourth number to the fifth number is located in a set ratio range or not may be determined, and if the ratio of the fourth number to the fifth number is located in the set ratio range, the sub-image may be considered as a sub-image located in the two-dimensional code. The ratio range can be flexibly set according to the requirement, the application is not particularly limited to the range, and the ratio range is 0.9-1.1 and the like by way of example.
In a possible implementation manner, when a certain sub-image is determined to be a sub-image located in the two-dimensional code, the first position information of the anchor sub-square included in the sub-image is first identified based on a first color value configured in a preset anchor sub-square, and then the first position information of each anchor sub-square included in the two-dimensional code image is quickly and accurately identified based on a preset interval between the anchor sub-squares and the first color value.
In one possible embodiment, considering that if the first number is not less than 2, it is generally necessary to output (display) the data of the plurality of two-dimensional code images in a unified manner after each two-dimensional code image is decoded (for convenience of description, referred to as finish decoding), in order to know whether decoding is finished, in one possible embodiment, when the color value of the anchor sub-square of the sub-area is set to be the set fifth color value in the two-dimensional code image, for each two-dimensional code image, the two-dimensional code image may be taken as the first two-dimensional code image (the first-ranked two-dimensional code image in the first order, for convenience of description) of the plurality of two-dimensional code images bearing data to be transmitted. In one possible implementation manner, since the color value of the anchor point sub-square of the setting sub-area of the first two-dimensional code image is different from the color values of the anchor point sub-square of the setting sub-area of the other two-dimensional code images, when a plurality of two-dimensional code images are circularly played according to a certain sequence and a set frequency, when the plurality of two-dimensional code images are decoded, when the two-dimensional code image to be decoded is identified as the first two-dimensional code image, whether the data carried by the first two-dimensional code image is obtained (acquired) can be further judged based on the two-dimensional code decoding instruction. If the two-dimensional code decoding instruction is not based, the data carried by the first two-dimensional code image is obtained, the first two-dimensional code image can be recognized for the first time, the two-dimensional code image can be decoded, and the data carried by the two-dimensional code image can be obtained.
If the data carried by the first two-dimensional code image is obtained (acquired) based on the two-dimensional code decoding instruction, the first two-dimensional code image can be considered to be recognized for the second time, the decoding process of each two-dimensional code image can be considered to be completed, namely, the decoding process is completed, the data carried by each two-dimensional code image obtained based on the two-dimensional code decoding instruction which is currently stored can be fused, and the data of each two-dimensional code image which is acquired can be sequentially fused from the data of the first two-dimensional code image, so that the data which is the same as the data to be transmitted in the embodiment is obtained (restored), and the decoding process is finished.
In a possible implementation manner, if it is identified that the color value of the anchor sub-square of the sub-area is set to be the set sixth color value in a certain two-dimensional code image, the two-dimensional code image is considered to be the last two-dimensional code image in the plurality of two-dimensional code images bearing the data to be transmitted, after the two-dimensional code is decoded, the data carried by each two-dimensional code image obtained based on the currently stored two-dimensional code decoding instruction may be fused, and for example, the data carried by each two-dimensional code image obtained based on the currently stored two-dimensional code decoding instruction may be sequentially fused in the order from the data of the first two-dimensional code image to the data of the last two-dimensional code image, so as to obtain (restore) the data identical to the data to be transmitted in the above embodiment, and end the decoding process.
In a possible implementation manner, considering that when decoding the first two-dimensional code image, the first position information of each anchor sub-square included in the first two-dimensional code image is already obtained, and in general, when analyzing a plurality of two-dimensional code images based on the same decoding instruction, the plurality of two-dimensional code images are used as a group of two-dimensional code images corresponding to the same data to be transmitted, the difference between the position information of the anchor sub-square included in each two-dimensional code image is not large, if each two-dimensional code image re-head identifies the position information of the anchor sub-square, more time may be consumed, in order to improve the two-dimensional code identification efficiency, for each two-dimensional code image, if knowing that the data carried by other two-dimensional code images are obtained based on the two-dimensional code decoding instruction before the two-dimensional code image, the currently decoded two-dimensional code image is not the first two-dimensional code image (the first two-dimensional code image), and the determined position information of each anchor sub-square included in other two-dimensional code images located before the two-dimensional code image in the first order can be determined based on the first color value of the anchor sub-square configured in the preset anchor sub-square. For example, the first position information of each anchor sub-square included in the two-dimensional code image may be determined based on the first position information of each anchor sub-square included in the last adjacent two-dimensional code image ranked before the two-dimensional code image in the first ranking.
The method and the device can determine the position information of each anchor sub-square contained in the two-dimensional code image based on the position information of the anchor sub-square of other two-dimensional code images positioned in front of the two-dimensional code image in the first order, so that the two-dimensional code identification efficiency can be improved.
In one possible implementation manner, in order to improve the correct recognition rate of the two-dimensional code and the reliability of the two-dimensional code, in the embodiments of the present application, after determining the second color value configured in the sub-square of the third position information, according to the corresponding relationship 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 may be further corrected, in consideration of that when the two-dimensional code image is recognized, a certain error exists in the second color value due to a certain offset in the color transfer process, and so on. Exemplary, the embodiments of the present application provide the following three correction methods for the second color value.
The first correction mode for the second color value is as follows:
For each two-dimensional code image, if the two-dimensional code image is identified to contain 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 an actual color lower limit value) and the highest value (for convenience of description, referred to as an actual color upper limit value) in the second color value of the sub-square configuration of each third position information in each sub-area in the two-dimensional code image can be determined. And then 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 to determine the color value deviation correcting coefficient of the sub-area. Taking the S value as an example, if the reference color upper limit value of the S value is 1, the reference color lower limit value is 0.55, and the actual color upper limit value of the S value of a certain sub-region is 0.8, and the actual color lower limit value is 0.44, the identified second color value may be considered to be 80% of the ideal second color value, and the color value deviation correction coefficient may be determined as an inverse of 80%, that is, 1.25, for example.
After determining the color value correction coefficient, the second color value of each determined sub-square of the third position information of the sub-area may be corrected based on the color value correction coefficient. For example, the product of the second color value of each sub-square at the third position in the identified sub-area and the color value deviation correcting coefficient may be determined as a corrected second color value, and the target binary data corresponding to the corrected second color value may be determined according to the corresponding relationship between the predetermined binary data and the color value of the HSL color space.
The second correction mode for the second color value is as follows:
For each two-dimensional code image, if the two-dimensional code image is identified to contain 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) in the second color values of all the sub-squares in the two-dimensional code image can be determined. And then 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 to determine the color value deviation correcting coefficient of the two-dimensional code image. The process of determining the color value correction coefficient is the same as that of the foregoing embodiment, and will not be described herein.
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. For example, the product of the second color value of the identified sub-square of the two-dimensional code image and the color value correction coefficient may be determined as a corrected second color value, and the target binary data corresponding to the corrected second color value may be determined according to the corresponding relationship between the predetermined binary data and the color value of the HSL color space.
The third correction mode for the second color value is as follows:
For each two-dimensional code image, if each sub-area of the two-dimensional code image is identified to contain a first reference color sub-square and a second reference color sub-square, the lowest value (called an actual color lower limit value for convenience of description) and the highest value (called an actual color upper limit value for convenience of description) in the second color value of the sub-square configuration of each third position information in the sub-area can be determined for each sub-area of the two-dimensional code image. And then comparing the actual color upper limit value with the reference color upper limit value configured in the second reference color sub-square in the subarea, 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 subarea, so as to determine the color value deviation correcting coefficient of the subarea.
After determining the color value correction coefficient, the second color value of each determined sub-square of the third position information of the sub-area may be corrected based on the color value correction coefficient. For example, the product of the second color value of each sub-square at the third position in the identified sub-area and the color value deviation correcting coefficient may be determined as a corrected second color value, and the target binary data corresponding to the corrected second color value may be determined according to the corresponding relationship between the predetermined binary data and the color value of the HSL color space.
Based on the same technical concept, the application provides a two-dimensional code encoding device, and fig. 5 shows a schematic diagram of the two-dimensional code encoding device provided by some embodiments, as shown in fig. 5, the device includes:
The first determining module 51 is configured to obtain data to be transmitted and a data amount of the data to be transmitted, where the data to be transmitted is carried in a two-dimensional code encoding instruction if the two-dimensional code encoding instruction is received; determining a first number of two-dimensional code templates required for transmitting the data to be transmitted according to the data quantity and a predetermined data bearing capacity of one two-dimensional code template; each two-dimensional code template comprises a preset second number of subareas, each subarea comprises a preset third number of subareas, and for each subarea, the subareas at the preset position in the subarea are configured as anchor subareas, and the anchor subareas are configured as set first color values;
The second determining module 52 is configured to determine, according to the first number and the data to be transmitted, sub-data to be transmitted corresponding to each two-dimensional code template to be encoded;
The configuration module 53 is configured to determine, for each two-dimensional code template, sub-bearing data corresponding to each sub-square carrying data in the two-dimensional code template according to sub-data to be transmitted corresponding to the two-dimensional code template and an ordering sequence of each sub-square in the two-dimensional code template; and configuring each sub-square carrying data into a second color value corresponding to the corresponding sub-carrying data.
In one possible implementation manner, the anchor sub-square in the sub-area located at the edge in each two-dimensional code template is configured to be a preset third color value.
In one possible embodiment, the apparatus further comprises:
The adjustment module is used for sequencing each two-dimensional code template according to the sub-data to be transmitted corresponding to each two-dimensional code template if the first number is not less than 2; and aiming at each two-dimensional code template, if the anchor sub-square in the sub-area positioned at the edge in the front and back two other two-dimensional code templates adjacent to the two-dimensional code template is configured to be a preset third color value, adjusting the color value of the anchor sub-square in the sub-area positioned at the edge in the two-dimensional code template to be a non-third color value.
In one possible implementation manner, for each two-dimensional code template, in the ordering order of each sub-region in the two-dimensional code template, the first color value of the anchor sub-square in the first-ranked sub-region is configured to be a preset fourth color value.
In a possible implementation manner, the adjusting module is further configured to adjust, for a two-dimensional code template ranked first in the ranking, a first color value of an anchor sub-square of a set sub-area in the two-dimensional code template to a set fifth color value.
In a possible implementation manner, the adjusting module is further configured to adjust, for a two-dimensional code template ranked last in the ranking, a first color value of an anchor sub-square of a set sub-area in the two-dimensional code template to a set sixth color value.
In a possible implementation manner, the configuration module is specifically configured to determine, for each sub-square carrying data, target binary data corresponding to sub-carrying data corresponding to the sub-square carrying data; determining a second color value corresponding to the target binary data according to the corresponding relation between the predetermined binary data and the color values of hue, saturation and brightness HSL color space; and configuring the data-bearing sub-square as the second color value.
In one possible implementation manner, for each two-dimensional code template, the two-dimensional code template includes at least one first reference color sub-square and at least one second reference color sub-square, wherein a set reference color lower limit value is configured in the first reference color sub-square; the second reference color sub-square is provided with a set reference color upper limit value.
Based on the same technical concept, the application provides a two-dimensional code encoding device, fig. 6 shows a schematic diagram of a two-dimensional code decoding device provided by some embodiments, and as shown in fig. 6, the device includes:
The identifying module 61 is configured to, if a two-dimensional code decoding instruction is received, identify first location information of each anchor sub-square included in at least one two-dimensional code image based on a first color value configured in a preset anchor sub-square;
The third determining module 62 is configured to determine, for each two-dimensional code image, second location information of a sub-area to which each anchor sub-square belongs, based on the first location information of each anchor sub-square included in the two-dimensional code image;
A fourth determining module 63, configured to determine, for each of the sub-areas, a number of sub-squares included in the sub-area, and determine third location information of the sub-squares included in the sub-area;
The reading module 64 is configured to read sub-bearer data corresponding to a second color value configured in each sub-square of the third location information in the two-dimensional code image according to the third location information of the sub-square in each sub-area, combine the sub-bearer data corresponding to the sub-square of each bearer data according to a preset combination sequence of the sub-squares in the sub-area, obtain data carried by the two-dimensional code image, and store the data.
In a possible implementation manner, the identifying module 61 is specifically configured to determine, for each two-dimensional code image, first location information of each anchor sub-square of the edge where the two-dimensional code image is located, based on a preset third color value of the anchor sub-square of the sub-area of the edge where the two-dimensional code image is located;
Determining an edge area of the two-dimensional code image based on first position information of each anchor sub-square positioned at the edge; and determining first position information of each anchor sub-square positioned in the inner area based on the first color value in the inner area of the two-dimensional code image.
In a possible implementation manner, the reading module 64 is specifically configured to, if it is identified that the color value of any anchor sub-square is a preset fourth color value, start from a sub-area to which the anchor sub-square belongs, and combine sub-bearer data corresponding to each sub-square carrying data according to a combination sequence of sub-squares in the preset sub-area to obtain data carried by the two-dimensional code image.
In a possible implementation manner, the identifying module 61 is further configured to select, for each two-dimensional code image, at least one sub-image according to a set pixel interval, an image displayed in an acquisition area when the two-dimensional code image is identified; and determining whether the ratio of the fourth number to the fifth number is within a set ratio range or not according to the fourth number of pixel points with the pixel value higher than the median value of the set reference color and the fifth number of pixel points with the pixel value lower than the median value of the set reference color in each sub-image, if so, determining the sub-image as the sub-image positioned in the two-dimensional code image, and performing the step of respectively identifying the first position information of each anchor sub-square included in at least one two-dimensional code image based on the first color value configured in the preset anchor sub-square based on the position information of the sub-image.
In one possible embodiment, the apparatus further comprises:
The fusion module is used for judging whether the data carried by the first two-dimensional code image corresponding to the fifth color value is obtained based on the two-dimensional code decoding instruction or not by taking the two-dimensional code image as the first two-dimensional code image in a plurality of two-dimensional code images bearing data to be transmitted if the color value of the anchor point sub square of the sub area is set to be the set fifth color value in the two-dimensional code image, if so, fusing the data carried by each currently stored two-dimensional code image obtained based on the two-dimensional code decoding instruction, and ending the decoding process.
In one possible implementation manner, the fusion module is further configured to, if it is identified that the color value of the anchor sub-square of the sub-region in the two-dimensional code image is set to be the set sixth color value, take the two-dimensional code image as the last two-dimensional code image in the plurality of two-dimensional code images bearing data to be transmitted, fuse the currently stored data carried by each two-dimensional code image obtained based on the two-dimensional code decoding instruction, and end the decoding process.
In a possible implementation manner, the identification module 61 is specifically configured to determine, for each two-dimensional code image, based on a first color value configured in a preset anchor sub-square and first location information of each anchor sub-square included in the other two-dimensional code image, if data carried by other two-dimensional code images have been obtained based on the two-dimensional code decoding instruction before the two-dimensional code image.
In a possible implementation manner, the reading module 64 is specifically configured to determine, for each sub-square of the third location information, a second color value configured in the sub-square of the third location information; determining target binary data corresponding to the second color value according to the corresponding relation between the predetermined binary data and the color values of hue, saturation and brightness HSL color space; and taking the target binary data as sub-bearing data corresponding to the second color value configured in the sub-square of the third position information.
In a possible implementation manner, the reading module 64 is further configured to determine, for each sub-area 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 by the sub-square of each third location information in the sub-area if the two-dimensional code image is identified to include the set first reference color sub-square and the set second reference color sub-square;
determining a color value deviation correction coefficient of the subarea by comparing the actual color upper limit value with a reference color upper limit value configured in the second reference color sub-square and comparing the actual color lower limit value with a reference color lower limit value configured in the first reference color sub-square;
Correcting the second color value of the sub-square configuration of each third position information of the subarea based on the color value correction coefficient, and carrying out subsequent steps according to the corresponding relation between the predetermined binary data and the color value of the hue, saturation and brightness HSL color space based on the corrected second color value, so as to determine the target binary data corresponding to the second color value.
Based on the same technical concept, the present application further provides an electronic device, fig. 7 shows a schematic structural diagram of an electronic device provided by some embodiments, and as shown in fig. 7, the electronic device includes: the processor 71, the communication interface 72, the memory 73 and the communication bus 74, wherein the processor 71, the communication interface 72 and the memory 73 complete communication with each other through the communication bus 74;
The memory 73 stores a computer program which, when executed by the processor 71, causes the processor 71 to execute the computer program stored in the memory to implement the steps of the two-dimensional code encoding method as described above, or to implement the steps of the two-dimensional code decoding method as described above.
Because the principle of solving the problem of the electronic device is similar to that of the two-dimensional code encoding method and the two-dimensional code decoding method, the implementation of the electronic device can be referred to the implementation of the method, and the repetition is omitted.
The communication bus mentioned above for the electronic device may be a peripheral component interconnect standard (PERIPHERAL COMPONENT INTERCONNECT, PCI) bus or an extended industry standard architecture (Extended Industry Standard Architecture, EISA) bus, etc. The communication bus may be classified as an address bus, a data bus, a control bus, or the like. For ease of illustration, the figures are shown with only one bold line, but not with only one bus or one type of bus.
The communication interface 72 is used for communication between the above-described electronic device and other devices.
The Memory may include random access Memory (Random Access Memory, RAM) or may include Non-Volatile Memory (NVM), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the aforementioned processor.
The processor may be a general-purpose processor, including a central processing unit, a network processor (Network Processor, NP), etc.; but also digital instruction processors (DIGITAL SIGNAL Processing units, DSPs), application specific integrated circuits, field programmable gate arrays or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
Based on the same technical concept, the embodiments of the present application provide a computer readable storage medium, in which a computer program executable by an electronic device is stored, which when executed on the electronic device, causes the electronic device to implement the steps of any one of the two-dimensional code encoding methods described above, or implement the steps of any one of the two-dimensional code decoding methods described above.
Because the principle of solving the problem by the 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 computer readable storage medium can be referred to the implementation of the method, and the repetition is omitted.
The computer readable storage medium may be any available medium or data storage device that can be accessed by a processor in an electronic device, including but not limited to magnetic memories such as floppy disks, hard disks, magnetic tapes, magneto-optical disks (MO), etc., optical memories such as CD, DVD, BD, HVD, etc., and semiconductor memories such as ROM, EPROM, EEPROM, nonvolatile memories (NAND FLASH), solid State Disks (SSD), etc.
Based on the same technical idea, the present application provides a computer program product comprising: and the computer program code, when running on the computer, causes the computer to implement the two-dimensional code encoding method and the two-dimensional code decoding method which are applied to any method embodiment of the electronic equipment when being executed by the computer.
In the above embodiments, it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof, and may be implemented in whole or in part in the form of a computer program product. The computer program product comprises one or more computer instructions which, when loaded and executed on a computer, produce, in whole or in part, a process or function in accordance with embodiments of the present application.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
It will be apparent to those skilled in the art that various modifications and variations can be made to the present application without departing from the spirit or scope of the application. Thus, it is intended that the present application also include such modifications and alterations insofar as they come within the scope of the appended claims or the equivalents thereof.

Claims (20)

1. The two-dimensional code encoding method is characterized by comprising the following steps of:
If a two-dimensional code coding instruction is received, acquiring data to be transmitted and the data quantity of the data to be transmitted, which are carried in the coding instruction; determining a first number of two-dimensional code templates required for transmitting the data to be transmitted according to the data quantity and a predetermined data bearing capacity of one two-dimensional code template; each two-dimensional code template comprises a preset second number of subareas, each subarea comprises a preset third number of subareas, and for each subarea, the subareas at the preset position in the subarea are configured as anchor subareas, and the anchor subareas are configured as set first color values;
determining 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;
Aiming at each two-dimensional code template, determining sub-bearing data corresponding to each sub-square of bearing data in the two-dimensional code template according to sub-data to be transmitted corresponding to the two-dimensional code template and the ordering sequence of each sub-square in the two-dimensional code template; configuring each sub-square carrying data into a second color value corresponding to the corresponding sub-carrying data;
and the anchor point sub-square in the sub-area positioned at the edge in each two-dimensional code template is configured to be a preset third color value.
2. The method according to claim 1, wherein the method further comprises:
If the first number is not less than 2, sequencing each two-dimensional code template according to the sub-data to be transmitted corresponding to each two-dimensional code template;
And aiming at each two-dimensional code template, if the anchor sub-square in the sub-area positioned at the edge in the front and back two other two-dimensional code templates adjacent to the two-dimensional code template is configured to be a preset third color value, adjusting the color value of the anchor sub-square in the sub-area positioned at the edge in the two-dimensional code template to be a non-third color value.
3. The method according to any one of claims 1-2, wherein for each two-dimensional code template, in the order of ordering of each sub-region in the two-dimensional code template, the first color value of the anchor sub-square in the first-ranked sub-region is configured to be a preset fourth color value.
4. The method according to claim 2, wherein the method further comprises:
And aiming at the first two-dimensional code template in the ranking, adjusting the first color value of the anchor sub-square of the set subarea in the two-dimensional code template to be a set fifth color value.
5. The method according to claim 2, wherein the method further comprises:
and aiming at the two-dimensional code template ranked at the last in the ranking, adjusting the first color value of the anchor point sub-square of the set subarea in the two-dimensional code template to be the set sixth color value.
6. The method of claim 1, wherein configuring each data-bearing sub-square to a second color value corresponding to the respective corresponding sub-bearing data comprises:
Determining target binary data corresponding to sub-bearing data corresponding to the sub-square of the bearing data aiming at the sub-square of each bearing data; determining a second color value corresponding to the target binary data according to the corresponding relation between the predetermined binary data and the color values of hue, saturation and brightness HSL color space; and configuring the data-bearing sub-square as the second color value.
7. The method according to claim 1 or 6, wherein for each two-dimensional code template, the two-dimensional code template includes at least one first reference color sub-square and at least one second reference color sub-square, wherein a set reference color lower limit value is configured in the first reference color sub-square; the second reference color sub-square is provided with a set reference color upper limit value.
8. The two-dimensional code decoding method is characterized by comprising the following steps of:
If a two-dimensional code decoding instruction is received, respectively identifying first position information of each anchor sub-square contained in at least one two-dimensional code image based on a first color value configured in a preset anchor sub-square;
determining second position information of a subarea to which each anchor sub-square belongs based on the first position information of each anchor sub-square contained in each two-dimensional code image;
Determining the number of sub-squares contained in each sub-area according to each sub-area, and determining third position information of the sub-squares contained in the sub-area;
And reading sub-bearing data corresponding to a 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-area, combining the sub-bearing data corresponding to the sub-square of each bearing data according to the preset combination sequence of the sub-squares in the sub-area to obtain the data carried by the two-dimensional code image, and storing the data.
9. The method of claim 8, wherein the identifying the first location information of each anchor sub-square included in the at least one two-dimensional code image based on the first color value configured in the preset anchor sub-square includes:
Determining first position information of each anchor sub-square of the two-dimensional code image positioned on the edge based on a preset third color value of the anchor sub-square of the two-dimensional code image positioned in a sub-area of the edge;
Determining an edge area of the two-dimensional code image based on first position information of each anchor sub-square positioned at the edge; and determining first position information of each anchor sub-square positioned in the inner area based on the first color value in the inner area of the two-dimensional code image.
10. The method of claim 8, wherein the combining the sub-bearer data corresponding to each sub-square carrying data according to the combination sequence of sub-squares in the preset sub-area to obtain the data carried by the two-dimensional code image includes:
If the color value of any anchor sub-square is identified to be a preset fourth color value, starting from the sub-area to which the anchor sub-square belongs, and combining sub-bearing data corresponding to each sub-square bearing data according to the combination sequence of the sub-squares in the preset sub-area to obtain the data carried by the two-dimensional code image.
11. The method of claim 8, wherein after receiving the two-dimensional code decoding instruction, before the identifying the first location information of each anchor sub-square included in the at least one two-dimensional code image based on the first color value configured in the preset anchor sub-square, the method further comprises:
for each two-dimensional code image, selecting at least one sub-image according to a set pixel point interval from the image displayed in the acquisition area when the two-dimensional code image is identified; and respectively determining a fourth number of pixel points with the pixel value higher than the median value of the set reference color and a fifth number of pixel points with the pixel value lower than the median value of the set reference color for each sub-image, judging whether the ratio of the fourth number to the fifth number is in a set ratio range, if so, determining the sub-image as the sub-image in the two-dimensional code image, and carrying out subsequent steps based on the position information of the sub-image.
12. The method according to claim 8, wherein after identifying the first position information of each anchor sub-square included in the at least one two-dimensional code image based on the first color value configured in the preset anchor sub-square, the method further includes, for each two-dimensional code image, before determining the second position information of the sub-area to which each anchor sub-square belongs based on the first position information of each anchor sub-square included in the two-dimensional code image:
And aiming at each two-dimensional code image, if the color value of the anchor point sub square of the sub area in the two-dimensional code image is set to be the set fifth color value, taking the two-dimensional code image as the first two-dimensional code image in a plurality of two-dimensional code images bearing data to be transmitted, judging whether the data carried by the first two-dimensional code image corresponding to the fifth color value is obtained based on the two-dimensional code decoding instruction, if so, fusing the data carried by each currently stored two-dimensional code image obtained based on the two-dimensional code decoding instruction, and ending the decoding process.
13. The method of claim 8, wherein the method further comprises:
if the color value of the anchor point sub square of the sub area is set to be the set sixth color value in the two-dimensional code image, the two-dimensional code image is taken as the last two-dimensional code image in a plurality of two-dimensional code images bearing data to be transmitted, the currently stored data carried by each two-dimensional code image obtained based on the two-dimensional code decoding instruction are fused, and the decoding process is ended.
14. The method of claim 8, wherein the identifying the first location information of each anchor sub-square included in the at least one two-dimensional code image based on the first color value configured in the preset anchor sub-square includes:
For each two-dimensional code image, if data carried by other two-dimensional code images are obtained based on the two-dimensional code decoding instruction before the two-dimensional code image, determining the first position information of each anchor sub-square contained in the two-dimensional code image based on a first color value configured in a preset anchor sub-square and the first position information of each anchor sub-square contained in the other two-dimensional code image.
15. The method of claim 8, wherein the reading the sub-bearer data corresponding to the second color value configured in the sub-square of each of the third location information in the two-dimensional code image includes:
Determining a second color value configured in each sub-square of the third position information aiming at the sub-square of each third position information; determining target binary data corresponding to the second color value according to the corresponding relation between the predetermined binary data and the color values of hue, saturation and brightness HSL color space; and taking the target binary data as sub-bearing data corresponding to the second color value configured in the sub-square of the third position information.
16. The method according to claim 15, wherein after determining the second color value configured in the sub-square of the third location information, 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, brightness HSL color space, the method further comprises:
If the two-dimensional code image is identified to contain the set first reference color sub-square and the set second reference color sub-square, determining an actual color lower limit value and an actual color upper limit value of a second color value configured by the sub-square of each third position information in each sub-area of the two-dimensional code image;
determining a color value deviation correction coefficient of the subarea by comparing the actual color upper limit value with a reference color upper limit value configured in the second reference color sub-square and comparing the actual color lower limit value with a reference color lower limit value configured in the first reference color sub-square;
And correcting the second color value of the determined sub-grid configuration of each third position information of the sub-region based on the color value correction coefficient, and performing subsequent steps based on the corrected second color value.
17. A two-dimensional code encoding device, the device comprising:
The first determining module is used for acquiring data to be transmitted and the data quantity of the data to be transmitted, which are carried in the encoding instruction, if the two-dimensional code encoding instruction is received; determining a first number of two-dimensional code templates required for transmitting the data to be transmitted according to the data quantity and a predetermined data bearing capacity of one two-dimensional code template; each two-dimensional code template comprises a preset second number of subareas, each subarea comprises a preset third number of subareas, and for each subarea, the subareas at the preset position in the subarea are configured as anchor subareas, and the anchor subareas are configured as set first color values;
the second determining module is used for determining 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;
The configuration module is used for determining 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 ordering sequence of each sub-square in the two-dimensional code template; configuring each sub-square carrying data into a second color value corresponding to the corresponding sub-carrying data;
the anchor point sub-grids in the sub-regions located at the edges in each two-dimensional code template are configured to be preset third color values.
18. A two-dimensional code decoding device, the device comprising:
The identification module is used for respectively identifying the first position information of each anchor sub-square contained in at least one two-dimensional code image based on a first color value configured in a preset anchor sub-square if a two-dimensional code decoding instruction is received;
the third determining module is used for determining second position information of a subarea to which each anchor sub-square belongs according to the first position information of each anchor sub-square contained in each two-dimensional code image;
A fourth determining module, configured to determine, for each sub-area, a number of sub-squares included in the sub-area, and determine third location information of the sub-squares included in the sub-area;
The reading module is used for reading 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-area, combining the sub-bearing data corresponding to the sub-square of each bearing data according to the preset combination sequence of the sub-squares in the sub-area to obtain the data carried by the two-dimensional code image, and storing the data.
19. An electronic device, characterized in that the electronic device comprises at least a processor and a memory, the processor being configured to implement the steps of a two-dimensional code encoding method according to any one of claims 1-7 or to implement the steps of a two-dimensional code decoding method according to any one of claims 8-16 when executing a computer program stored in the memory.
20. A computer-readable storage medium, characterized in that it stores a computer program which, when executed by a processor, implements the steps of a two-dimensional code encoding method according to any one of claims 1 to 7, or implements the steps of a two-dimensional code decoding method according to any one of claims 8 to 16.
CN202111639976.XA 2021-12-29 2021-12-29 Two-dimensional code encoding and decoding method, device, equipment and medium Active CN114399010B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111639976.XA CN114399010B (en) 2021-12-29 2021-12-29 Two-dimensional code encoding and decoding method, device, equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111639976.XA CN114399010B (en) 2021-12-29 2021-12-29 Two-dimensional code encoding and decoding method, device, equipment and medium

Publications (2)

Publication Number Publication Date
CN114399010A CN114399010A (en) 2022-04-26
CN114399010B true CN114399010B (en) 2024-08-27

Family

ID=81229481

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111639976.XA Active CN114399010B (en) 2021-12-29 2021-12-29 Two-dimensional code encoding and decoding method, device, equipment and medium

Country Status (1)

Country Link
CN (1) CN114399010B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114998454B (en) * 2022-05-09 2023-05-16 西南交通大学 Dynamic multi-color code generation and analysis method

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2016201061A (en) * 2015-04-14 2016-12-01 株式会社テララコード研究所 Two-dimensional code, and reading method for two-dimensional code
CN112070195A (en) * 2020-09-22 2020-12-11 澳新银行营运服务(成都)有限公司 Two-dimensional code identification and generation method and device, electronic equipment and storage medium

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101052403B1 (en) * 2004-03-15 2011-07-28 셴젠 시스칸 테크놀러지 코오퍼레이션 리미티드 2D barcodes and their coding / decoding methods
JP5895511B2 (en) * 2011-12-21 2016-03-30 富士ゼロックス株式会社 Two-dimensional code, recording device, identification device and program
CN104463294B (en) * 2013-09-23 2017-12-12 北大方正集团有限公司 Color three dimension code generating method and system, analytic method and system and label
CN104866886B (en) * 2015-06-12 2018-01-12 矽图(厦门)科技有限公司 The generating means of colored high-order latent image code
CN109978111A (en) * 2019-03-13 2019-07-05 杭州百伴生物技术有限公司 Matrix two-dimensional code, its generation, coding/decoding method and its equipment
CN111275152A (en) * 2020-01-16 2020-06-12 北京迈格威科技有限公司 Two-dimensional code, encoding method and decoding method of two-dimensional code, decoding device of two-dimensional code and electronic system

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2016201061A (en) * 2015-04-14 2016-12-01 株式会社テララコード研究所 Two-dimensional code, and reading method for two-dimensional code
CN112070195A (en) * 2020-09-22 2020-12-11 澳新银行营运服务(成都)有限公司 Two-dimensional code identification and generation method and device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN114399010A (en) 2022-04-26

Similar Documents

Publication Publication Date Title
CN110139104B (en) Video decoding method, video decoding device, computer equipment and storage medium
CN114399010B (en) Two-dimensional code encoding and decoding method, device, equipment and medium
CN112800850B (en) Video processing method and device, electronic equipment and storage medium
CN110166850B (en) Method and system for predicting panoramic video watching position by multiple CNN networks
CN110636294A (en) Video decoding method and device, and video encoding method and device
CN110473238A (en) A kind of method for registering images, device, electronic equipment and storage medium
CN107038695A (en) A kind of image interfusion method and mobile device
CN111107361A (en) Video processing apparatus and method for determining motion metadata of encoded video
CN113723457A (en) Image recognition method and device, storage medium and electronic device
CN113301346A (en) Method and device for playing multi-channel video in hybrid mode based on android terminal soft and hard decoding
CN114677394A (en) Matting method, matting device, image pickup apparatus, conference system, electronic apparatus, and medium
CN110519607B (en) Video decoding method and device, and video encoding method and device
CN106028088A (en) Insertion method and device of media data
EP2731342A1 (en) Electronic device and method for splitting image
CN113688832A (en) Model training and image processing method and device
CN111160340B (en) Moving object detection method and device, storage medium and terminal equipment
CN110853056B (en) Method, device, equipment and storage medium for generating image segmentation information
CN113313635A (en) Image processing method, model training method, device and equipment
CN113691811B (en) Coding block dividing method, device, system and storage medium
CN111179158A (en) Image processing method, image processing apparatus, electronic device, and medium
CN110581995A (en) Video processing method and device
CN113542617B (en) Method and device for acquiring code scanning image, code scanning equipment and storage medium
CN105554587B (en) A kind of display control method, device and display device
CN115100417A (en) Image processing method, storage medium, and electronic device
CN105787541A (en) Four-dimensional code encoding method and system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant