Two-dimensional code, two-dimensional code encoding method and device, and two-dimensional code identification method and device
Technical Field
The application relates to the field of two-dimensional codes, in particular to a two-dimensional code, a two-dimensional code encoding method and device, and a two-dimensional code identification method and device.
Background
In recent years, with the continuous development of a graphic coding technology and an image processing technology, a two-dimensional code technology develops rapidly and is widely applied to the fields of mobile payment, securities, information traceability, product packaging, internet of things and the like. Over decades of development, many different kinds of two-dimensional codes, such as QR Code (Quick Response Code), PDF147, DataMatrix, Tencent applet, etc., are emerging.
The traditional one-dimensional bar code and two-dimensional code usually have fixed and unchangeable shapes, the appearance shapes of the traditional one-dimensional bar code and the traditional two-dimensional bar code are usually limited to be fixed shapes such as a rectangle or a circle, the appearance is quite single, and the diversity is lacked. In order to facilitate program reading, the traditional one-dimensional bar code and the traditional two-dimensional bar code usually exist independently in product design, are difficult to be fused with other image-text designs on the product, and destroy the integral image-text design style of the product to a certain extent. Moreover, in order to enable a reading program to quickly and accurately locate, the locating pattern in the conventional matrix two-dimensional code is usually large in size, which reduces the effective user data stored in the two-dimensional code coding area. If more data needs to be stored, the size and range of the two-dimensional code have to be enlarged. In order to beautify the appearance style of the two-dimensional code, many manufacturers beautify code elements, positioning blocks and the like by using the fault-tolerant capability of the two-dimensional code, but the success rate of reading the two-dimensional code is reduced by the method, and the two-dimensional code can only restore the stored effective user data by a corresponding error correction algorithm by storing more error correction codes. The method sacrifices the capacity of the two-dimension code for storing effective user data, increases the complexity of a decoding and identifying algorithm and reduces the efficiency of two-dimension code identification.
Disclosure of Invention
The application aims to provide a two-dimension code, a two-dimension code encoding method and device, and a two-dimension code identification method and device. The two-dimensional code can break through the limitation of the traditional two-dimensional code on the appearance shape by storing the user data in the primitive two-dimensional code and repeatedly filling the primitive two-dimensional code into the two-dimensional code pattern filling area, and provides richer, more flexible and more changeable appearance patterns. The two-dimension code can be fused with the product graphic design, so that the two-dimension code is hidden in the product graphic design. Due to the repeated filling mechanism, the obtained two-dimensional code has good data redundancy characteristic, and the fault-tolerant performance and the reading success rate of the two-dimensional code can be further improved.
In a first aspect of the present application, a two-dimensional code is provided, which includes a graph outline area and a graph filling area;
the graphic outline region is used for presenting the appearance style of the two-dimensional code;
the figure filling area is positioned in the figure outline area and is formed by repeatedly filling the primitive two-dimensional codes;
each element two-dimensional code consists of code elements and comprises a positioning area and a data area, wherein the positioning area is used for a reading program to determine the position of each area in the element two-dimensional code, and the data area is used for storing user data.
In a second aspect of the present application, a two-dimensional code encoding method is provided, including:
receiving graphic setting data and user data input by a user;
generating a graph outline area and a blank graph filling area according to the graph setting data;
acquiring a primitive two-dimensional code model, wherein the primitive two-dimensional code model consists of code elements and comprises a positioning area and a data area, and the positioning area is used for a reading program to determine the position of each area in the primitive two-dimensional code;
filling user data into a data area according to a first preset encoding and decoding rule to obtain a primitive two-dimensional code;
and repeatedly filling the primitive two-dimensional code into a pattern filling area to obtain a two-dimensional code pattern.
Further, before or after acquiring the primitive two-dimensional code model, the method further comprises:
segmenting user data to obtain user subdata and sequence information of the user subdata;
filling the user data into the data area according to a first predetermined encoding and decoding rule further comprises: and for each user subdata, filling the user subdata and the sequence information thereof into a data area according to a first preset coding and decoding rule to obtain a primitive two-dimensional code.
Further, when receiving graphic setting data and user data input by a user, receiving coding function data or determining the coding function data according to the user data;
the primitive two-dimensional code model also comprises a functional area;
filling the user data into the data area according to a first preset encoding and decoding rule to obtain the elementary two-dimensional code, further comprising:
and filling the coding function data into the function area according to a second coding and decoding rule, and filling the user data into the data area according to a coding and decoding rule corresponding to the coding function data to obtain the primitive two-dimensional code.
Further, before or after acquiring the primitive two-dimensional code model, the method further comprises:
segmenting user data to obtain user subdata and sequence information of the user subdata;
filling the coding function data into the function area according to the second coding and decoding rule, filling the user data into the data area according to the coding and decoding rule corresponding to the coding function data, and obtaining the element two-dimensional code further comprises the following steps: and for each piece of user subdata, filling the coded function data and the sequence information of the user subdata into a function area according to a second preset coding and decoding rule, and filling the user subdata into a data area according to a coding and decoding rule corresponding to the coded function data to obtain the elementary two-dimensional code.
In a third aspect of the present application, there is provided a two-dimensional code encoding device, including:
the input module is used for receiving graphic setting data and user data input by a user;
the generating module is used for generating a graph outline area and a blank graph filling area according to the graph setting data;
the encoding module is used for acquiring a primitive two-dimensional code model, the primitive two-dimensional code model consists of code elements and comprises a positioning area and a data area, and the positioning area is used for a reading program to determine the position of each area in the primitive two-dimensional code;
the first filling module is used for filling the user data into the data area according to a first preset coding and decoding rule to obtain a primitive two-dimensional code;
and the second filling module is used for repeatedly filling the primitive two-dimensional code into the pattern filling area to obtain the two-dimensional code pattern.
In a fourth aspect of the present application, a two-dimensional code identification method is further provided, including:
collecting a two-dimensional code image;
searching a positioning area in the two-dimensional code image, and positioning the range and the direction of a data area in an elementary two-dimensional code according to one or more searched positioning areas;
and decoding each code element in the data region according to a first preset coding and decoding rule to obtain user data.
In a fifth aspect of the present application, a two-dimensional code identification method is further provided, including:
collecting a two-dimensional code image;
searching a positioning area in the two-dimensional code image, and positioning the range and the direction of a data area in an elementary two-dimensional code according to one or more searched positioning areas;
decoding each code element in the data area according to a first preset coding and decoding rule to obtain the user subdata and the sequence information of the user subdata;
determining the number of the elementary two-dimensional codes for storing different user subdata according to the sequence information of the user subdata, and re-executing the steps of positioning and decoding according to the number of the elementary two-dimensional codes for storing different user subdata until all the user subdata and the sequence information thereof are obtained;
and combining the user subdata according to the sequence information of the user subdata to obtain the user data.
In a sixth aspect of the present application, there is provided a two-dimensional code identification method, including:
collecting a two-dimensional code image;
searching a positioning area in the two-dimensional code image, and positioning the range and the direction of a data area and a functional area in an elementary two-dimensional code according to one or more searched positioning areas;
decoding each code element in the functional region according to a second preset coding and decoding rule to obtain coding functional data;
and decoding each code element in the data area according to the coding and decoding rules corresponding to the coding function data to obtain the user data.
A seventh aspect of the present application further provides a two-dimensional code identification method, including:
collecting a two-dimensional code image;
searching a positioning area in the two-dimensional code image, and positioning the range and the direction of a data area and a functional area in an elementary two-dimensional code according to one or more searched positioning areas;
decoding each code element in the functional area according to a second preset coding and decoding rule to obtain the sequence information of the coding functional data and the user subdata;
decoding each code element in the data area according to a coding and decoding rule corresponding to the coding function data to obtain user subdata;
determining the number of the elementary two-dimensional codes for storing different user subdata according to the sequence information of the user subdata, and re-executing the steps of positioning and decoding according to the number of the elementary two-dimensional codes for storing different user subdata until all the user subdata and the sequence information thereof are obtained;
and combining the user subdata according to the sequence information of the user subdata to obtain the user data.
In an eighth aspect of the present application, there is provided a two-dimensional code recognition apparatus, including:
the acquisition module is used for acquiring a two-dimensional code image;
the positioning module is used for searching a positioning area in the two-dimensional code image and positioning the range and the direction of a data area in the elementary two-dimensional code according to one or more searched positioning areas;
and the identification module is used for decoding each code element in the data area according to a first preset coding and decoding rule to obtain user data.
The ninth aspect of the present application further provides a two-dimensional code recognition apparatus, including:
the acquisition module is used for acquiring a two-dimensional code image;
the positioning module is used for searching a positioning area in the two-dimensional code image and positioning the range and the direction of a data area in a primitive two-dimensional code according to one or more searched positioning areas;
the identification module is used for decoding each code element in the data area according to a first preset coding and decoding rule to obtain the user subdata and the sequence information of the user subdata;
the analysis module is used for determining the number of the elementary two-dimensional codes for storing different user subdata according to the sequence information of the user subdata, and restarting the positioning module and the identification module according to the number of the elementary two-dimensional codes for storing different user subdata until all the user subdata and the sequence information thereof are obtained;
and the combination module is used for combining the user subdata according to the sequence information of the user subdata to obtain the user data.
In a tenth aspect of the present application, there is provided a two-dimensional code recognition apparatus, including:
the acquisition module is used for acquiring a two-dimensional code image;
the positioning module is used for searching a positioning area in the two-dimensional code image and positioning the range and the direction of a data area and a functional area in a primitive two-dimensional code according to one or more searched positioning areas;
the first identification module is used for decoding each code element in the functional region according to a second preset coding and decoding rule to obtain coding functional data;
and the second identification module is used for decoding each code element in the data area according to the coding and decoding rule corresponding to the coding function data to obtain the user data.
In an eleventh aspect of the present application, there is provided a two-dimensional code recognition apparatus, including:
the acquisition module is used for acquiring a two-dimensional code image;
the positioning module is used for searching a positioning area in the two-dimensional code image and positioning the range and the direction of a data area and a functional area in a primitive two-dimensional code according to one or more searched positioning areas;
the first identification module is used for decoding each code element in the functional area according to a second preset coding and decoding rule to obtain the sequence information of the coding functional data and the user subdata;
the second identification module is used for decoding each code element in the data area according to the coding and decoding rules corresponding to the coding function data to obtain the user subdata;
the analysis module is used for determining the number of the elementary two-dimensional codes for storing different user subdata according to the sequence information of the user subdata, and restarting the positioning module, the first identification module and the second identification module according to the number of the elementary two-dimensional codes for storing different user subdata until all the user subdata and the sequence information thereof are obtained;
and the combination module is used for combining the user subdata according to the sequence information of the user subdata to obtain the user data.
In a twelfth aspect of the present application, a computer device is provided, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the processor executes the computer program, the processor implements the two-dimensional code encoding method according to any of the foregoing embodiments.
In a thirteenth aspect of the present application, a computer-readable storage medium stores a computer program for implementing the two-dimensional code encoding method according to any one of the foregoing embodiments when the computer program is executed by a processor.
In a fourteenth aspect of the present application, a computer device is provided, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the processor executes the computer program, the processor implements the two-dimensional code recognition method according to any of the foregoing embodiments.
In a fifteenth aspect of the present application, a computer-readable storage medium is provided, which stores a computer program for executing, when executed by a processor, a two-dimensional code identification method according to any one of the foregoing embodiments.
The two-dimensional code that this application provided can break through traditional two-dimensional code to the restriction of appearance shape, realizes the variety of two-dimensional code outward appearance and size. The appearance style of the two-dimensional code can be changed according to user requirements, the two-dimensional code is hidden in product graphic design, and information data storage and hiding are achieved while the product design diversity requirements are considered. In addition, the two-dimensional code comprises a plurality of primitive two-dimensional codes, the stored information has redundancy, the stored information can be successfully extracted by a reading program only by finding one or more primitive two-dimensional codes, and even if part of the primitive two-dimensional codes in the two-dimensional code are damaged, the two-dimensional code can still be decoded by other undamaged primitive two-dimensional codes, so that the two-dimensional code has better fault tolerance and adaptability.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a schematic view of a two-dimensional code with a digital outline according to an embodiment of the present disclosure;
fig. 2 is a schematic view of a two-dimensional code of a butterfly profile according to an embodiment of the present disclosure;
fig. 3 is a schematic diagram of a primitive two-dimensional code according to an embodiment of the present disclosure;
fig. 4A, fig. 4B, fig. 5A and fig. 5B are flowcharts of a two-dimensional code encoding method according to an embodiment of the present application;
fig. 6A and fig. 6B are schematic diagrams of a two-dimensional code obtained after encoding according to an embodiment of the present application;
fig. 7A and 7B are configuration diagrams of a two-dimensional code encoding device according to an embodiment of the present application;
fig. 8A, 8B, 9A, and 9B are flowcharts of a two-dimensional code recognition method according to an embodiment of the present application;
fig. 10A, 10B, 11A, and 11B are schematic diagrams of a two-dimensional code recognition apparatus according to an embodiment of the present disclosure;
fig. 12 is a schematic diagram of a primitive two-dimensional code positioning method according to an embodiment of the present application;
fig. 13 is a schematic diagram of a computer device according to an embodiment of the present application.
Detailed Description
In order to make the technical features and effects of the present application more obvious, the technical solutions of the present application are further described below with reference to the accompanying drawings, and the present application may also be described or implemented by other different specific examples, and any equivalent changes made by those skilled in the art within the scope of the claims are included in the protection scope of the present application.
In the description herein, references to the description of the terms "an embodiment," "a particular embodiment," "some embodiments," "for example," etc., mean that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the application. In this specification, the schematic representations of the terms used above do not necessarily refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. The sequence of steps involved in the embodiments is for illustrative purposes to illustrate the implementation of the present application, and the sequence of steps is not limited and can be adjusted as needed.
The terms "first," "second," and the like, as used in the description of the present specification, do not particularly denote any order or sequence, nor are they used to limit the present application, but rather are used to distinguish one element or operation from another element or operation described in the same technical language.
It should be noted that, in the following embodiments, if no special description is made, the two-dimensional code refers to a two-dimensional code provided in the present application.
The two-dimensional code proposed in the present application is composed of a pattern outline area 101, 201 and a pattern fill area 102, 202. The figure outline area is used for presenting the appearance style of the two-dimensional code. The figure filling area is positioned in the figure outline area and is formed by repeatedly filling the primitive two-dimensional codes. Each element two-dimensional code consists of code elements and comprises a positioning area and a data area, wherein the positioning area is used for a reading program to determine the position of each area in the element two-dimensional code so as to facilitate the decoding of the reading program, and the data area is used for storing user data.
In specific implementation, the shape of the graphic outline region may be arbitrarily selected, which is not limited in this application, for example, the graphic outline region 101 in fig. 1 is a digital shape, and the graphic outline region 201 in fig. 2 is a butterfly shape. In addition, the figure outline region can be an outline figure with obvious boundary, can also be an outline figure without obvious boundary, and can also be an outline figure with certain filling space inside.
The primitive two-dimensional codes can be filled in an orderly or unordered mode, the specific filling mode is not limited in the application, and the graphic filling area can be filled as long as the primitive two-dimensional codes are not overlapped with each other. In some embodiments, in order to increase the data storage density, the adjacent arrangement mode of the two-dimensional codes can be selected. The primitive two-dimensional code repeatedly filling the graphic filling area is a single primitive two-dimensional code storing the same user data or a plurality of primitive two-dimensional codes storing different user data. The type of the code element in the primitive two-dimensional code can be selected at will, and the application does not specifically limit the type of the code element. As shown in fig. 3, the symbol 301 of the elementary two-dimensional code 300 is composed of hexagonal cells.
In an embodiment of the present application, as shown in fig. 3, the primitive two-dimensional code includes a functional area 304 for storing encoding functional data, in addition to a positioning area 302 and a data area 303. Specifically, the encoding function data includes, but is not limited to, version information, mask information, and error correction level information.
The version information is used for limiting the maximum storage capacity of the two-dimensional code, the division form of the code element, the filling mode of the primitive two-dimensional code and the like. The different version information corresponds to different coding and decoding rules or data capacity of the two-dimensional code. And when the two-dimensional code is coded, storing the user data in the code element of the data area according to the coding and decoding rule corresponding to the version information. And when the two-dimensional code is decoded, decoding the code element of the data area according to the coding and decoding rule corresponding to the version information.
The mask information is used to indicate a mask pattern used by the two-dimensional code. And masking (masking) the filled or pre-filled two-dimensional code graph by using a preset masking pattern (masking), so that the color distribution of the finally presented two-dimensional code graph is more uniform. Specifically, masking enables the dark and light (e.g., black and white, black representing a binary 1 and white representing a binary 0) regions in the two-dimensional code pattern to be distributed at an optimal ratio.
The error correction levels may follow, for example, 4 error correction levels (L, M, Q, H) of the conventional two-dimensional code, and new error correction levels may also be defined. In specific implementation, error correction data is calculated by an error correction algorithm (a reed solomon error correction algorithm (reed solomon error correction) algorithm can be selected, and other algorithms can also be selected) according to the error correction level and the user data, and the user data and the error correction data are stored in a data area of the two-dimensional code according to a preset rule, so that the user data can still be restored by a reading program under the conditions of partial pollution, incomplete defect and the like of the two-dimensional code.
In an embodiment of the present application, as shown in fig. 3, the positioning area 302 is composed of a positioning pattern 305 and an auxiliary positioning pattern 306, it should be noted that the positioning pattern and the auxiliary positioning pattern shown in fig. 3 are only examples, and the present application does not specifically limit the selection of the positioning pattern and the auxiliary positioning pattern. The positioning graph is used for searching and determining the position of the primitive two-dimensional code, and the collected two-dimensional code graph is corrected by utilizing the characteristics of the positioning graph. The auxiliary positioning graph is optional and is mainly used for correcting image mirroring, overturning and the like.
In an embodiment of the present application, there is further provided a two-dimensional code encoding method according to any one of the above embodiments, as shown in fig. 4A, including:
step 401, receiving the graphic setting data and the user data input by the user. In specific implementation, the graphic setting data may be selected by a user according to a preset graphic list, or may be set by the user according to a requirement, which is not limited in the present application.
In step 403, a pattern outline area and a blank pattern fill area are generated based on the pattern setting data.
Step 405, obtaining a primitive two-dimensional code model, where the primitive two-dimensional code model is composed of code elements and includes a positioning area and a data area, and the positioning area is used for the recognition program to determine the position of each area in the primitive two-dimensional code. The primitive two-dimensional code model is a primitive two-dimensional code not filled with user data.
Step 407, the user data is filled into the data area according to a first predetermined encoding and decoding rule, so as to obtain the primitive two-dimensional code.
And 409, repeatedly filling the primitive two-dimensional code into a pattern filling area to obtain a two-dimensional code pattern.
As an example of the application, the two-dimensional code obtained by the encoding method is shown in fig. 6A and 6B, the appearance style of the obtained two-dimensional code can be changed according to the user requirement, and the two-dimensional code is hidden in the product graphic design, so that the information data can be stored and hidden while the product design diversity requirement is considered. In addition, the two-dimensional code comprises a plurality of primitive two-dimensional codes, the stored information has redundancy, the stored information can be successfully extracted by a reading program only by finding one or more primitive two-dimensional codes, and even if part of the primitive two-dimensional codes in the two-dimensional code are damaged, the two-dimensional code can still be decoded by other undamaged primitive two-dimensional codes, so that the two-dimensional code has better fault tolerance and adaptability.
In specific implementation, if the user data is large, one primitive two-dimensional code cannot store all the user data, as shown in fig. 4B, before or after the step 405 of obtaining the primitive two-dimensional code model, the method further includes: step 406, segmenting the user data to obtain the user sub-data and the sequence information of the user sub-data, where the sequence information of the user sub-data is used to accurately restore the user data when the two-dimensional code is decoded, and specifically, the sequence information of the user sub-data includes: the ordering of the user subdata and the total number of the user subdata.
The step 407 further includes: step 407', for each user subdata, the user subdata and the sequence information thereof are filled into the data area according to a first predetermined encoding and decoding rule to obtain a primitive two-dimensional code. In the above step 409, all the primitive two-dimensional codes obtained in the step 407' are repeatedly filled into the pattern filling area to obtain a two-dimensional code pattern.
In an embodiment of the present application, as shown in fig. 5A, a two-dimensional code encoding method includes:
step 501, receiving the graphic setting data, the encoding function data and the user data input by the user. In particular, the encoding function data (including but not limited to version information, mask information, and error correction level information) may also be determined according to the user data, for example, the version information may be determined according to the size of the user data.
In step 503, a pattern outline area and a blank pattern fill area are generated based on the pattern setting data.
And 505, acquiring a primitive two-dimensional code model, wherein the primitive two-dimensional code model consists of code elements and comprises a positioning area, a data area and a functional area, and the positioning area is used for a reading program to determine the position of each area in the primitive two-dimensional code.
And 507, filling the coding function data into the function area according to a second coding and decoding rule, and filling the user data into the data area according to a coding and decoding rule corresponding to the coding function data to obtain the primitive two-dimensional code.
In one embodiment, the encoding function data includes version information, mask information, and error correction level information, and the process of filling the user data into the data region according to the encoding and decoding rules corresponding to the encoding function data includes: coding the user data according to the coding and decoding rules corresponding to the version information to obtain binary data; and processing the binary data according to the error correction level and the mask information, and filling the processed data into the data area.
And 509, repeatedly filling the primitive two-dimensional code into a pattern filling area to obtain a two-dimensional code pattern.
In specific implementation, if the user data is large, one primitive two-dimensional code cannot store all the user data, as shown in fig. 5B, before or after the step 505 of obtaining the primitive two-dimensional code model, the method further includes: step 506, the user data is segmented to obtain the user sub data and the sequence information of the user sub data.
In step 507, the encoding function data is filled into the function area according to the second encoding and decoding rule, and the user data is filled into the data area according to the encoding and decoding rule corresponding to the encoding function data, so as to obtain the primitive two-dimensional code, further including: and 507', for each piece of user subdata, filling the coded function data and the sequence information of the user subdata into a function area according to a second preset coding and decoding rule, and filling the user subdata into a data area according to a coding and decoding rule corresponding to the coded function data to obtain the elementary two-dimensional code.
Based on the same inventive concept, an embodiment of the present application further provides a coding apparatus, as shown in fig. 7A, which is suitable for the two-dimensional code described in the embodiment of fig. 4A, and since the principle of solving the problem of the coding apparatus is similar to that of the coding method, the implementation of the coding apparatus may refer to the coding method, and repeated details are omitted. Specifically, the encoding device includes:
an input module 701, configured to receive graphic setting data and user data input by a user;
a generating module 702, configured to generate a graph outline area and a blank graph filling area according to graph setting data;
the encoding module 703 is configured to obtain a primitive two-dimensional code model, where the primitive two-dimensional code model is composed of code elements and includes a positioning area and a data area, and the positioning area is used for a recognition program to determine the position of each area in the primitive two-dimensional code;
a first filling module 704, configured to fill the user data into the data area according to a first predetermined encoding and decoding rule, so as to obtain a primitive two-dimensional code;
the second filling module 705 is configured to repeatedly fill the primitive two-dimensional code into the pattern filling area to obtain a two-dimensional code pattern.
In a further embodiment, the input module 701 is further configured to receive encoded function data input by a user or determine the encoded function data according to the user data, the primitive two-dimensional code model obtained by the encoding module 703 further includes a function region, the first filling module 704 is configured to fill the encoded function data into the function region according to a second encoding and decoding rule, and fill the user data into the data region according to an encoding and decoding rule corresponding to the encoded function data, so as to obtain the primitive two-dimensional code.
In an embodiment of the present application, an encoding apparatus is further provided, as shown in fig. 7B, which is suitable for the two-dimensional code described in the embodiment of fig. 4B, and includes:
an input module 701' for receiving graphic setting data and user data input by a user;
a generating module 702' for generating a graph outline area and a blank graph filling area according to the graph setting data;
the encoding module 703' is used for obtaining a primitive two-dimensional code model, wherein the primitive two-dimensional code model is composed of code elements and comprises a positioning area and a data area, and the positioning area is used for a reading program to determine the position of each area in the primitive two-dimensional code;
the segmentation module 706' is configured to segment the user data to obtain the user sub data and sequence information of the user sub data;
a first filling module 704' for filling the user subdata and the sequence information thereof into a data area according to a first predetermined encoding and decoding rule for each user subdata to obtain a primitive two-dimensional code;
the second filling module 705' is configured to repeatedly fill the primitive two-dimensional code into the graph filling area, so as to obtain a two-dimensional code graph.
In a further embodiment, the input module 701 ' is further configured to receive encoded function data input by a user or determine the encoded function data according to the user data, the primitive two-dimensional code model obtained by the encoding module 703 ' further includes a function area, and the first filling module 704 ' is configured to, for each piece of user data, fill the encoded function data and sequence information of the user data into the function area according to a second predetermined encoding and decoding rule, and fill the user data into the data area according to the encoding and decoding rule corresponding to the encoded function data, so as to obtain the primitive two-dimensional code.
In an embodiment of the present application, a two-dimensional code identification method is further provided, as shown in fig. 8A, where the two-dimensional code obtained by the encoding method shown in fig. 4A includes:
step 801, collecting a two-dimensional code image;
step 802, searching a positioning area in the two-dimensional code image, and positioning the range and the direction of a data area in a primitive two-dimensional code according to one or more searched positioning areas;
step 803, decode each symbol in the data region according to a first predetermined coding and decoding rule to obtain user data.
The acquired two-dimensional code image can be a whole two-dimensional code image or a part of two-dimensional code image, and the primitive two-dimensional codes are repeatedly filled, so that the user data can be accurately restored even under the condition of acquiring a part of two-dimensional code image.
In specific implementation, the range and the direction of a data area in the primitive two-dimensional code can be positioned through the positioning area of the single primitive two-dimensional code. Or according to the positioning areas of a plurality of primitive two-dimensional codes, positioning the range and the orientation of the data area in the primitive two-dimensional codes, as shown in fig. 12, the reading program searches a group of adjacent 4 positioning area graphs, and the range and the orientation of one primitive two-dimensional code can be determined through the 4 positioning point graphs.
In an embodiment of the present application, a two-dimensional code identification method is further provided, as shown in fig. 8B, where the two-dimensional code obtained by the encoding method shown in fig. 4B includes:
step 801', collecting a two-dimensional code image;
step 802', searching a positioning area in the two-dimensional code image, and positioning the range and the direction of a data area in a primitive two-dimensional code according to one or more searched positioning areas;
step 803', according to the first predetermined encoding and decoding rule, decoding each code element in the data area to obtain the user subdata and the sequence information of the user subdata;
step 804 ', determining the number of the elementary two-dimensional codes for storing different user subdata according to the sequence information of the user subdata, and re-executing the step 802 ' and the step 803 ' according to the number of the elementary two-dimensional codes for storing different user subdata until all the user subdata and the sequence information thereof are obtained;
and step 805', combining the user subdata according to the sequence information of the user subdata to obtain user data.
In specific implementation, if the total number of the user sub-data includes N user sub-data, the user sub-data and the sequence information of the user sub-data obtained after decoding in step 803' are: (user subdata 1, order 1/N). From the sequence information 1/N, it can be known that N pieces of user sub-data are included, and at this time, step 802' and the following steps should be executed again until all user sub-data and the sequence information thereof are obtained. And if the user data cannot be obtained, prompting the user to acquire the two-dimensional code image again.
In an embodiment of the present application, a two-dimensional code identification method is further provided, as shown in fig. 9A, where the two-dimensional code obtained by the encoding method shown in fig. 5A includes:
step 901, collecting a two-dimensional code image;
step 902, searching a positioning area in the two-dimensional code image, and positioning the range and the direction of a data area and a functional area in a primitive two-dimensional code according to one or more searched positioning areas;
step 903, decoding each code element in the function region according to a second preset coding and decoding rule to obtain coding function data;
step 904, decoding each code element in the data region according to the coding and decoding rules corresponding to the coding function data to obtain the user data.
In one embodiment, the process of obtaining the user data by decoding each symbol in the data region according to the coding and decoding rule corresponding to the coding function data includes: decoding the user data according to the coding and decoding rules corresponding to the version information to obtain binary data; and processing the binary data according to the error correction grade and the mask information to obtain user data.
In an embodiment of the present application, a two-dimensional code identification method is further provided, as shown in fig. 9B, where the two-dimensional code obtained by the encoding method shown in fig. 5B includes:
step 901', collecting a two-dimensional code image;
step 902', searching a positioning area in a two-dimensional code image, and positioning the range and the direction of a data area and a functional area in a primitive two-dimensional code according to one or more searched positioning areas;
903', according to the second preset encoding and decoding rule, decoding each code element in the function region to obtain the sequence information of the encoding function data and the user subdata;
step 904', decoding each code element in the data area according to the coding and decoding rules corresponding to the coding function data to obtain the user subdata;
step 905 ', determining the number of the primitive two-dimensional codes for storing different user subdata according to the sequence information of the user subdata, and re-executing the step 902' and the following steps according to the number of the primitive two-dimensional codes for storing different user subdata until all the user subdata and the sequence information thereof are obtained;
and 906', combining the user subdata according to the sequence information of the user subdata to obtain the user data.
In specific implementation, after searching for the positioning area in the two-dimensional code image, the method further includes: and carrying out graph correction and transformation on the two-dimensional code graph by using the positioning area in the two-dimensional code image.
Based on the same inventive concept, the present application further provides a two-dimensional code recognition apparatus corresponding to the above-mentioned fig. 8A, 8B, 9A and 9B, as shown in fig. 10A, 10B, 11A and 11B, since the principle of the recognition apparatus to solve the problem is similar to the above-mentioned encoding method, the implementation of the apparatus can refer to the above-mentioned encoding method, and the repeated details are not repeated.
Specifically, in an embodiment of the present application, as shown in fig. 10A, the two-dimensional code recognition apparatus includes:
the acquisition module 1001 is used for acquiring a two-dimensional code image;
the positioning module 1002 is configured to search for a positioning area in the two-dimensional code image, and position a range and an orientation of a data area in a primitive two-dimensional code according to one or more searched positioning areas;
the identifying module 1003 is configured to decode each symbol in the data region according to a first predetermined encoding and decoding rule, so as to obtain user data.
In an embodiment of the present application, as shown in fig. 10B, the two-dimensional code recognition apparatus includes:
the acquisition module 1001' is used for acquiring a two-dimensional code image;
the positioning module 1002' is used for searching a positioning area in the two-dimensional code image, and positioning the range and the direction of a data area in a primitive two-dimensional code according to one or more searched positioning areas;
an identifying module 1003' for decoding each code element in the data area according to a first predetermined encoding and decoding rule to obtain the user sub-data and the sequence information of the user sub-data;
the analyzing module 1004 ' is used for determining the number of the primitive two-dimensional codes for storing different user subdata according to the sequence information of the user subdata, and restarting the positioning module 1002 ' and the identifying module 1003 ' according to the number of the primitive two-dimensional codes for storing different user subdata until all the user subdata and the sequence information thereof are obtained;
and the combination module 1005' is used for combining the user subdata according to the sequence information of the user subdata to obtain the user data.
In an embodiment of the present application, as shown in fig. 11A, the two-dimensional code recognition apparatus includes:
the acquisition module 1101 is used for acquiring a two-dimensional code image;
the positioning module 1102 is configured to search a positioning area in the two-dimensional code image, and position a range and an orientation of a data area and a functional area in a primitive two-dimensional code according to one or more searched positioning areas;
a first identifying module 1103, configured to decode each symbol in the functional region according to a second predetermined encoding and decoding rule to obtain encoded functional data;
and a second identifying module 1104, configured to decode each symbol in the data region according to a coding/decoding rule corresponding to the coding function data to obtain user data.
In an embodiment of the present application, as shown in fig. 11B, the two-dimensional code recognition apparatus includes:
the acquisition module 1101' is used for acquiring a two-dimensional code image;
the positioning module 1102' is used for searching a positioning area in the two-dimensional code image, and positioning the range and the direction of a data area and a functional area in the elementary two-dimensional code according to one or more searched positioning areas;
a first identifying module 1103' for decoding each code element in the functional region according to a second predetermined encoding and decoding rule to obtain the sequence information of the encoded functional data and the user sub-data;
the second identification module 1104' is used for decoding each code element in the data area according to the coding and decoding rule corresponding to the coding function data to obtain the user subdata;
the analyzing module 1105 'is configured to determine the number of primitive two-dimensional codes storing different pieces of user sub-data according to the sequence information of the user sub-data, and restart the positioning module 1102', the first identifying module 1103 'and the second identifying module 1104' according to the number of primitive two-dimensional codes storing different pieces of user sub-data until all pieces of user sub-data and sequence information thereof are obtained;
the combining module 1106' is configured to combine the user sub-data according to the sequence information of the user sub-data to obtain user data.
The two-dimensional code provided by the application can break through the limitation of the traditional two-dimensional code on the appearance shape by storing the user data in the primitive two-dimensional code and repeatedly filling the primitive two-dimensional code to the two-dimensional code pattern filling area, and provides more abundant, flexible and changeable appearance patterns. The two-dimension code can be fused with the product graphic design, so that the two-dimension code is hidden in the product graphic design. Due to the repeated filling mechanism, the obtained two-dimensional code has good data redundancy characteristic, and the fault-tolerant performance and the reading success rate of the two-dimensional code can be further improved.
As shown in fig. 13, which is a schematic structural diagram of a computer device according to an embodiment of the present application, in particular, the computer device 1302 may include one or more processors 1304, such as one or more Central Processing Units (CPUs), and each processing unit may implement one or more hardware threads. The computer device 1302 may further include any memory 1306, configured to store a computer program, where when the processor executes the computer program, the two-dimensional code encoding method according to any one of the foregoing embodiments or the two-dimensional code identification method according to any one of the foregoing embodiments is implemented, and when the two-dimensional code encoding method and the two-dimensional code identification method are implemented, different computer devices may implement the two-dimensional code encoding method and the two-dimensional code identification method. For example, without limitation, memory 1306 may include any one or more of the following in combination: any type of RAM, any type of ROM, flash memory devices, hard disks, optical disks, etc. More generally, any memory may use any technology to store information. Further, any memory may provide volatile or non-volatile retention of information. Further, any memory may represent fixed or removable components of computer device 1302. In one case, when processor 1304 executes associated instructions that are stored in any memory or combination of memories, computer device 1302 may perform any of the operations of the associated instructions. The computer device 1302 also includes one or more drive mechanisms 1308, such as a hard disk drive mechanism, an optical drive mechanism, etc., for interacting with any memory.
Computer device 1302 may also include an input/output module 1310(I/O) for receiving various inputs (via input device 1312) and for providing various outputs (via output device 1314)). One particular output mechanism may include a presentation device 1316 and an associated Graphical User Interface (GUI) 1318. In other embodiments, input/output module 1310(I/O), input device 1312, and output device 1314 may also not be included, as only one computer device in a network. Computer device 1302 may also include one or more network interfaces 1320 for exchanging data with other devices via one or more communication links 1322. One or more communication buses 1324 couple the above-described components together.
Communication link 1322 may be implemented in any manner, e.g., via a local area network, a wide area network (e.g., the Internet), a point-to-point connection, etc., or any combination thereof. The communication link 1322 may comprise any combination of hardwired links, wireless links, routers, gateway functions, name servers, etc., governed by any protocol or combination of protocols.
In an embodiment of the present application, a computer readable instruction is further provided, where when the processor executes the instruction, the program causes the processor to execute the two-dimensional code encoding method shown in one of fig. 4A, fig. 4B, fig. 5A, and fig. 5B.
In an embodiment of the present application, a computer readable instruction is further provided, wherein when the processor executes the instruction, the program causes the processor to execute the two-dimensional code recognition method shown in one of fig. 8A, fig. 8B, fig. 9A, and fig. 9B.
As will be appreciated by one skilled in the art, method 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 embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams 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.
The above description is only for the purpose of illustrating the present disclosure, and any person skilled in the art can modify and change the above embodiments without departing from the spirit and scope of the present disclosure. Therefore, the protection scope of the claims of the present application shall be subject to the claims.