Disclosure of Invention
The invention aims to provide a two-dimensional code generation method, a two-dimensional code generation device and a two-dimensional code. Even if any one or any several of the positioning points in the two-dimensional code are damaged, the identification of the two-dimensional code is not hindered.
In order to achieve the above object, as an aspect of the present invention, there is provided a method for generating a two-dimensional code, wherein the method comprises:
determining the positions of a plurality of positioning points, wherein the plurality of positioning points comprise a central positioning point and a plurality of peripheral positioning points, the plurality of peripheral positioning points are uniformly distributed on the circumference of the same circle, and the central positioning point is positioned at the center of the circle;
a central positioning graph is arranged at the central positioning point, the central positioning graph limits an included angle, and the included angle points to one of the peripheral positioning points;
setting a peripheral positioning graph at the peripheral positioning point;
determining the positions of a plurality of data lines, wherein each data line corresponds to one peripheral positioning point, and the data lines are connected with the peripheral positioning points and the central positioning point corresponding to the data lines;
and respectively arranging a graphic data graph on each data line to obtain the two-dimensional code.
Preferably, the two-dimensional code includes eight peripheral positioning points, each peripheral positioning graph includes three pixels, and the arrangement of the three pixels in the eight peripheral positioning points is different from each other.
Preferably, the data pattern on each data line includes eight pixels, the data pattern includes four groups of main data and four groups of backup data, each group of main data corresponds to one group of backup data, and the main data and the backup data have the same content.
As a second aspect of the present invention, there is provided a two-dimensional code, wherein the two-dimensional code includes:
the peripheral positioning patterns are distributed on the circumference of the same circle;
the central positioning graph is positioned at the center of the circle and limits an included angle, and the included angle points to one of the peripheral positioning points;
the data lines are connected with the peripheral positioning patterns corresponding to the data lines and the central positioning patterns.
Preferably, the two-dimensional code includes eight peripheral positioning points, each peripheral positioning graph includes three pixels, and the arrangement of the three pixels in the eight peripheral positioning points is different from each other.
Preferably, the data pattern on each data line includes eight pixels, the data pattern includes four groups of main data and four groups of backup data, each group of main data corresponds to one group of backup data, and the main data and the backup data have the same content.
As a third aspect of the present invention, there is provided a two-dimensional code generation device, comprising:
the positioning point determining module is used for determining the positions of a plurality of positioning points, wherein the positioning points comprise a central positioning point and a plurality of peripheral positioning points, the peripheral positioning points are uniformly distributed on the circumference of the same circle, and the central positioning point is positioned at the center of the circle;
the positioning graph setting module is used for setting a central positioning graph at the central positioning point, the central positioning graph defines an included angle, the included angle points to one of the peripheral positioning points, and the positioning graph setting module is also used for setting a peripheral positioning graph at the peripheral positioning point;
the data line determining module is used for determining the positions of a plurality of data lines, each data line corresponds to one peripheral positioning point, and the data lines are connected with the peripheral positioning points and the central positioning points corresponding to the data lines;
and the data graph setting module is used for setting a graph data graph on each data line respectively so as to obtain the two-dimensional code.
Preferably, the two-dimensional code includes eight peripheral positioning points, each peripheral positioning graph includes three pixels, and the arrangement of the three pixels in the eight peripheral positioning points is different from each other.
Preferably, the data pattern on each data line includes eight pixels, the data pattern includes four groups of main data and four groups of backup data, each group of main data corresponds to one group of backup data, and the main data and the backup data have the same content.
In the two-dimensional code generation method provided by the invention, a plurality of peripheral positioning graphs are arranged on the circumference, and because the positioning graphs are uniformly distributed along the circumference, even if one or more positioning graphs are damaged, the position information of the damaged positioning graph can be determined according to other positioning graphs, and then the data graph corresponding to the positioning graph is obtained.
Even if all the peripheral positioning graphs are damaged, the position of one peripheral positioning graph can still be determined according to the central positioning graph, and then the positions of the other peripheral positioning graphs are pushed out.
When the two-dimensional code generated by the two-dimensional code generation method provided by the invention is identified, any one or any several of the peripheral positioning patterns is damaged or stained, and the position of the damaged or stained positioning pattern can be determined by using the positioning pattern which is not damaged, so that the position of each data line can be determined, and further the information in the two-dimensional code can be identified.
In other words, as long as there is an undamaged positioning image, the two-dimensional code can be positioned and data read.
Detailed Description
The following detailed description of embodiments of the invention refers to the accompanying drawings. It should be understood that the detailed description and specific examples, while indicating the present invention, are given by way of illustration and explanation only, not limitation.
As an aspect of the present invention, there is provided a method for generating a two-dimensional code, where as shown in fig. 1, the method includes:
in step S110, determining positions of a plurality of positioning points, where the plurality of positioning points include a central positioning point and a plurality of peripheral positioning points, the plurality of peripheral positioning points are uniformly distributed on a circumference of a same circle, and the central positioning point is located at a center of the circle;
in step S120, a central positioning graph is set at the central positioning point, the central positioning graph defines an included angle, and the included angle points to one of the peripheral positioning points;
in step S130, a peripheral positioning graph is set at the peripheral positioning points;
in step S140, determining positions of a plurality of data lines, where each data line corresponds to one peripheral positioning point, and the data line connects the peripheral positioning point and the central positioning point corresponding to the data line;
in step S150, a graphic data pattern is respectively disposed on each of the data lines to obtain the two-dimensional code.
In the two-dimensional code generation method provided by the invention, a plurality of peripheral positioning graphs are arranged on the circumference, and because the positioning graphs are uniformly distributed along the circumference, even if one or more positioning graphs are damaged, the position information of the damaged positioning graph can be determined according to other positioning graphs, and then the data graph corresponding to the positioning graph is obtained.
Even if all the peripheral positioning graphs are damaged, the position of one peripheral positioning graph can still be determined according to the central positioning graph, and then the positions of the other peripheral positioning graphs are pushed out.
When the two-dimensional code generated by the two-dimensional code generation method provided by the invention is identified, any one or any several of the peripheral positioning patterns is damaged or stained, and the position of the damaged or stained positioning pattern can be determined by using the positioning pattern which is not damaged, so that the position of each data line can be determined, and further the information in the two-dimensional code can be identified.
In other words, as long as there is an undamaged positioning pattern, the two-dimensional code can be positioned and data read.
Different from the situation that the two-dimensional code is prevented from being damaged as far as possible in the prior art, the two-dimensional code generated by the two-dimensional code generation method provided by the application has no requirement on the setting position of the two-dimensional code, and even if the two-dimensional code is set at a position easy to wear, the information of the two-dimensional code can still be accurately identified.
For example, the two-dimensional code may be provided on a shared bicycle. Because even wear and tear still can discern the two-dimensional code, consequently, can with the two-dimensional code sets up in obvious position to be convenient for user's scanning, improve user experience.
The graphical two-dimensional code shown in fig. 2 can be generated by using the method for generating the two-dimensional code provided by the invention.
In this embodiment, the two-dimensional code includes eight peripheral anchor points, which are peripheral anchor point P1, peripheral anchor point P2, peripheral anchor point P3, peripheral anchor point P4, peripheral anchor point P5, peripheral anchor point P6, peripheral anchor point P7, and peripheral anchor point P8. As shown in fig. 2, center positioning point P0 is located at the center of a circle, and the eight data lines are data line D1 connecting peripheral positioning point P1 and center positioning point P0, data line D2 connecting peripheral positioning point P2 and center positioning point P0, data line D3 connecting peripheral positioning point P3 and center positioning point P0, data line D4 connecting peripheral positioning point P4 and center positioning point P0, data line D5 connecting peripheral positioning point P5 and center positioning point P0, data line D6 connecting peripheral positioning point P6 and center positioning point P0, data line D7 connecting peripheral positioning point P7 and center positioning point P0, and data line D8 connecting peripheral positioning point P8 and center positioning point P0, respectively.
In the embodiment shown in FIG. 2, the center graphic at center location point P0 includes two sectors that share a horizontal diameter, and thus, the location of peripheral location point P1 can be determined from the center graphic.
As described above, the two-dimensional code includes eight peripheral anchor points. In order to ensure that the positioning patterns of the eight positioning points are different from each other, it is preferable that each of the peripheral positioning patterns includes three pixels, and the arrangement of the three pixels in the eight peripheral positioning points is different from each other, as shown in fig. 2.
Accordingly, the data pattern on each of the data lines includes eight pixels. In other words, each data line is binary pixel data. 00000000 is shown in fig. 3a and 00100101 is shown in fig. 3 b. The data graph comprises four groups of main data and four groups of backup data, each group of main data corresponds to one group of backup data, and the contents of the main data and the backup data are the same. In the specific embodiment shown in fig. 2, main data is disposed on the data line D1, the data line D2, the data line D3, and the data line D4. Backup data is provided on the data line D5, the data line D6, the data line D7, and the data line D8. The main data on the data line D1 is the same as the backup data on the data line D5, the main data on the data line D2 is the same as the backup data on the data line D6, the main data on the data line D3 is the same as the backup data on the data line D7, and the main data on the data line D4 is the same as the backup data on the data line D8.
When the two-dimensional code comprises eight peripheral positioning graphs and eight data graphs, the amount of carried data information is limited, so that the two-dimensional code is suitable for being used as an identity recognition graph. For example, the two-dimensional code may be utilized as an identification code of the shared bicycle. And the number of releases of the shared bicycle is within 1 hundred million, the two-bit code is printed on a girder of the shared bicycle, and each data graph has a data volume of 8 bytes and represents the ID of the shared bicycle. The two-dimensional code may represent numbers from 0 to 4294967295.
As another aspect of the present invention, there is provided a two-dimensional code generated by the above two-dimensional code generation method, wherein the two-dimensional code includes:
the peripheral positioning patterns are distributed on the circumference of the same circle;
the central positioning graph is positioned at the center of the circle and defines an included angle, and the included angle points to one of the peripheral positioning graphs;
the data lines are all the diameter of the circle, and two different peripheral positioning patterns are respectively arranged at two ends of each data line.
The two-dimensional code is generated by the two-dimensional code generation method provided by the invention, as described above, the plurality of peripheral positioning patterns are arranged on the circumference, and because the plurality of positioning patterns are uniformly distributed along the circumference, even if one or more positioning patterns are damaged, the position information of the damaged positioning pattern can be determined according to other positioning patterns, so as to obtain the data pattern corresponding to the positioning pattern.
Even if all the peripheral positioning graphs are damaged, the position of one peripheral positioning graph can still be determined according to the central positioning graph, and then the positions of the other peripheral positioning graphs are pushed out.
Different from the situation that the two-dimensional code is prevented from being damaged as far as possible in the prior art, the two-dimensional code generated by the two-dimensional code generation method provided by the application has no requirement on the setting position of the two-dimensional code, and even if the two-dimensional code is set at a position easy to wear, the information of the two-dimensional code can still be accurately identified.
For example, the two-dimensional code may be provided on a shared bicycle. Because even wear and tear still can discern the two-dimensional code, consequently, can with the two-dimensional code sets up in obvious position to be convenient for user's scanning, improve user experience.
As a specific implementation manner, the two-dimensional code includes eight peripheral positioning patterns, each peripheral positioning pattern includes three pixels, and arrangement manners of the three pixels in the eight peripheral positioning patterns are different from each other.
As shown in fig. 2, each of the peripheral positioning patterns includes three pixels, and the arrangement of the three pixels in the eight peripheral positioning patterns is different from each other.
Accordingly, the data pattern on each of the data lines includes eight pixels. In other words, each data line is binary pixel data. 00000000 is shown in fig. 3a and 00100101 is shown in fig. 3 b.
When the two-dimensional code comprises eight peripheral positioning graphs and eight data graphs, the amount of carried data information is limited, so that the two-dimensional code is suitable for being used as an identity recognition graph.
When a user scans the two-dimensional code, firstly, the two-dimensional code is subjected to graphic correction, and the non-perfect-circle two-dimensional code shot by the camera is corrected into a perfect circle. Then, the positions of the peripheral positioning patterns are determined, and data information is further read.
As a third aspect of the present invention, there is provided a two-dimensional code generating apparatus, wherein, as shown in fig. 4, the two-dimensional code generating apparatus includes a positioningpoint determining module 410, a positioningpattern setting module 420, a dataline determining module 430, and a datapattern setting module 440. The two-dimensional code generation device provided by the invention is used for executing the two-dimensional code generation method provided by the invention.
Specifically, the positioningpoint determining module 410 is configured to perform step S110, that is, the positioningpoint determining module 410 is configured to determine positions of a plurality of positioning points, where the plurality of positioning points include a central positioning point and a plurality of peripheral positioning points, the plurality of peripheral positioning points are uniformly distributed on a circumference of a same circle, and the central positioning point is located at a center of the circle.
The positioningpattern setting module 420 is configured to perform the steps S120 and S130, that is, the positioningpattern determining module 420 is configured to set a central positioning pattern at the central positioning point, the central positioning pattern defining an included angle, the included angle pointing to one of the peripheral positioning points, and the positioningpattern setting module 420 is further configured to set a peripheral positioning pattern at the peripheral positioning point.
The data line determiningmodule 430 is configured to execute step S140, that is, the data line determining module 330 is configured to determine positions of a plurality of data lines, where each data line corresponds to one peripheral positioning point, and the data line connects the peripheral positioning point and the central positioning point corresponding to the data line.
The datapattern setting module 440 is configured to execute step S150, that is, the datapattern setting module 440 is configured to set a pattern data pattern on each data line, respectively, so as to obtain the two-dimensional code.
The two-dimensional code generating device provided by the present invention is used for executing the two-dimensional code generating method provided by the present invention, and the working principle and the beneficial effects of the two-dimensional code generating method have been described in detail above, and are not described herein again.
As described above, as a specific embodiment, the two-dimensional code includes eight peripheral positioning points, each peripheral positioning graph includes three pixels, and the arrangement of the three pixels in the eight peripheral positioning points is different from each other.
Correspondingly, the data pattern on each data line comprises eight pixels, the data pattern comprises four groups of main data and four groups of backup data, each group of main data corresponds to one group of backup data, and the main data and the backup data have the same content.
It will be understood that the above embodiments are merely exemplary embodiments taken to illustrate the principles of the present invention, which is not limited thereto. It will be apparent to those skilled in the art that various modifications and improvements can be made without departing from the spirit and substance of the invention, and these modifications and improvements are also considered to be within the scope of the invention.