CN110414644B - Two-dimensional code, encoding and decoding methods and devices thereof, storage medium and mobile terminal - Google Patents

Two-dimensional code, encoding and decoding methods and devices thereof, storage medium and mobile terminal Download PDF

Info

Publication number
CN110414644B
CN110414644B CN201810395881.XA CN201810395881A CN110414644B CN 110414644 B CN110414644 B CN 110414644B CN 201810395881 A CN201810395881 A CN 201810395881A CN 110414644 B CN110414644 B CN 110414644B
Authority
CN
China
Prior art keywords
bit stream
dimensional code
binary bit
pattern
preset
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
CN201810395881.XA
Other languages
Chinese (zh)
Other versions
CN110414644A (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.)
Wuzhou Online E Commerce Beijing Co ltd
Original Assignee
Alibaba Group Holding 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 Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN201810395881.XA priority Critical patent/CN110414644B/en
Publication of CN110414644A publication Critical patent/CN110414644A/en
Application granted granted Critical
Publication of CN110414644B publication Critical patent/CN110414644B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

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
    • 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

Abstract

The application provides a two-dimensional code encoding method and device, a two-dimensional code decoding method and device, a mobile terminal, a non-transitory computer readable storage medium and a two-dimensional code. The encoding method of the two-dimensional code comprises the following steps: converting data to be encoded into a binary bit stream; inserting a preset initial field in the initial position of the binary bit stream; rendering the binary bit stream into a two-dimensional pattern starting from the start field; and adding a plurality of symmetrical positioning patterns in a preset area of the two-dimensional pattern.

Description

Two-dimensional code, encoding and decoding methods and devices thereof, storage medium and mobile terminal
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a method and an apparatus for encoding a two-dimensional code, a method and an apparatus for decoding a two-dimensional code, a mobile terminal, a non-transitory computer readable storage medium, and a two-dimensional code.
Background
Two-dimensional codes (QR codes), also known as two-dimensional Bar codes, are a popular way of encoding information in recent years, which can record more information than traditional Bar codes (Bar codes), and also can represent more data types.
The two-dimension code is characterized by that it uses a specific geometric figure to record symbol information of data according to black-white alternate graph distributed on plane (two-dimensional direction) according to a certain rule, and utilizes the concept of "0" and "1" bit stream forming internal logic basis of computer on the code preparation, and uses several geometric figures correspondent to binary system to represent literal numerical information, and utilizes image input equipment or photoelectric scanning equipment to automatically read so as to implement automatic information processing. Two-dimensional codes have some commonalities in bar code technology: each code system has a specific character set, and each character occupies a certain width and has a certain checking function.
Fig. 1 illustrates an example of a conventional two-dimensional code. As shown in fig. 1, the two-dimensional code 100 may include a coding region 110 and a positioning point region 120. The encoding area 110 contains data information recorded by a two-dimensional code, and binary 1 s and 0 s are represented by black and white or gray dots and spaces in the area. The anchor point region 120 includes three anchor patterns located at the upper left corner, the lower left corner, and the upper right corner of the two-dimensional code pattern. When the two-dimensional code is identified, the positions of the three positioning patterns can be confirmed, and the whole two-dimensional code area can be positioned. Since it is possible to scan or photograph the two-dimensional code from different angles and directions, each positioning pattern needs to be asymmetric with respect to each other to confirm the correct direction (i.e., up, down, left, right) of the two-dimensional code. Thus, the beauty and coordination of the two-dimensional code can be affected. However, this is unavoidable with such conventional coding.
Disclosure of Invention
The application provides a two-dimensional code encoding method and device, a two-dimensional code decoding method and device, a mobile terminal, a non-transitory computer readable storage medium and a two-dimensional code.
According to a first aspect of the present application, there is provided a method for encoding a two-dimensional code, including: converting data to be encoded into a binary bit stream; inserting a preset initial field in the initial position of the binary bit stream; rendering the binary bit stream into a two-dimensional pattern starting from the start field; and adding a plurality of symmetrical positioning patterns in a preset area of the two-dimensional pattern.
According to one embodiment, the method further comprises: calculating the binary bit stream according to a preset CRC generating polynomial to generate a CRC check code; the generated CRC check code is inserted into the binary bit stream.
According to one embodiment, the method further comprises: calculating the binary bit stream according to a preset RS generating polynomial to generate an RS error correcting code; the generated RS error correction code is inserted into the binary bit stream.
According to one embodiment, the two-dimensional pattern comprises a plurality of circles of closed figures, which are concentric with each other.
According to one embodiment, the two-dimensional pattern includes four circles of closed figures concentric with each other, an outermost circle and an innermost circle of the four circles of closed figures being annular, and a middle two circles of the four circles of closed figures being rounded polygons.
According to one embodiment, the rounded polygon is a rounded hexagon.
According to one embodiment, rendering the binary bitstream into a two-dimensional pattern starting from the start field comprises: rendering a position corresponding to 0 in the binary bit stream as blank; and rendering the position corresponding to 1 in the binary bit stream as a gray point or a line segment.
According to one embodiment, starting from the start field, rendering the binary bit stream into a two-dimensional pattern further comprises: detecting three or more gray points continuously appearing in the rendered two-dimensional pattern; and adjusting part of gray points in the three or more gray points which are detected and continuously appear into gray line segments.
According to one embodiment, the method further comprises: detecting three or more 0 s that occur consecutively in the binary bit stream; inserting a preset escape field before three or more 0 s detected to occur in succession; and (3) performing escape processing on three or more 0 s which are detected and continuously appear.
According to one embodiment, the symmetrical plurality of positioning patterns are four positioning circles distributed symmetrically.
According to one embodiment, the method further comprises: and adding a Krani pattern or a preset picture in the central area surrounded by the closed pattern.
According to one embodiment, the method further comprises: and receiving audio data and taking the audio data as the data to be encoded.
According to a second aspect of the present application, there is provided a decoding method of a two-dimensional code, including: identifying the positions of a plurality of symmetrical positioning patterns in the scanned picture to determine the area where the two-dimensional code pattern is located; acquiring binary bit stream information from the two-dimensional code pattern; searching a preset initial field in the binary bit stream information; and converting the binary bit stream by taking the searched initial field as a starting point of the binary bit stream and a preset rule to obtain decoding information.
According to one embodiment, obtaining binary bit stream information from the two-dimensional code pattern includes: normalizing the area where the determined two-dimensional code pattern is positioned to a preset template according to the symmetrical positioning patterns; and acquiring the binary bit stream information according to the two-dimensional code pattern on the preset template.
According to one embodiment, the method further comprises: and performing CRC check on the binary bit stream according to a preset CRC generating polynomial.
According to one embodiment, the method further comprises: and performing RS error correction on the binary bit stream according to a preset RS generating polynomial.
According to one embodiment, the two-dimensional code pattern includes a plurality of circles of closed figures, which are concentric with each other.
According to one embodiment, the two-dimensional code pattern comprises four circles of closed patterns concentric with each other, the outermost circle and the innermost circle of the four circles of closed patterns are annular, and the middle two circles of the four circles of closed patterns are rounded polygons.
According to one embodiment, the rounded polygon is a rounded hexagon.
According to one embodiment, obtaining binary bit stream information from the two-dimensional code pattern includes: identifying a blank position in the two-dimensional code pattern as 0; and identifying the gray point and the line segment in the two-dimensional code pattern as 1.
According to one embodiment, acquiring binary bit stream information from the two-dimensional code pattern further includes: searching a preset escape field in the binary bit stream information; and performing the reverse sense processing on the fields after the searched escape fields according to the preset escape rules.
According to one embodiment, the symmetrical plurality of positioning patterns are four positioning circles distributed symmetrically.
According to one embodiment, using the searched start field as a starting point of the binary bit stream, and converting the binary bit stream according to a preset rule to obtain decoding information includes: converting the binary bit stream into audio data; and playing the audio data.
According to a third aspect of the present application, there is provided a two-dimensional code encoding apparatus, including: a processor; a memory for storing one or more programs; the one or more programs, when executed by the processor, cause the processor to implement the encoding methods described above.
According to a fourth aspect of the present application, there is provided a decoding apparatus for a two-dimensional code, including: a processor; a memory for storing one or more programs; the one or more programs, when executed by the processor, cause the processor to implement the decoding methods described above.
According to a fifth aspect of the present application, there is provided a method of encoding audio data into a two-dimensional code, comprising: acquiring audio data; converting the audio data into a binary bit stream; calling a preset two-dimensional code coding model; and rendering the binary bit stream into a two-dimensional code pattern according to the called two-dimensional code coding model.
According to one embodiment, acquiring audio data includes: collecting sound information by using a microphone; the sound information is recorded as the audio data.
According to one embodiment, acquiring audio data includes: the audio data is obtained from a server storing the audio data.
According to one embodiment, converting the audio data into a binary bit stream comprises: acquiring image data; and respectively converting and superposing the audio data and the image data to obtain the binary bit stream.
According to one embodiment, acquiring image data includes: collecting the image data by using a camera; or the image data is acquired from a server storing the image data.
According to one embodiment, the method of encoding audio data into a two-dimensional code further includes: and sending the two-dimensional code pattern through a network.
According to one embodiment, the method of encoding audio data into a two-dimensional code further includes: and printing the two-dimensional code pattern on a printed matter.
According to a sixth aspect of the present application, there is provided a method of decoding a two-dimensional code into audio data, comprising: acquiring a two-dimensional code pattern; acquiring binary bit stream information from the two-dimensional code pattern according to a preset two-dimensional code model; the binary bit stream is converted into audio data.
According to one embodiment, acquiring the two-dimensional code pattern includes: and acquiring the two-dimensional code pattern through a camera.
According to one embodiment, acquiring the two-dimensional code pattern includes: and acquiring the two-dimensional code pattern from a server storing the two-dimensional code pattern.
According to one embodiment, the method of decoding a two-dimensional code into audio data further includes: the audio data is played through a speaker or headphones.
According to one embodiment, the method of decoding a two-dimensional code into audio data further includes: and sending the audio data through a network.
According to a seventh aspect of the present application, there is provided a mobile terminal comprising: a processor; a memory for storing one or more programs; the one or more programs, when executed by the processor, cause the processor to implement any of the method of encoding audio data into two-dimensional code and the method of decoding two-dimensional code into audio data as described above.
According to an eighth aspect of the present application, there is provided a non-transitory computer readable storage medium having stored thereon a computer program which, when executed by a processor, causes the processor to implement any one of the encoding method and the decoding method as described above.
According to a ninth aspect of the present application, there is provided a two-dimensional code encoded by the encoding method as described above.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the application. Also, like reference numerals are used to designate like parts throughout the figures. In the drawings:
fig. 1 illustrates an example of a conventional two-dimensional code;
FIG. 2 illustrates an example of a two-dimensional code pattern according to one embodiment of the present application;
FIG. 3 shows a flowchart of a method of encoding a two-dimensional code according to one embodiment of the present application;
fig. 4 shows a flowchart of a method of encoding a two-dimensional code according to another embodiment;
fig. 5 shows a flowchart of a method of encoding a two-dimensional code according to another embodiment;
FIG. 6 illustrates a flow chart for rendering a binary bit stream into a two-dimensional pattern starting from a start field according to one embodiment of the present application;
FIG. 7 shows a flow chart for rendering a binary bit stream into a two-dimensional pattern starting from a start field according to another embodiment;
Fig. 8 shows a flowchart of a method of encoding a two-dimensional code according to another embodiment;
FIG. 9 shows a flowchart of a method of decoding a two-dimensional code according to one embodiment of the present application;
FIG. 10 illustrates a flowchart for obtaining binary bit stream information from a two-dimensional code pattern according to one embodiment of the present application;
FIG. 11 illustrates a flowchart for obtaining binary bit stream information from a two-dimensional code pattern according to another embodiment of the present application;
FIG. 12 illustrates a flowchart for obtaining binary bit stream information from a two-dimensional code pattern according to another embodiment of the present application;
FIG. 13 illustrates a flow chart for converting a binary bit stream with preset rules to obtain decoding information according to one embodiment of the present application;
FIG. 14 illustrates a flowchart of a method of encoding audio data into a two-dimensional code according to one embodiment of the present application;
fig. 15 shows a flowchart of a method of decoding a two-dimensional code into audio data according to one embodiment of the present application.
Detailed Description
Embodiments of the present application are described in detail below with reference to the accompanying drawings. It should be noted that the following description is merely exemplary and is not intended to limit the present application. Furthermore, in the following description, the same reference numerals will be used to designate the same or similar components in different drawings. The various features of the various embodiments described below may be combined with one another to form further embodiments within the scope of the present application.
The application provides a novel two-dimensional code pattern and a coding and decoding method thereof. Fig. 2 illustrates an example of a two-dimensional code pattern according to one embodiment of the present application. As shown in fig. 2, the two-dimensional code pattern 200 may include: a plurality of positioning patterns 210, a coding pattern 220, and a center pattern 230. The plurality of positioning patterns 210 are symmetrically arranged (e.g., 4 uniformly distributed positioning circles), and when the two-dimensional code pattern is scanned or identified, the positions of the plurality of positioning patterns 210 can be confirmed first, so that the area where the entire two-dimensional code pattern 200 is located can be confirmed.
Due to symmetry among the plurality of positioning patterns 210, a correct direction of the two-dimensional code pattern 200 cannot be determined, i.e., a start position of the code cannot be confirmed, only according to the positions of the positioning patterns 210. In this regard, in the encoding pattern 220, a start field is inserted, which is a preset binary field, and in the encoding stage of the two-dimensional code, the start field is inserted into the start position of the binary bit stream to be encoded, and the two-dimensional code is encoded starting from the start field. Then, in the decoding stage of the two-dimensional code, when a preset start field is found in the encoding pattern 220, it is confirmed that the binary bit stream starts from there. Therefore, the initial field is arranged in the coding pattern, so that the two-dimensional code pattern can be positioned by adopting the symmetrical positioning pattern, and the symmetrical positioning pattern has more attractive appearance and coordination.
The encoding pattern 220 may include a plurality of circles of closed figures concentric with each other. For example, as shown in fig. 2, the encoding pattern 220 may include four circles of closed patterns concentric with each other, wherein the outermost circle is annular and the inner three circles are rounded hexagons. It will be appreciated that the number of turns of the closed figure and the shape of the closed figure per turn may be designed according to actual needs. For example, the outermost ring and the innermost ring may be annular, the middle two rings may be rounded hexagons, or other alternative shapes.
In each turn of the pattern 220, one blank position represents one 0 in the binary bit stream, and one gray point and line segment each represent one 1 in the binary bit stream. In the encoding pattern 220, if there are a plurality of gray points that appear consecutively, there is a possibility that the beauty and harmony are affected and it is difficult to correctly recognize even in the case of low resolution. In this regard, according to the present application, some of the plurality of gradation points that continuously appear can be adjusted to line segments. In the decoding stage, since both the point and the line segment represent 1 in binary, the result of decoding is not affected.
In this application, the size of the encoding pattern 220 is not limited, and may be set according to actual needs. If the amount of data required to be recorded by the two-dimensional code is large, the size of the encoding pattern 220 can be appropriately increased, whereas if the amount of data required to be recorded by the two-dimensional code is small, the size of the encoding pattern 220 can be appropriately reduced.
On the other hand, if there are a plurality of spaces continuously occurring in the encoding pattern 220, it may be subjected to an escape process, for example, the positions of the spaces other than the head and the tail may be adjusted to be points or line segments (i.e., 00000 is modified to 01110), and a two-dimensional code segment representing a predetermined escape field is inserted before the head space. In the decoding stage, when the predetermined escape field is identified, it can be known that the subsequent pattern has undergone the above-mentioned escape processing, and then the field following the escape field needs to undergo the escape processing, for example, 1 between two 0's that first appear is modified to 0 (i.e., 01110 is modified to 00000), so that a correct decoding result can be obtained. It will be appreciated that the specific manner of escape processing may be varied (e.g., 00000 may be modified to 01110, or 01010 may be modified), so long as the specific escape processing manner is pre-defined in advance between the encoding side and all possible decoding sides before encoding, encoding and decoding operations may be performed smoothly.
The center pattern 230 is provided in the center region of the two-dimensional code pattern 200. According to the present application, the center pattern 230 may be a clarni pattern. The clani pattern is a pattern of eighteen german physicist enroster-clandeni, which was tested by placing a wider sheet of metal on the violin, uniformly spreading sand on it, and then starting to string the violin with the bow, so that the fine sand was automatically arranged in different beautiful patterns, and the patterns were changed continuously as the tune and frequency of string pull-out were different. This pattern is known as a clarni pattern. In the present application, the central pattern 230 is set as a clarni pattern, which can further increase the integrity, aesthetic, harmony and recognizability of the two-dimensional code pattern, and improve the differentiation.
An encoding method and a decoding method of a two-dimensional code pattern according to the present application will be described in detail below with reference to the accompanying drawings.
Fig. 3 shows a flowchart of a method for encoding a two-dimensional code according to an embodiment of the present application. As shown in fig. 3, the method 300 includes steps S310 to S340.
In step S310, the data to be encoded is converted into a binary bit stream. It will be appreciated by those skilled in the art that the appropriate manner may be selected to convert the data to be encoded into a binary bit stream depending on the data type of the data.
Subsequently, in step S320, a preset start field is inserted at the start position of the binary bit stream. It will be appreciated that the start field is a binary field that is set in advance, and that the effect is that when its presence is identified in the decoding stage, the start position of the binary bit stream is known. Then, in step S330, the binary bit stream is rendered into a two-dimensional pattern starting from the start field. In step S340, a plurality of symmetrical positioning patterns are added to a predetermined area of the two-dimensional pattern. Because the preset initial field is inserted into the binary bit stream, even the symmetrical positioning pattern with higher aesthetic property and coordination can realize the positioning function of the two-dimensional pattern.
Fig. 4 shows a flowchart of a method of encoding a two-dimensional code according to another embodiment. As shown in fig. 4, the method 300 may further include steps S350 and S360 in addition to steps S310 to S340. For the sake of brevity, only the differences between the embodiment shown in fig. 4 and fig. 3 will be described below, and a detailed description of the same will be omitted.
Before rendering the binary bit stream into a two-dimensional pattern, in step S350, the binary bit stream is calculated according to a preset CRC generator polynomial to generate a CRC check code. Subsequently, in step S360, the generated CRC check code is inserted into the binary bit stream.
The CRC check code, namely the cyclic redundancy check code (Cyclic Redundancy Check), is an error checking check code commonly used in the field of data communication, and is characterized in that the lengths of an information field and a check field can be arbitrarily selected. The CRC check is a data transmission error detection function, performs polynomial computation on data, and attaches the obtained result (CRC check code) to the back of the data. The receiving device also performs a similar algorithm according to a prior convention to check the correctness and integrity of the data transmission.
When generating a CRC code, it is necessary to set a CRC generator polynomial in advance, generate the CRC code using the CRC generator polynomial in encoding, and perform the check using the same CRC generator polynomial in decoding.
Thereby, a CRC check code may be inserted in the binary bit stream, enabling a check of the correctness and integrity of the data transmission upon decoding.
Fig. 5 shows a flowchart of a method of encoding a two-dimensional code according to another embodiment. As shown in fig. 5, the method 300 may further include steps S350 'and S360', in addition to steps S310 to S340. For the sake of brevity, only the differences between the embodiment shown in fig. 5 and fig. 3 will be described below, and a detailed description of the same will be omitted.
Before rendering the binary bit stream into a two-dimensional pattern, in step S350', the binary bit stream is calculated according to a preset RS generator polynomial to generate an RS error correction code. Subsequently, in step S360', the generated RS error correction code is inserted into the binary bit stream.
RS error correction codes, also known as Reed-Solomon codes, are a type of forward error correction channel coding that is effective for correcting polynomials generated from over-sampled data. When the receiver correctly receives enough points, it can recover the original polynomial, even if many points on the received polynomial are distorted by noise interference.
When generating an RS error correction code, an RS generation polynomial needs to be set in advance, when encoding, the RS error correction code is generated by using the RS generation polynomial, and when decoding, the same RS generation polynomial is used, so that errors can be found and corrected at a receiving end after errors occur in the transmission process.
Thus, an RS error correction code can be inserted into the binary bit stream so that errors in the data can be corrected at the time of decoding.
According to one embodiment, the two-dimensional pattern may include a plurality of circles of closed figures, which may be concentric with each other. For example, the two-dimensional pattern includes four circles of closed figures concentric with each other, an outermost circle and an innermost circle of the four circles of closed figures may be annular, and two middle circles of the four circles of closed figures may be rounded polygons. The rounded polygon may be, for example, a rounded hexagon.
FIG. 6 illustrates a flow chart for rendering a binary bitstream into a two-dimensional pattern starting from a start field according to one embodiment of the present application. As shown in fig. 6, the above step S330 may include sub-steps S331 and S332.
In sub-step S331, rendering the position corresponding to 0 in the binary bit stream as blank; in sub-step S332, the position corresponding to 1 in the binary bit stream is rendered as a gray point or line segment. The blank may be white, and the gray points or segments may be black, but may also be other gray colors that are easily distinguishable from each other.
Fig. 7 shows a flow chart of rendering a binary bitstream into a two-dimensional pattern starting from a start field according to another embodiment. As shown in fig. 7, this step S330 may include sub-steps S333 and S334 in addition to sub-steps S331 and S332. For the sake of brevity, only the differences between the embodiment shown in fig. 7 and fig. 6 will be described below, and a detailed description of the same will be omitted.
In sub-step S333, three or more gray points continuously appearing in the rendered two-dimensional pattern (i.e., 111 or more bits 1 continuously are each rendered as a gray point) are detected. In sub-step S334, a part of the detected three or more gray points that appear in succession is adjusted to a gray line segment. Therefore, the attractive appearance and the coordination are enhanced, and the situation that the accurate identification is difficult to realize under the condition of lower resolution can be avoided.
Fig. 8 shows a flowchart of a method of encoding a two-dimensional code according to another embodiment. As shown in fig. 8, the method 300 may further include steps S370 to S390 in addition to steps S310 to S340. For the sake of brevity, only the differences between the embodiment shown in fig. 8 and fig. 3 will be described below, and a detailed description of the same will be omitted.
Before rendering the binary bit stream into a two-dimensional pattern, three or more 0S continuously present in the binary bit stream are detected in step S370. If it is detected that there are three or more 0S that occur consecutively, a preset escape field is inserted before the detected three or more 0S that occur consecutively in step S380. In step S390, the detected three or more 0S that occur in succession are subjected to an escape process.
That is, for example, if there are five consecutive 0 fields 00000 in the binary bitstream, the rendered two-dimensional code pattern will be displayed as five consecutive blanks, which greatly affects the beauty and coordination of the two-dimensional code pattern, and may be difficult to correctly recognize in case of low resolution. According to this embodiment, three or more 0 s that occur in succession may be subjected to an escape process and a preset escape field inserted in front of them for identification of the decoding stage. It will be appreciated that the specific manner of escape processing may be varied (e.g., 00000 may be modified to 01110, or 01010 may be modified), so long as the specific escape processing manner is pre-defined in advance between the encoding side and all possible decoding sides before encoding, encoding and decoding operations may be performed smoothly.
According to one embodiment, the symmetrical plurality of positioning patterns may be four positioning circles (as shown in fig. 2) symmetrically distributed.
According to another embodiment of the present application, the method for encoding a two-dimensional code may further include the following steps: and adding a Krani pattern or a preset picture in the central area surrounded by the closed pattern. Therefore, the attractiveness and the coordination of the two-dimensional code pattern can be further increased.
According to another embodiment of the present application, before step S310, the encoding method of the two-dimensional code may further include the following steps: audio data is received and used as data to be encoded. Therefore, the received audio data can be used as data to be encoded, and the two-dimensional code can be formed by utilizing the data. That is, in the two-dimensional code pattern thus formed, audio information is recorded for the user to listen to by scanning the code. The user can realize the off-line playing of the sound only by acquiring the two-dimension code.
Fig. 9 shows a flowchart of a decoding method of a two-dimensional code according to an embodiment of the present application. As shown in fig. 9, the method 900 includes steps S910 to S940.
In step S910, positions of a plurality of symmetrical positioning patterns in the scanned picture are identified to determine an area where the two-dimensional code pattern is located. In step S920, binary bit stream information (i.e., information recorded in the two-dimensional code pattern in the form of a binary bit stream) is acquired from the two-dimensional code pattern. In step S930, a preset start field is searched for in the acquired binary bitstream information. In step S940, the binary bit stream is converted according to a preset rule with the searched start field as a start point of the binary bit stream, so as to obtain decoding information.
Thus, the two-dimensional code pattern obtained by the encoding method can be decoded to obtain the data recorded in the two-dimensional code.
Fig. 10 illustrates a flowchart for acquiring binary bit stream information from a two-dimensional code pattern according to one embodiment of the present application. As shown in fig. 10, the above step S920 may include sub-steps S921 and S922.
In sub-step S921, the determined area where the two-dimensional code pattern is located is normalized to a preset template according to the symmetrical plurality of positioning patterns. Subsequently, in sub-step S922, binary bitstream information is acquired according to the two-dimensional code pattern on a preset template.
Since the difference of the photographed distance and angle affects decoding of the two-dimensional code pattern when photographing or scanning the two-dimensional code pattern, the two-dimensional code pattern can be normalized to a predetermined size (for example, by operations such as zooming in, zooming out, rotating, etc.) according to the position of each positioning pattern after the positioning pattern is recognized, that is, normalized to a preset template. Then, since it has been normalized, binary bit stream information can be easily acquired from the two-dimensional code pattern on the template.
According to an embodiment of the present application, the decoding method of the two-dimensional code may further include: and performing CRC check on the binary bit stream according to a preset CRC generating polynomial. If the CRC check is passed, it is indicated that the acquired binary bit stream is correct. If the CRC check is not passed, an error is indicated in the acquired binary bit stream.
According to another embodiment of the present application, the decoding method of the two-dimensional code may further include: and performing RS error correction on the binary bit stream according to a preset RS generating polynomial. Therefore, by utilizing the preset RS generating polynomial, the errors in the binary bit stream can be automatically found and corrected in the decoding operation after the errors occur in the transmission process.
According to one embodiment, the two-dimensional pattern may include a plurality of circles of closed figures, which may be concentric with each other. For example, the two-dimensional pattern includes four circles of closed figures concentric with each other, an outermost circle and an innermost circle of the four circles of closed figures may be annular, and two middle circles of the four circles of closed figures may be rounded polygons. The rounded polygon may be, for example, a rounded hexagon.
Fig. 11 illustrates a flowchart for acquiring binary bit stream information from a two-dimensional code pattern according to another embodiment of the present application. As shown in fig. 11, this step S920 may include sub-steps S923 and S924 in addition to sub-steps S921 and S922. For the sake of brevity, only the differences between the embodiment shown in fig. 11 and fig. 10 will be described below, and a detailed description of the same will be omitted.
In sub-step S923, a blank position in the two-dimensional code pattern is identified as 0. In sub-step S924, both the gray point and the line segment in the two-dimensional code pattern are identified as 1.
Fig. 12 illustrates a flowchart for acquiring binary bit stream information from a two-dimensional code pattern according to another embodiment of the present application. As shown in fig. 12, this step S920 may include sub-steps S925 and S926 in addition to sub-steps S921 to S924. For the sake of brevity, only the differences between the embodiment shown in fig. 12 and fig. 11 will be described below, and a detailed description of the same will be omitted.
In sub-step S925, a preset escape field is found in the binary bitstream information. In sub-step S926, the fields following the found escape fields are subjected to an anti-sense process according to a preset escape rule. Thus, by using the search of the preset escape field, the bits that are escape during the encoding process can be adjusted to the correct values. It will be appreciated that the specific manner of escape processing may be varied (e.g., 00000 may be modified to 01110, or 01010 may be modified as well), and thus, the inverse processing may be varied. Such as an escape process that modifies 00000 to 01110, and an antisense process that modifies 01110 to 00000; for example, the escape processing of modifying 00000 to 01010 is performed, and the antisense processing is performed by modifying 01010 to 00000. The encoding and decoding operations can be performed smoothly as long as a specific escape processing mode is pre-defined in advance by the encoding side and all possible decoding sides before encoding.
According to one embodiment, the symmetrical plurality of positioning patterns may be four positioning circles (as shown in fig. 2) symmetrically distributed.
Fig. 13 shows a flowchart for converting a binary bit stream with preset rules to obtain decoding information according to an embodiment of the present application. As shown in fig. 13, the above step S940 may include sub-steps S941 and S942.
In sub-step S941, the binary bit stream is converted into audio data; and in sub-step S942, the converted audio data is played. As described above, according to one embodiment of the present application, audio data may be recorded in a two-dimensional code. In contrast, when such a two-dimensional code is acquired, the decoded data can be converted into audio data and directly played.
Fig. 14 shows a flowchart of a method of encoding audio data into a two-dimensional code according to one embodiment of the present application. As shown in fig. 14, the method 1400 includes steps S1410 to S1440.
In step S1410, audio data is acquired. According to one embodiment, the audio data may be obtained through a microphone or a network. If acquired by a microphone, this step may include: collecting sound information by using a microphone; and recording the sound information as audio data. If acquired over a network, this step may include: the audio data is obtained from a server storing the audio data.
In step S1420, the audio data is converted into a binary bit stream. Those skilled in the art will appreciate that any suitable technique may be used to convert audio data into a binary bit stream and will not be described in detail herein.
In step S1430, a preset two-dimensional code encoding model is invoked. As the two-dimensional code has a plurality of coding mechanisms, a plurality of two-dimensional code coding models can be preset. And when the operation of the step is carried out, the selective call is carried out from a preset model.
In step S1440, the binary bit stream is rendered into a two-dimensional code pattern according to the invoked two-dimensional code coding model. Thus, the two-dimensional code pattern can be obtained, and the audio data is manufactured into the two-dimensional code pattern.
According to one embodiment of the application, the binary bit stream can be generated by utilizing the audio data and the image data together, so that the audio information and the image information can be recorded in the two-dimensional code at the same time. In this regard, the step S1420 may include: acquiring image data; and converting and superposing the audio data and the image data respectively to obtain a binary bit stream. According to one embodiment, the image data may be acquired by a camera or a network, i.e. the operation of acquiring the image data may comprise: collecting image data by using a camera; or the image data is acquired from a server storing the image data.
According to an embodiment of the present application, the method for encoding audio data into a two-dimensional code may further include: sending the two-dimensional code pattern through a network; or the two-dimensional code pattern is printed on the printed matter.
Fig. 15 shows a flowchart of a method of decoding a two-dimensional code into audio data according to one embodiment of the present application. As shown in fig. 15, the method 1500 includes steps S1510 to S1530.
In step S1510, a two-dimensional code pattern is acquired. According to one embodiment, the two-dimensional code pattern may be obtained through a camera or a network. If acquired by a camera, this step may include: and acquiring a two-dimensional code pattern through a camera. If acquired over a network, this step may include: and acquiring the two-dimensional code pattern from a server storing the two-dimensional code pattern.
In step S1520, binary bit stream information is acquired from the two-dimensional code pattern according to a preset two-dimensional code model. Because the encoding/decoding mechanisms of the two-dimensional code are multiple, multiple two-dimensional code models can be preset. And when the operation of the step is carried out, the selective call is carried out from a preset model.
In step S1530, the binary bit stream is converted into audio data. Those skilled in the art will appreciate that any suitable technique may be used to convert the binary bit stream into audio data and will not be described in detail herein. Therefore, the audio data can be obtained from the two-dimensional code pattern for playing or storing.
According to an embodiment of the present application, the method for decoding the two-dimensional code into the audio data may further include: playing the audio data through a speaker or an earphone; or transmit audio data over a network.
The application also provides a mobile terminal comprising a processor and a memory. The memory has a program stored therein that, when executed by the processor, causes the processor to perform any one of the above-described method of encoding audio data into two-dimensional code and method of decoding two-dimensional code into audio data. That is, when a user is using the mobile terminal, the mobile terminal may be used to make data (e.g., audio data collected through a microphone of the mobile terminal) into a two-dimensional code, and the mobile terminal may be used to decode the obtained two-dimensional code into a desired data form (e.g., converted into audio data and played).
Those skilled in the art will appreciate that the present application may be implemented as a system, method, or computer program product. Thus, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment (including firmware, resident software, micro-code, etc.) or an embodiment combining software and hardware aspects that may all generally be referred to as a "circuit," module "or" system. Furthermore, the present application may take the form of a computer program product embodied in any tangible expression medium having computer-usable program code embodied in the medium.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the application. It will be understood that each block of the flowchart illustrations and/or block diagrams, and combinations of 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, 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/acts specified in the flowchart and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable medium 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 medium produce an apparatus including instructions which implement the function/act specified in the flowchart and/or block diagram block or blocks.
The 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 processes for implementing the functions/acts specified in the flowchart and/or block diagram block or blocks.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may in fact be executed substantially concurrently or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
While the above description includes many specific arrangements and parameters, it is noted that these specific arrangements and parameters are merely illustrative of one embodiment of the present application. This should not be taken as limiting the scope of the present application. Those skilled in the art will appreciate that various modifications, additions and substitutions are possible, without departing from the scope and spirit of the invention. The scope of the application should therefore be construed based on the appended claims.

Claims (27)

1. A two-dimensional code encoding method comprises the following steps:
converting data to be encoded into a binary bit stream;
inserting a preset initial field in the initial position of the binary bit stream;
rendering the binary bit stream into a two-dimensional pattern starting from the start field;
and adding a plurality of symmetrical positioning patterns in a preset area of the two-dimensional pattern.
2. The method of claim 1, further comprising:
calculating the binary bit stream according to a preset CRC generating polynomial to generate a CRC check code;
the generated CRC check code is inserted into the binary bit stream.
3. The method of claim 1 or 2, further comprising:
calculating the binary bit stream according to a preset RS generating polynomial to generate an RS error correcting code;
the generated RS error correction code is inserted into the binary bit stream.
4. The method of claim 1, wherein the two-dimensional pattern comprises a plurality of circles of closed figures, the circles of closed figures being concentric with one another.
5. The method of claim 1, wherein the two-dimensional pattern comprises four circles of closed figures concentric with each other, an outermost circle and an innermost circle of the four circles of closed figures being annular, and a middle two circles of the four circles of closed figures being rounded polygons.
6. The method of claim 5, wherein the rounded polygon is a rounded hexagon.
7. The method of any of claims 4-6, wherein rendering the binary bitstream into a two-dimensional pattern starting from the start field comprises:
rendering a position corresponding to 0 in the binary bit stream as blank;
and rendering the position corresponding to 1 in the binary bit stream as a gray point or a line segment.
8. The method of claim 7, wherein rendering the binary bitstream into a two-dimensional pattern starting from the start field further comprises:
detecting three or more gray points continuously appearing in the rendered two-dimensional pattern;
and adjusting part of gray points in the three or more gray points which are detected and continuously appear into gray line segments.
9. The method of claim 1, further comprising:
detecting three or more 0 s that occur consecutively in the binary bit stream;
inserting a preset escape field before three or more 0 s detected to occur in succession;
and (3) performing escape processing on three or more 0 s which are detected and continuously appear.
10. The method of claim 1, wherein the symmetrical plurality of positioning patterns are four positioning circles distributed symmetrically.
11. The method of claim 4 or 5, further comprising:
and adding a Krani pattern or a preset picture in the central area surrounded by the closed pattern.
12. The method of claim 1, further comprising:
and receiving audio data and taking the audio data as the data to be encoded.
13. A decoding method of a two-dimensional code, comprising:
identifying the positions of a plurality of symmetrical positioning patterns in the scanned picture to determine the area where the two-dimensional code pattern is located;
acquiring binary bit stream information from the two-dimensional code pattern;
searching a preset initial field in the binary bit stream information;
and converting the binary bit stream by taking the searched initial field as a starting point of the binary bit stream and a preset rule to obtain decoding information.
14. The method of claim 13, wherein obtaining binary bit stream information from the two-dimensional code pattern comprises:
normalizing the area where the determined two-dimensional code pattern is positioned to a preset template according to the symmetrical positioning patterns;
And acquiring the binary bit stream information according to the two-dimensional code pattern on the preset template.
15. The method of claim 13, further comprising:
and performing CRC check on the binary bit stream according to a preset CRC generating polynomial.
16. The method of claim 13 or 15, further comprising:
and performing RS error correction on the binary bit stream according to a preset RS generating polynomial.
17. The method of claim 13, wherein the two-dimensional code pattern comprises a plurality of circles of closed figures, the circles of closed figures being concentric with one another.
18. The method of claim 13, wherein the two-dimensional code pattern comprises four circles of closed figures concentric with each other, an outermost circle and an innermost circle of the four circles of closed figures being annular, and a middle two circles of the four circles of closed figures being rounded polygons.
19. The method of claim 18, wherein the rounded polygon is a rounded hexagon.
20. The method of any of claims 17-19, wherein obtaining binary bit stream information from the two-dimensional code pattern comprises:
identifying a blank position in the two-dimensional code pattern as 0;
and identifying the gray point and the line segment in the two-dimensional code pattern as 1.
21. The method of claim 20, wherein obtaining binary bit stream information from the two-dimensional code pattern further comprises:
searching a preset escape field in the binary bit stream information;
and performing the reverse sense processing on the fields after the searched escape fields according to the preset escape rules.
22. The method of claim 13, wherein the symmetrical plurality of positioning patterns are four positioning circles distributed symmetrically.
23. The method of claim 13, wherein converting the binary bit stream with a preset rule using the searched start field as a start point of the binary bit stream to obtain decoding information comprises:
converting the binary bit stream into audio data;
and playing the audio data.
24. An encoding device of a two-dimensional code, comprising:
a processor;
a memory for storing one or more programs;
the one or more programs, when executed by the processor, cause the processor to perform the method of any of claims 1-12.
25. A decoding device of a two-dimensional code, comprising:
a processor;
a memory for storing one or more programs;
The one or more programs, when executed by the processor, cause the processor to perform the method of any of claims 13-23.
26. A non-transitory computer readable storage medium having stored thereon a computer program which, when executed by a processor, causes the processor to implement the method of any of claims 1-23.
27. A two-dimensional code encoded by the method of any one of claims 1-12.
CN201810395881.XA 2018-04-27 2018-04-27 Two-dimensional code, encoding and decoding methods and devices thereof, storage medium and mobile terminal Active CN110414644B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810395881.XA CN110414644B (en) 2018-04-27 2018-04-27 Two-dimensional code, encoding and decoding methods and devices thereof, storage medium and mobile terminal

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810395881.XA CN110414644B (en) 2018-04-27 2018-04-27 Two-dimensional code, encoding and decoding methods and devices thereof, storage medium and mobile terminal

Publications (2)

Publication Number Publication Date
CN110414644A CN110414644A (en) 2019-11-05
CN110414644B true CN110414644B (en) 2023-05-09

Family

ID=68346859

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810395881.XA Active CN110414644B (en) 2018-04-27 2018-04-27 Two-dimensional code, encoding and decoding methods and devices thereof, storage medium and mobile terminal

Country Status (1)

Country Link
CN (1) CN110414644B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111062704A (en) * 2019-12-10 2020-04-24 支付宝(杭州)信息技术有限公司 Method and device for identifying graphic code
CN111291846B (en) * 2020-05-09 2021-06-04 支付宝(杭州)信息技术有限公司 Two-dimensional code generation, decoding and identification method, device and equipment
CN112215322B (en) * 2020-12-14 2021-04-13 深圳市深圳通有限公司 Traffic two-dimensional code generation method and generation device, and verification method and verification device
CN114912475A (en) * 2021-02-07 2022-08-16 华为技术有限公司 Two-dimensional code identification method and related device

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101093553A (en) * 2007-07-19 2007-12-26 成都博古天博科技有限公司 2D code system, and identification method
CN102622626B (en) * 2011-12-26 2014-12-24 华南理工大学 Method for recognizing two-dimension code
CN106022425B (en) * 2016-05-15 2019-09-10 杭州荣旗科技有限公司 A kind of coding and interpretation method of layered structure two dimensional code

Also Published As

Publication number Publication date
CN110414644A (en) 2019-11-05

Similar Documents

Publication Publication Date Title
CN110414644B (en) Two-dimensional code, encoding and decoding methods and devices thereof, storage medium and mobile terminal
KR100730611B1 (en) Electronic watermark embedding device, electronic watermark detection device, method thereof, and program
TW201710957A (en) Generating and decoding two-dimensional code
JP2019067408A (en) Learning method and learning device for image segmentation, and image segmentation method and image segmentation device using the same
CN103793735B (en) Circular two-dimensional bar code and encoding and decoding method thereof
US8458520B2 (en) Apparatus and method for verifying training data using machine learning
JP2018530225A5 (en)
US9425830B2 (en) Error detection device and error detecting method
Zhang et al. Aesthetic QR codes based on two-stage image blending
JP4207049B2 (en) Printed matter with identification function, image generation apparatus, image processing apparatus and method thereof
CN108846385A (en) Based on convolution-deconvolution neural network image recognition, bearing calibration and device
JP2014176033A (en) Communication system, communication method and program
CN107749990A (en) A kind of video copyright protecting method and device based on digital watermarking
JP6543764B2 (en) Security authentication method for digital video content and system therefor
CN107845118B (en) Data image processing method
US8363885B2 (en) Method, device, and program for embedding, displaying, and recognizing data
Kuribayashi et al. Aesthetic QR code based on modified systematic encoding function
CN109640096A (en) A kind of concealed communication method based on video decoding electromagnetic leakage
CN117292020A (en) Image generation method, device, electronic equipment and storage medium
CN107742145A (en) Data embedding method, method for reading data, device and readable storage medium storing program for executing
US9111162B2 (en) Method, apparatus and storage medium for two-dimensional data storage
Duda et al. Image-like 2d barcodes using generalizations of the Kuznetsov–Tsybakov problem
CN106682717B (en) Method and system for generating halftone two-dimensional code
CN111597851B (en) Two-dimensional code anti-counterfeiting processing method, system, computer readable medium and electronic equipment
JP2011049690A (en) Two-dimensional code generator, image forming system, two-dimensional code reader, computer program, and medium

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
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20230719

Address after: 311121 Room 437, Floor 4, Building 3, No. 969, Wenyi West Road, Wuchang Subdistrict, Yuhang District, Hangzhou City, Zhejiang Province

Patentee after: Wuzhou Online E-Commerce (Beijing) Co.,Ltd.

Address before: Box 847, four, Grand Cayman capital, Cayman Islands, UK

Patentee before: ALIBABA GROUP HOLDING Ltd.