A two-dimensional code recognition method, device, electronic device and storage medium

By identifying the real locator in the QR code image and using geometric features to find the remaining locator, the problem of identification failure caused by the destruction of the QR code locator is solved, the recognition accuracy and success rate are improved, and the operation of electronic devices is reduced pressure.

CN114781417BActive Publication Date: 2024-11-15TP-LINK
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210377276.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-12
Publication Date
2024-11-15
Estimated Expiration
2042-04-12

AI Technical Summary

Technical Problem

The prior art is difficult to accurately identify the locator of the QR code when it is defiled, resulting in the identification failure and the error correction mechanism cannot solve such problems.

Method used

The real locator is identified by preset color feature ratio. If the number is not complete, the geometric features in the image are determined, the suspected locator is found, and the remaining real locator is determined in the geometric features, and finally the identification is based on all real locators.

Benefits of technology

It improves the accuracy and recognition success rate of QR code locator recognition, reduces the computing pressure of electronic devices, and ensures that all real locators are recognized in a short time.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114781417B_ABST
    Figure CN114781417B_ABST
Patent Text Reader

Abstract

The present application discloses a two-dimensional code recognition method, a two-dimensional code recognition device, an electronic device, and a computer-readable storage medium. The method comprises: according to a preset color feature ratio, identifying a real locator in the image of the two-dimensional code to be recognized; if the number of the recognized real locators is incomplete, determining the geometric features of the two-dimensional code to be recognized in the image; according to the geometric features, finding at least two suspected locators in the image; determining the remaining real locators among the at least two suspected locators; and recognizing the two-dimensional code to be recognized based on all the real locators. Through the scheme of the present application, the recognition accuracy of the locator of the two-dimensional code can be improved when the locator of the two-dimensional code is defaced, so that the recognition success rate of the two-dimensional code can also be increased.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the technical field of two-dimensional code processing, and in particular, relates to a two-dimensional code recognition method, a two-dimensional code recognition device, an electronic device and a computer-readable storage medium. Background Art

[0002] Nowadays, QR codes have been widely used in production and life. In actual scenarios, QR codes are often contaminated. Although the QR code itself has an error correction mechanism that can tolerate a certain degree of contamination of the coding area, if the QR code's locator is contaminated, it will challenge the QR code recognition algorithm because it cannot recognize the accurate locator, which is a problem that the QR code's error correction mechanism cannot solve. Therefore, how to accurately recognize the QR code when the QR code's locator is contaminated has become a problem that needs to be solved urgently. Summary of the invention

[0003] The present application provides a two-dimensional code recognition method, a two-dimensional code recognition device, an electronic device and a computer-readable storage medium, which can improve the recognition accuracy of the locator of the two-dimensional code when the locator of the two-dimensional code is damaged, so that the recognition success rate of the two-dimensional code can also be increased.

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

[0005] According to a preset color feature ratio, a real locator is identified in the image of the QR code to be identified;

[0006] If the number of the identified real locators is incomplete, determining the geometric features of the to-be-identified two-dimensional code in the image;

[0007] According to the geometric features, at least two suspected locators are found in the image;

[0008] determining the remaining true locator among the at least two suspected locators;

[0009] The above-mentioned two-dimensional code to be identified is identified based on all the above-mentioned real locators.

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

[0011] A first recognition module, used to recognize a real locator in the image of the QR code to be recognized according to a preset color feature ratio;

[0012] A first determination module, configured to determine the geometric features of the to-be-identified two-dimensional code in the image if the number of the identified real locators is incomplete;

[0013] A search module, used to search for at least two suspected locators in the image according to the geometric features;

[0014] A second determination module, configured to determine the remaining real locators among the at least two suspected locators;

[0015] The second recognition module is used to recognize the above-mentioned two-dimensional code to be recognized based on all the above-mentioned real locators.

[0016] In a third aspect, the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method of the first aspect when executing the computer program.

[0017] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method of the first aspect are implemented.

[0018] In a fifth aspect, the present application provides a computer program product, which includes a computer program. When the computer program is executed by one or more processors, it implements the steps of the method of the first aspect.

[0019] Compared with the prior art, the present application has the following beneficial effects: the electronic device first identifies the real locator in the image of the to-be-identified two-dimensional code according to a preset color feature ratio. If the number of the identified real locators is incomplete, the geometric features of the to-be-identified two-dimensional code in the image are determined, and at least two suspected locators are found in the image according to the geometric features. Finally, the remaining real locators are determined among the at least two suspected locators, and the to-be-identified two-dimensional code is identified according to all the obtained real locators. In the above process, when the locator of the two-dimensional code is defiled and the number of identified real locators is insufficient, the electronic device fully considers the geometric features of the two-dimensional code, and infers the remaining real locators according to the geometric features. Since the geometric reasoning has less computational pressure on the electronic device, the electronic device can identify all the real locators in a short time, thereby ensuring the recognition accuracy of the electronic device to the locator, and improving the recognition success rate of the electronic device to the two-dimensional code to a certain extent.

[0020] It can be understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0022] Figure 1 It is a schematic diagram of the implementation flow of the two-dimensional code recognition method provided in the embodiment of the present application;

[0023] Figure 2 is an example diagram of a defaced locator provided in an embodiment of the present application;

[0024] Figure 3 is an example diagram of the farthest point search process provided by an embodiment of the present application;

[0025] Figure 4 is an example diagram of the farthest point found in eight specified directions provided in an embodiment of the present application;

[0026] Figure 5 This is an example diagram of the effect of the two-dimensional code to be identified after preprocessing provided in the embodiment of the present application;

[0027] Figure 6 is an example diagram of boundary tracking provided by an embodiment of the present application;

[0028] Figure 7 is an example diagram of a process for determining a suspected center point provided in an embodiment of the present application;

[0029] Figure 8 is another example diagram of the process of determining a suspected center point provided by an embodiment of the present application;

[0030] Fig. 9 is another example diagram of the process of determining a suspected center point provided in an embodiment of the present application;

[0031] Fig.10 This is an example diagram of a situation where a locator misrecognition occurs, provided in an embodiment of the present application;

[0032] Fig.11 is a structural block diagram of a two-dimensional code recognition device provided in an embodiment of the present application;

[0033] Fig.12 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0034] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.

[0035] In order to illustrate the technical solution proposed in this application, a specific embodiment is provided below for illustration.

[0036] The two-dimensional code recognition method provided in the embodiments of the present application is applied to electronic devices. As an example only, the electronic device may be an electronic device with a shooting function, such as a smart phone, a tablet computer or a notebook. It is understood that for these electronic devices, when the camera is turned on to enable the two-dimensional code scanning function, the two-dimensional code recognition method proposed in the embodiments of the present application can be executed. Of course, the electronic device may also be an electronic device without a shooting function, such as a desktop computer or a server. It is understood that for these electronic devices, after receiving the image of the two-dimensional code to be identified sent by other devices, the two-dimensional code recognition method proposed in the embodiments of the present application can be executed based on the image of the two-dimensional code to be identified. That is, in the embodiments of the present application, the execution subject of the two-dimensional code recognition method is not limited.

[0037] See also Figure 1 , the implementation process of the two-dimensional code recognition method is described in detail as follows:

[0038] Step 101, identifying a real locator in an image of a QR code to be identified according to a preset color feature ratio.

[0039] The two-dimensional code to be identified in the embodiment of the present application specifically refers to a matrix two-dimensional code (QR two-dimensional code). For a matrix two-dimensional code, there is a locator in the upper left corner, lower left corner and upper right corner respectively, and the locator strictly follows the following color feature ratio: the ratio of the black and white widths in the horizontal, vertical and 45-degree diagonal directions all meet 1:1:3:1:1. Based on this, a search can be performed in the image of the two-dimensional code to be identified according to the color feature ratio to identify the real locator.

[0040] Step 102: If the number of recognized real locators is incomplete, the geometric features of the two-dimensional code to be recognized in the image are determined.

[0041] As can be seen from the above description, normally, there should be three locators in the two-dimensional code to be identified. However, considering the actual application scenario, the locator may be damaged, resulting in the locator failing to meet the color feature ratio due to the damage, and thus resulting in the failure to identify the damaged locator in step 101. In other words, the number of real locators identified may be less than three. In this case, the geometric features of the two-dimensional code to be identified in the image can be found, and the geometric features include: the center point of the real locator; and the vertices of the two-dimensional code to be identified or the vertices of the central black block of the real locator.

[0042] It should be noted that the embodiment of the present application mainly focuses on the situation where real locators are identified but the number of the real locators is insufficient. That is, if one or two real locators are identified through step 101, the remaining real locators can be found through the two-dimensional code recognition method proposed in the embodiment of the present application; if no real locators are identified through step 101, the remaining real locators cannot be found through the two-dimensional code recognition method.

[0043] Of course, if, through step 101 , the electronic device has identified all the real locators of the to-be-identified two-dimensional code (three real locators in total), step 105 can be directly executed.

[0044] See also Figure 2 , Figure 2 An example of a locator that is defaced in multiple directions is given.

[0045] Step 103: Find at least two suspected locators in the image based on the geometric features.

[0046] The geometric features of the QR code to be identified in the image actually express the position of the identified real locator in the image to a certain extent. As described above, for a matrix QR code, the position of its locator in the matrix QR code is fixed. Therefore, the possible positions of the remaining real locators in the image can be found based on the geometric features, and the corresponding locator areas can be delineated based on this, and the patterns expressed by each locator area are used as suspected locators.

[0047] Step 104: determining the remaining real locators among the at least two suspected locators.

[0048] Under normal circumstances, the at least two suspected locators found usually contain the remaining real locators. Based on this, the electronic device can verify each suspected locator by other methods other than the color feature ratio to determine the remaining real locator. As an example only, the other method can be a template matching method; or the other method can also be a prediction (classification) method based on a deep learning model, which is not limited here.

[0049] Taking template matching as an example, the electronic device can determine the remaining real locators as follows:

[0050] Calculate the template matching degree between the matching template and each suspected locator; determine the remaining real locators in descending order of template matching degree, specifically: if a real locator is identified through step 101, the first two suspected locators with the highest template matching degree are determined as real locators, thereby finding three real locators, and at this point, the real locators have been completely identified; if two real locators are identified through step 101, the only suspected locator with the highest template matching degree is determined as the real locator, thereby finding three real locators, and at this point, the real locators have been completely identified.

[0051] It can be understood that the matching template may be a preset locator pattern; or, the matching template may be a real locator identified in step 101, and the method for obtaining the matching template is not limited herein.

[0052] It can be understood that, considering that the position of the determined suspected locator may deviate, a diamond search method can be used when calculating the template matching degree between the matching template and each suspected locator to compensate for possible position deviations. The diamond search method will not be described in detail here.

[0053] Step 105: Identify the QR code to be identified based on all real locators.

[0054] As described above, a QR code has three locators. It is understandable that there are multiple ways to identify "all real locators" here: including the case where three real locators are directly identified through step 101, and the case where three real locators are identified through steps 101-104. That is, as long as the electronic device can find all the real locators in the QR code to be identified (find the complete number of real locators), this step can be triggered for execution. Based on all the real locators currently found (a total of three real locators), the electronic device can identify the QR code to be identified to obtain the information carried by the QR code to be identified.

[0055] In some embodiments, when one real locator is identified, the geometric features determined by the electronic device may be: the center point of the real locator and the vertices of the QR code to be identified. When two real locators are identified, the geometric features determined by the electronic device may be: the center point of each real locator and the vertices of the central black block of each real locator.

[0056] When the electronic device recognizes the real locator, the coordinates of the center point of the real locator can be determined. That is, when the electronic device recognizes the real locator, the center point of the real locator is known to the electronic device.

[0057] Since the two-dimensional code to be identified and the central black block are actually square, the vertices of the two-dimensional code to be identified and the vertices of the central black block of the real locator can be obtained through the following process:

[0058] A1. Find the farthest points of the boundary of the figure whose vertex is to be determined in at least four specified directions;

[0059] It can be understood that, when one real locator is identified, the figure with the vertex to be determined refers to the QR code to be identified; when two real locators are identified, the figure with the vertex to be determined refers to the central black block of any of the identified real locators. That is, the concept of the figure with the vertex to be determined is introduced here for the convenience of explanation. In fact, according to different application scenarios, it refers to the central black block of the QR code to be identified or the real locator.

[0060] The electronic device may first perform boundary tracking on the graphics of the vertex to be determined, and then find the farthest points in at least four specified directions on the tracked boundaries. As an example only, the specified direction may be vertically upward (referred to as upward), vertically downward (referred to as downward), horizontally to the left (referred to as left), and horizontally to the right (referred to as right). Considering that the two-dimensional code to be identified may be tilted in the image, the specified direction may be increased to the eight directions of upward, downward, left, right, 45° upward relative to the horizontal left direction (referred to as the upper left), 45° downward relative to the horizontal left direction (referred to as the lower left), 45° upward relative to the horizontal right direction (referred to as the upper right), and 45° downward relative to the horizontal right direction (referred to as the lower right). It can be understood that the horizontal in the above description refers to the direction parallel to the x-axis of the image coordinate system; the vertical in the above description refers to the direction parallel to the y-axis of the image coordinate system; wherein the origin of the image coordinate system is the upper left vertex of the image.

[0061] Specifically, the farthest points in different directions can be determined by the coordinates of each point on the boundary in the image coordinate system, and the determination method is described in detail as follows:

[0062] For the upward direction: the point on the boundary with the smallest ordinate value is determined as the farthest point in this direction.

[0063] For the downward direction: the point with the largest ordinate value on the boundary is determined as the farthest point in that direction.

[0064] For the left direction: the point on the boundary with the smallest horizontal coordinate value is determined as the farthest point in this direction.

[0065] For the right direction: the point with the largest horizontal coordinate value on the boundary is determined as the farthest point in this direction.

[0066] For the upper left direction: the point on the boundary with the smallest sum of the ordinate value and the abscissa value is determined as the farthest point in this direction.

[0067] For the lower left direction: the point on the boundary with the largest difference between the ordinate value and the abscissa value (ie, yx) is determined as the farthest point in that direction.

[0068] For the upper right direction: the point on the boundary with the largest difference between the horizontal coordinate value and the vertical coordinate value (ie, xy) is determined as the farthest point in that direction.

[0069] For the lower right direction: the point on the boundary with the largest sum of the ordinate value and the abscissa value is determined as the farthest point in this direction.

[0070] In some application scenarios, more than three farthest points may be found in a certain direction through the above determination method. To reduce the complexity of subsequent data processing, the three farthest points in this direction may be filtered, specifically:

[0071] Generally speaking, the three or more farthest points must be on the same straight line. Based on this, after connecting the three or more farthest points, a line segment can be obtained. Only the endpoints of the line segment are retained as the final farthest points in this direction, and the rest of the points are discarded, so that only two farthest points are retained in this direction.

[0072] For example, through the method of determining the farthest point described above, it is found that the four points P1, P2, P3 and P4 in the upper left direction all satisfy the minimum sum of the ordinate value and the abscissa value, then these four points must be located on the straight line y=-x+k, k is the minimum value of the sum of the ordinate value and the abscissa value. Connect P1, P2, P3 and P4 to obtain a line segment, where P1 is the endpoint of the line segment, P4 is the other endpoint of the line segment, and P2 and P3 are both non-endpoint points on the line segment. Then the electronic device can discard P2 and P3, and only retain P1 and P4 as the farthest points in the upper left direction.

[0073] It can be understood that if only one or two farthest points are found in a certain direction through the method for determining the farthest point described above, there is no need to filter the farthest points in this direction.

[0074] Thus, at most two farthest points can be obtained in each direction. When eight specified directions are set, the electronic device can obtain at most sixteen farthest points. Of course, at least one farthest point can be obtained in each direction. When eight specified directions are set, the electronic device can obtain at least eight farthest points.

[0075] See also Figure 3 , Figure 3 An example of the process of finding the farthest point is given. It should be noted that Figure 3 In order to highlight the farthest point, the farthest point is shown as a small gray dot. In fact, each farthest point should be a pixel point.

[0076] A2. Calculate the distance between the farthest points and determine the two farthest points as the vertices of the figure.

[0077] Considering that in any case, the figure is a square, and the vertices of a square have the following characteristics: the vertices at the diagonal angles are the farthest apart, based on this, the electronic device can start from this characteristic and find the two vertices at the diagonal angles. To find the two vertices at the diagonal angles, the electronic device can calculate the distance between the farthest points, and then determine the two farthest points with the farthest distance calculated as the two vertices of the figure. So far, two vertices have been found in the image, and only the other two vertices have not been found.

[0078] A3. On both sides of the designated line, the farthest points farthest from the designated line are respectively determined as vertices of the figure, wherein the designated line is: a line connecting the two farthest points at the farthest distance.

[0079] Connect the two farthest points, that is, the two vertices determined in step A2, to obtain a line. On either side of the line, if there is only one farthest point on that side, the farthest point is the vertex; if there are more than two farthest points on that side, the distances from the two or more farthest points on that side to the designated line can be calculated, and the farthest point farthest from the designated line can be determined as a vertex of the image. Through the above process, the remaining two vertices can be found by searching on both sides of the line, and the two vertices are on different sides of the line.

[0080] For ease of understanding, steps A2 and A3 are described below using a specific example:

[0081] See also Figure 4 , Figure 4An example of the farthest point of the border of the central black block found in eight specified directions is given. Figure 4 The farthest points found are P1, P2, ..., P12, and there are 12 farthest points in total.

[0082] By calculating the distance between the farthest points in step A2, it is determined that P4 and P10 are the farthest apart, so P4 and P10 are both determined as vertices. Connect P4 and P10 to obtain the specified line. Figure 4 Shown as gray line segments. Figure 4 It can be seen that P1, P2, P3, P11 and P12 are on one side of the designated line, and P5, P6, P7, P8 and P9 are on the other side of the designated line.

[0083] Through step A3, the distances between P1, P2, P3, P11 and P12 and the designated line are calculated, and it is determined that P1 is the farthest from the designated line, then P1 is the vertex determined on one side of the designated line; similarly, the distances between P5, P6, P7, P8 and P9 and the designated line are calculated, and it is determined that P8 is the farthest from the designated line, then P8 is the vertex determined on the other side of the designated line. So far, all the vertices of the graph have been found, which are: P4, P10, P1 and P8.

[0084] In some embodiments, the number of farthest points found in step A1 may be as many as a dozen, while the actual vertices of the graph are only four. In order to further improve the processing efficiency of steps A2 and A3, the farthest points found in step A1 may be further filtered before step A2, specifically: merge points that are too close. For example, if there is another farthest point within the eight-neighborhood of a farthest point, one of the two farthest points may be randomly retained, and the other farthest point may be discarded and not participate in the subsequent calculations of steps A2 and A3.

[0085] In some embodiments, the boundary tracing process of the graph whose vertices are to be determined may be:

[0086] B1. Search outward from the center point of the figure whose vertex is to be determined in any fixed direction. The first white pixel point found is the first point on the boundary. Based on this, the first white pixel point is determined as the current tracking point.

[0087] It can be understood that before starting to search outward from the center point of the figure whose vertex is to be determined, the fixed direction can be any direction; but once starting to search outward, the fixed direction should not be changed.

[0088] It should be noted that when the figure whose vertices are to be determined is a QR code to be identified, the QR code to be identified needs to be preprocessed before the boundary of the QR code to be identified can be found through steps B1-B3. The preprocessing process is briefly described as follows:

[0089] An enhanced version of the run-length entropy-based image segmentation algorithm is used to segment the QR code to be identified, and the QR code area of ​​the QR code to be identified is blackened.

[0090] See also Figure 5 , Figure 5 An example of the effect of the QR code to be recognized after preprocessing is given.

[0091] B2. Search the eight neighborhoods of the current tracking point in the specified search order, where the first point to be searched in the eight neighborhoods is: the last black pixel searched before determining the current tracking point. The search order can be determined according to the tracking order of the boundary, specifically: if the tracking order is counterclockwise, the search order is clockwise; if the tracking order is clockwise, the search order is counterclockwise.

[0092] B3. The first white pixel found in the eight-neighborhood is determined as the new current tracking point, and the process returns to step B2 until the boundary search is completed; that is, the process stops when the initial current tracking point (that is, the current tracking point determined in step B1) is reached again.

[0093] For easier understanding, see Figure 6 , the following combination Figure 6 The above boundary tracking process is explained as follows:

[0094] Figure 6 The gray dashed arrow in indicates the direction of searching outward from the center point of the figure whose vertex is to be determined (i.e., the fixed direction of step B1). Figure 6 In the fixed direction shown, the first point on the boundary found (that is, the first current tracking point) is point S.

[0095] Search in the eight neighborhoods of point S, where the last black pixel searched before point S is found is point A, so point A is the first point of this search. Assuming that the current tracking order is clockwise, the search order is counterclockwise, that is, starting from point A, traversing the eight neighborhoods of point S counterclockwise. In this way, the first white pixel T in the eight neighborhoods can be found. Point T can be determined as a new point on the boundary. At the same time, the current tracking point is updated, that is, point T is updated to the new current tracking point.

[0096] Search in the eight neighborhoods of point T. Since the last black pixel searched before finding point T is point A, point A is the first point of this search. Starting from point A, traverse the eight neighborhoods of point T counterclockwise, after passing through points A, B and C, find the first white pixel R in the eight neighborhoods. Point R can be determined as a new point on the boundary. At the same time, the current tracking point is updated, that is, point R is updated to the new current tracking point.

[0097] By analogy, when point S is found again, it is known that a circle has been searched. At this point, the boundary tracing of the graph whose vertex is to be determined has been completed.

[0098] It can be understood that in steps B1-B3, since the search order is different from the tracking order, and in the process of searching, the last black pixel point searched before the current tracking point is determined is used as the first point to be searched when searching the eight neighborhoods, which makes the path of searching the next current tracking point first enter the area of ​​the figure of the vertex to be determined. Based on this, in the process of searching out from the inside of the area (that is, the black area), the first white pixel point encountered must be close to the inside of the area (that is, the black area), thereby ensuring that each current tracking point is the outer boundary point of the figure of the vertex to be determined.

[0099] Of course, the traditional boundary tracking method can also be used to obtain the boundary of the figure whose vertices are to be determined. However, since the traditional boundary tracking method usually requires extracting the edge first, compared with the new boundary tracking method (i.e., steps B1-B3) proposed in the embodiment of the present application, the processing flow of the traditional boundary tracking method is more complicated, which may affect the recognition speed and efficiency of the electronic device for the locator of the QR code to a certain extent.

[0100] In some embodiments, as described above, when a real locator is identified, the geometric features determined by the electronic device are the center point of the real locator and the vertex of the QR code to be identified. As can be seen from the above, the real locator is usually near a corner of the QR code to be identified, so the remaining two real locators are near the remaining three corners. Based on this, step 103 can be specifically expressed as follows:

[0101] C1. Determine a first suspected center in the image according to the center point of the real locator, the first two-dimensional code vertex, and the second two-dimensional code vertex.

[0102] The first two-dimensional code vertex refers to: the vertex of the two-dimensional code to be identified that is closest to the center point of the real locator; in other words, the real locator is usually located at a certain corner of the two-dimensional code to be identified, and the first two-dimensional code vertex is the vertex of the two-dimensional code to be identified at that corner. Similarly, the second two-dimensional code vertex refers to: the vertex of the two-dimensional code to be identified that is farthest from the center point of the real locator; in other words, the second two-dimensional code vertex is the vertex of the two-dimensional code to be identified at the diagonal angle of the corner.

[0103] To explain the process of determining the first suspected center point, please refer to Figure 7 . Figure 7 The center point O of the identified real locator and the four vertices A, B, C and D of the two-dimensional code to be identified are shown in FIG. According to the definition given above, A is the first two-dimensional code vertex and C is the second two-dimensional code vertex.

[0104] Depend on Figure 7 It can be seen that when the perspective of the QR code to be identified is not very serious, ABCD is approximately a parallelogram, and at this time: Since the coordinates of the center point O of the real locator, the vertex A of the first two-dimensional code and the vertex C of the second two-dimensional code are all known, we can The coordinates of point Q are determined, and point Q is the first suspected center point.

[0105] Perspective here refers to the effect of near-big and far-small. Severe perspective means that when an electronic device captures a QR code, the lens of the electronic device is close to the QR code and the shooting angle is tilted, resulting in a large position difference (relative difference, that is, division, not subtraction) between different areas of the QR code and the lens, which in turn causes the magnification of the nearby QR code area to be significantly higher than that of the distant QR code area during imaging.

[0106] C2. Determine a second suspected center point and a third suspected center point in the image according to the intersection points of the first straight line, the second straight line, the third straight line and the fourth straight line.

[0107] The first straight line refers to: a straight line passing through the center point of the real locator and parallel to the first side of the two-dimensional code to be identified.

[0108] The second straight line refers to: a straight line passing through the center point of the real locator and parallel to the second side of the two-dimensional code to be identified.

[0109] The third straight line refers to: a straight line passing through the first suspected center point and parallel to the first side of the to-be-identified two-dimensional code.

[0110] The fourth straight line refers to: a straight line passing through the first suspected center point and parallel to the second side of the two-dimensional code to be identified.

[0111] The first side and the second side are two different adjacent sides of the two-dimensional code to be identified. That is, the first side and the second side are two different sides with a common endpoint among the four sides of the two-dimensional code to be identified.

[0112] Still see Figure 7 . Figure 7 The first side in refers to AB (or DC), and the second side refers to AD (or BC). Figure 7 The straight line in l 1 is the first straight line. l 1 passes through the center point O of the real locator and is parallel to AB; straight line l 2 is the second straight line. l 2 passes through the center point O of the real locator and is parallel to AD; straight line l 3 is the third straight line. l 3 passes through the first suspected center point Q and is parallel to AB; straight line l 4 is the fourth straight line. l 4 passes through the first suspected center point Q and is parallel to AD. It can be understood that since the coordinates of points O, Q, A, B, C and D are all known, the linear equations of the first straight line, the second straight line, the third straight line and the fourth straight line can be deduced based on plane geometry knowledge, which will not be repeated here.

[0113] Depend on Figure 7 It can be seen that four intersections are formed based on these four straight lines, two of which are the center point O of the real locator and the first suspected center point Q, and the remaining two intersections P and R are the second suspected center point and the third suspected center point. That is, the intersection point of interest in step C2 refers to the intersection point obtained by the intersection of any two straight lines among the first straight line, the second straight line, the third straight line and the fourth straight line, except the center point of the real locator and the first suspected center point.

[0114] C3. Determine corresponding suspected locators according to the first suspected center point, the second suspected center point and the third suspected center point respectively.

[0115] Among the three suspected center points obtained, two suspected center points should be near the center points of the remaining two real locators. Based on this, three suspected locators can be determined according to the three suspected center points, and the remaining two real locators can be found among the three suspected locators through the subsequent step 104.

[0116] It is understandable that the image of the QR code to be identified may also be distorted to a certain extent. Generally, when the distortion is not large, the QR code to be identified can still be approximately treated as a parallelogram to obtain the corresponding three suspected locators. Although the coordinates of the center points (i.e., the suspected center points) of the three suspected locators found may have errors due to the distortion, the precise positions of the remaining real locators can still be matched when the diamond search is used for template matching in the subsequent process.

[0117] In some embodiments, as described above, when two real locators are identified, the geometric features determined by the electronic device are the center point of the real locator and the vertices of the central black blocks of the two real locators. As can be seen from the above, the real locator is usually near a corner of the two-dimensional code to be identified, so the remaining real locator is near the remaining two corners. In actual application scenarios, when two real locators have been identified, the two real locators may have the following two different positional relationships: adjacent relationship and diagonal relationship. As the name implies, the adjacent relationship means that the corners where the two real locators are located are adjacent; the diagonal relationship means that the corners where the two real locators are located are diagonal. The embodiment of the present application proposes different methods for determining suspected locators for these two different positional relationships. That is, the present application will first determine the positional relationship of the two identified real locators; if the positional relationship is an adjacent relationship, at least two suspected center points are determined in a first manner; conversely, if the positional relationship is a diagonal relationship, at least two suspected center points are determined in a second manner; finally, the corresponding suspected locator is determined according to the at least two suspected center points determined.

[0118] The positional relationship between the two real locators can be determined through the following process:

[0119] D1. Select any real locator and calculate the linear equations of the two diagonals of the real locator based on the vertices of the central black block of the real locator.

[0120] D2. Calculate the equation of the line passing through the two center points based on the coordinates of the center points of the two real locators;

[0121] D3. Based on the linear equations of the two diagonals obtained by D1 and the linear equation of the straight line obtained by D2, calculate the angles between the straight line of D2 and the two diagonals of D1 respectively to obtain two angle values.

[0122] D4. Compare the relatively smaller angle value of the two angle values ​​with a preset angle threshold (for example, 5 degrees). If the relatively smaller angle value is smaller than the angle threshold, it means that the line connecting the center points of the two real locators is approximately parallel to a diagonal line of the real locators, that is, the two real locators are in a diagonal relationship; conversely, if the relatively smaller angle value is greater than or equal to the angle threshold, it means that the two real locators are in an adjacent relationship.

[0123] In some embodiments, when the two identified real locators are in an adjacent relationship, the first method of determining the suspected center point may include:

[0124] At least two suspected center points are determined in the image according to intersection points of the fifth straight line, the sixth straight line, the seventh straight line and the eighth straight line outside the two real locators.

[0125] For the sake of convenience of explanation, the central black blocks of the two real locators are respectively recorded as the first central black block and the second central black block. Then: the fifth straight line and the sixth straight line are respectively the straight lines where the diagonals of the first central black block are located, and the diagonals of the first central black block can be determined based on the vertices of the first central black block; the seventh straight line and the eighth straight line are respectively the straight lines where the diagonals of the second central black block are located, and the diagonals of the second central black block can be determined based on the vertices of the second central black block.

[0126] It can be understood that the fifth straight line, the sixth straight line, the seventh straight line and the eighth straight line form a total of four intersections, two of which must be inside the two identified real locators, and these two internal intersections can be ignored. That is, the embodiment of the present application focuses on the two intersections of the fifth straight line, the sixth straight line, the seventh straight line and the eighth straight line outside the two real locators.

[0127] In the case that the two identified real locators are in an adjacent relationship, the electronic device may specifically determine the symmetric points of the center points of the two real locators about the two intersection points as suspected center points, thereby obtaining four suspected center points.

[0128] To explain the process of determining the suspected center point when two real locators are adjacent, please refer to Figure 8 . Figure 8 It shows:

[0129] The center point O1 of a real locator and the center point O2 of another real locator;

[0130] The fifth straight line l 5. The fifth straight line l 5 is a straight line on which a diagonal line of the first central black block is located, obtained by two diagonally opposite vertices of the first central black block;

[0131] Sixth straight line l 6. The sixth straight line l 6 is the straight line where the other diagonal line of the first central black block is located, obtained from the remaining two diagonally opposite vertices of the first central black block;

[0132] The seventh straight line l 7. The seventh straight line l 7 is a straight line on which a diagonal line of the second central black block is located, obtained from two diagonally opposite vertices of the second central black block;

[0133] The eighth straight line l 8. The eighth straight line l 8 is the straight line where another diagonal line of the second central black block is located, which is obtained from the remaining two diagonally opposite vertices of the second central black block.

[0134] Depend on Figure 8 It can be seen that these four straight lines have a total of 4 intersection points, two of which are inside the two real locators and are very close to the positions of O1 and O2 respectively (in Figure 8 In other words, the embodiment of the present application only considers the intersection points outside the two real locators, namely Q and P.

[0135] The electronic device can find the symmetric point O4 of the center point O1 of the real locator with respect to the intersection point P, and the symmetric point O5 with respect to the intersection point Q; similarly, the symmetric point O3 of the center point O2 of the real locator with respect to the intersection point P, and the symmetric point O6 with respect to the intersection point Q can also be found. Based on this, the electronic device finds four symmetric points O3, O4, O5 and O6 of the center points of the two real locators with respect to the two intersection points, and these four symmetric points are all suspected center points.

[0136] In some embodiments, when the two identified real locators are in a diagonal relationship, the second method for determining the suspected center point may include:

[0137] At least two suspected center points are determined in the image according to intersection points of the ninth straight line, the tenth straight line, the eleventh straight line and the twelfth straight line outside the two real locators.

[0138] For the convenience of explanation, the two real locators are respectively recorded as the first real locator and the second real locator, and the central black block of the first real locator is recorded as the first central black block, and the central black block of the second real locator is recorded as the second central black block. Then: the ninth straight line is: a straight line passing through the center point of the first real locator and parallel to the third side of the first central black block; the tenth straight line is: a straight line passing through the center point of the first real locator and parallel to the fourth side of the first central black block; the eleventh straight line is: a straight line passing through the center point of the second real locator and parallel to the fifth side of the second central black block; the twelfth straight line is: a straight line passing through the center point of the second real locator and parallel to the sixth side of the second central black block.

[0139] The third side and the fourth side are two different sides adjacent to each other of the first central black block, that is, the third side and the fourth side are two different sides with a common endpoint among the four sides of the first central black block.

[0140] The fifth side and the sixth side are two different sides adjacent to each other of the second central black block, that is, the fifth side and the sixth side are two different sides with a common endpoint among the four sides of the second central black block.

[0141] It can be understood that since the coordinates of the vertices of the first central black block, the vertices of the second central black block and the center points of the two real locators are all known, the linear equations of the ninth straight line, the tenth straight line, the eleventh straight line and the twelfth straight line can all be inferred based on plane geometry knowledge, which will not be repeated here.

[0142] It can be understood that the ninth straight line, the tenth straight line, the eleventh straight line and the twelfth straight line form a total of four intersections, two of which must be inside the two identified real locators (respectively the center point of the first real locator and the center point of the second real locator), and these two internal intersections can be ignored. That is, the embodiment of the present application focuses on the two intersections of the fifth straight line, the sixth straight line, the seventh straight line and the eighth straight line outside the two real locators.

[0143] In the case where the two identified real locators are in a diagonal relationship, the electronic device may directly determine two intersection points outside the real locators as suspected center points, thereby obtaining two suspected center points.

[0144] To explain the process of determining the suspected center point when the two identified real locators are diagonally related, please refer to Fig. 9 . Fig. 9 It shows:

[0145] The center point O1 of the first real locator and the center point O2 of the second real locator;

[0146] The four vertices A1, A2, A3 and A4 of the first central black block;

[0147] The four vertices B1, B2, B3 and B4 of the second central black block;

[0148] Ninth Straight Line l 9. The ninth straight line l 9 is a straight line passing through O1 and parallel to the third side of the first central black block, which can be obtained from O1, A1 and A2;

[0149] Tenth straight line l 10 , the tenth straight line l 10 is a straight line passing through O1 and parallel to the fourth side of the first central black block, which can be obtained from O1, A1 and A4;

[0150] Eleventh straight line l 11 , the eleventh straight line l 11 is a straight line passing through O2 and parallel to the fifth side of the second central black block, which can be obtained from O2, B1 and B2;

[0151] The twelfth straight line l 12 , the twelfth straight line l 12 is a straight line passing through O2 and parallel to the sixth side of the second central black block, which can be obtained from O2, B1 and B4.

[0152] Depend on Fig. 9 It can be seen that these four straight lines have a total of 4 intersection points, two of which are O1 and O2, which do not need to be considered. That is, the embodiment of the present application only considers the intersection points outside the first real locator and the second real locator, namely P and Q. The intersection points P and Q are both suspected center points.

[0153] In some embodiments, it can be understood that the process of identifying the QR code is the process of parsing the QR code. In order to improve the recognition success rate of the QR code to be recognized, step 105 may specifically include:

[0154] E1. When three real locators have been found, the relative distance between any two adjacent real locators is calculated, and the target version number of the QR code to be identified is determined according to the relative distance;

[0155] E2. Parse the QR code to be identified according to the target version number;

[0156] E3. If the parsing fails, the version number adjacent to the target version number is determined as a candidate version number, and the QR code to be identified is parsed again according to the candidate version number.

[0157] Among them, the relative distance between adjacent real locators is not in units of the number of pixels, but in units of the minimum square unit of the two-dimensional code. That is, the relative distance expresses: the number of minimum square units in any row (or column) between two adjacent real locators. It can be understood that the size of the real locator is known, which is a 7*7 matrix; that is, the number of minimum square units in any row (or column) of a real locator is 7. Then, by calculating the number x of minimum square units in any row (or column) between two adjacent real locators, the size L of the two-dimensional code to be identified can be obtained, that is, the number L of minimum square units in any row (or column) of the two-dimensional code to be identified is 7+7+x. According to the two-dimensional code standard, there is the following relationship between the two-dimensional code size L and the version number V: L = (V-1) * 4 + 21. Therefore, the corresponding target version number can be calculated based on the relative distance.

[0158] However, since the position of the real locator will inevitably have some errors, and the smaller the size of the QR code, the greater the impact of this error, which may cause the calculated target version number to deviate from the correct value. Therefore, when the electronic device fails to parse based on the target version number, it can try to decode with a nearby version, thereby further improving the decoding success rate of the defaced QR code. For example, the target version number calculated by this relative distance is v 0, the electronic device attempts to use the target version number v 0 decodes the QR code to be identified; if it fails, the version numbers adjacent to the target version number are determined as candidate version numbers in turn, and decoding is attempted based on the determined candidate version numbers; once the decoding is successful, it returns, otherwise it continues to attempt decoding with a new candidate version number. In this way, the problem of incorrect version information calculation caused by the position error of the real locator can be avoided.

[0159] It should be noted that if the target version number v 0 is 1, then only v 0+1 can be determined as a candidate version number; if the target version number is 40, then only v 0-1 can be determined as a candidate version number; if the target version number v 0 is neither 1 nor 40, then according to the actual decoding situation, the specified order and the actual decoding situation can be used to v 0-1 and v 0+1 is determined as the candidate version number.

[0160] In some embodiments, when the electronic device recognizes the locator of the image of the QR code to be recognized according to the preset color feature ratio, it may directly recognize three "locators", but this does not necessarily mean that these three "locators" are real locators, it only means that there are three areas that meet the color feature ratio in the preset direction. In the real environment, it is possible that a certain area around the QR code also meets the color feature ratio in the preset direction, which will lead to the misrecognition of the locator. Please refer to Fig.10 , Fig.10 An example is given when misidentification of locators occurs. Fig.10 In the example, the locator at the bottom right corner of the QR code is smudged and cannot be identified as a real locator through the color feature ratio. However, there happens to be a very small area in the surrounding environment that meets the color feature ratio in all directions, causing the area to be mistakenly identified as a "locator" by the electronic device. Of course, when the electronic device identifies four or more "locators", it means that there must be a "locator" that is misidentified. Based on this, the electronic device can perform a preliminary screening of the recognition results obtained based on the color feature ratio, and delete the "locators" that are ridiculously wrong to obtain the real locator. Then step 101 may specifically include:

[0161] The image of the two-dimensional code to be identified is identified according to a preset color feature ratio; if the number of identified locators is less than 3, all the identified locators are determined as real locators; if the number of identified locators is greater than or equal to 3, the average size of all identified locators is calculated; the size error between the size of each locator and the average size is calculated respectively; if there is a target size error, the locator corresponding to the target size error is deleted, and the locator that has not been deleted is determined as the real locator; wherein the target size error refers to the size error that exceeds a preset size error threshold.

[0162] As can be seen from the above, in the embodiment of the present application, when the locator of the two-dimensional code is defaced and the number of recognized real locators is insufficient, the electronic device fully considers the geometric features of the recognized real locators in the two-dimensional code, and infers the remaining real locators based on the geometric features. Since geometric reasoning puts less computing pressure on the electronic device, the electronic device can identify all the real locators in a short time, thereby ensuring the accuracy of the electronic device's recognition of the locator, and to a certain extent improving the electronic device's recognition success rate of the two-dimensional code.

[0163] Corresponding to the two-dimensional code recognition method provided above, the present application embodiment also provides a two-dimensional code recognition device. Fig.11 , the two-dimensional code recognition device 1100 includes:

[0164] The first recognition module 1101 is used to recognize the real locator in the image of the two-dimensional code to be recognized according to a preset color feature ratio;

[0165] A first determination module 1102 is used to determine the geometric features of the to-be-identified two-dimensional code in the image if the number of the identified real locators is incomplete;

[0166] A search module 1103 is used to search for at least two suspected locators in the image according to geometric features;

[0167] A second determining module 1104 is used to determine the remaining real locators among the at least two suspected locators;

[0168] The second recognition module 1105 is used to recognize the two-dimensional code to be recognized based on all real locators.

[0169] Optionally, the first determining module 1102 includes:

[0170] A first geometric feature determination unit is used to determine the center point of the real locator and the vertices of the two-dimensional code to be identified in the image if a real locator is identified;

[0171] The second geometric feature determination unit is used to determine the center point of each real locator and the vertex of the central black block of each real locator in the image if two real locators are identified.

[0172] Optionally, the vertex is determined by:

[0173] For each figure with a vertex to be determined, find the farthest point of the boundary of the figure in at least four specified directions, wherein the figure with a vertex to be determined includes: a central black block of the QR code to be identified or a real locator;

[0174] Calculate the distance between the farthest points, and determine the two farthest points as the vertices of the graph;

[0175] On both sides of the designated line, the farthest points farthest from the designated line are respectively determined as vertices of the graph, wherein the designated line is: a line connecting the two farthest points with the farthest distance.

[0176] Optionally, the search module 1103 includes:

[0177] A first suspected center point determination unit is used to determine a first suspected center point in the image according to the center point of the real locator, the first two-dimensional code vertex and the second two-dimensional code vertex when a real locator is identified, wherein the first two-dimensional code vertex is: the vertex of the to-be-identified two-dimensional code closest to the center point of the real locator, and the second two-dimensional code vertex is: the vertex of the to-be-identified two-dimensional code farthest from the center point of the real locator;

[0178] The second suspected center point determination unit is used to determine the second suspected center point and the third suspected center point in the image according to the intersection of the first straight line, the second straight line, the third straight line and the fourth straight line, wherein the first straight line is: a straight line passing through the center point of the real locator and parallel to the first side of the two-dimensional code to be identified; the second straight line is: a straight line passing through the center point of the real locator and parallel to the second side of the two-dimensional code to be identified; the third straight line is: a straight line passing through the first suspected center point and parallel to the first side; the fourth straight line is: a straight line passing through the first suspected center point and parallel to the second side; the first side and the second side are adjacent.

[0179] The first suspected locator determining unit is used to determine the corresponding suspected locator according to the first suspected center point, the second suspected center point and the third suspected center point respectively.

[0180] Optionally, the search module 1103 includes:

[0181] A position relationship determination unit, used to determine the position relationship between the two real locators in the to-be-identified two-dimensional code when two real locators are identified;

[0182] A third suspected center point determination unit, used to determine at least two suspected center points in the image according to the position relationship and the geometric features;

[0183] The second suspected locator determining unit is used to determine the corresponding suspected locator according to at least two suspected center points respectively.

[0184] Optionally, the central black blocks of the two real locators are respectively recorded as the first central black block and the second central black block, and the third suspected center point determination unit is specifically used to determine at least two suspected center points in the image according to the intersection points of the fifth straight line, the sixth straight line, the seventh straight line and the eighth straight line outside the two real locators when the positional relationship is an adjacent relationship, wherein the fifth straight line and the sixth straight line are respectively the straight lines where the diagonal of the first central black block is located, and the diagonal of the first central black block is determined according to the vertices of the first central black block, and the seventh straight line and the eighth straight line are respectively the straight lines where the diagonal of the second central black block is located, and the diagonal of the second central black block is determined according to the vertices of the second central black block.

[0185] Optionally, the two real locators are respectively recorded as the first real locator and the second real locator, and the central black block of the first real locator is recorded as the first central black block, and the central black block of the second real locator is recorded as the second central black block. The third suspected center point determination unit is specifically used to determine at least two suspected center points in the image according to the intersection points of the ninth straight line, the tenth straight line, the eleventh straight line and the twelfth straight line outside the two real locators when the position relationship is a diagonal relationship, wherein the ninth straight line is: passing through the center point of the first real locator and parallel to the first center point The straight line is: a straight line passing through the center point of the first real locator and parallel to the fourth side of the first center black block; the tenth straight line is: a straight line passing through the center point of the second real locator and parallel to the fifth side of the second center black block; the twelfth straight line is: a straight line passing through the center point of the second real locator and parallel to the sixth side of the second center black block; the third side and the fourth side are adjacent, and the third side and the fourth side are determined according to the vertices of the first center black block; the fifth side and the sixth side are adjacent, and the fifth side and the sixth side are determined according to the vertices of the second center black block.

[0186] Optionally, the second identification module 1105 includes:

[0187] A calculation unit, used for calculating the relative distance between any two adjacent real locators when three real locators have been identified;

[0188] A target version number determination unit, used to determine the target version number of the QR code to be identified according to the relative distance;

[0189] A parsing unit, used for parsing the QR code to be identified according to the target version number;

[0190] The candidate version number determination unit is further used to determine a version number adjacent to the target version number as a candidate version number if the parsing fails;

[0191] The parsing unit is further used to parse the QR code to be identified again according to the candidate version number.

[0192] As can be seen from the above, in the embodiment of the present application, when the locator of the two-dimensional code is defaced and the number of recognized real locators is insufficient, the electronic device fully considers the geometric features of the recognized real locators in the two-dimensional code, and infers the remaining real locators based on the geometric features. Since geometric reasoning puts less computing pressure on the electronic device, the electronic device can identify all the real locators in a short time, thereby ensuring the accuracy of the electronic device's recognition of the locator, and to a certain extent improving the electronic device's recognition success rate of the two-dimensional code.

[0193] Corresponding to the two-dimensional code recognition method provided above, the present application embodiment also provides an electronic device. Fig.12 The electronic device 12 in the embodiment of the present application includes: a memory 1201, one or more processors 1202 ( Fig.12 Only one is shown in the figure) and a computer program stored in the memory 1201 and executable on the processor. Among them: the memory 1201 is used to store software programs and units, and the processor 1202 executes various functional applications and data processing by running the software programs and units stored in the memory 1201 to obtain the resources corresponding to the above-mentioned preset events. Specifically, the processor 1202 implements each step in the above-mentioned method embodiment by running the above-mentioned computer program stored in the memory 1201, which will not be repeated here.

[0194] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the above-mentioned device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.

[0195] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0196] If the above-mentioned integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the associated hardware through a computer program. The above-mentioned computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the above-mentioned computer program includes computer program code, and the above-mentioned computer program code can be in source code form, object code form, executable file or some intermediate form. The above-mentioned computer-readable storage medium may include: any entity or device capable of carrying the above-mentioned computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer-readable memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electrical carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the above-mentioned computer-readable storage medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable storage media does not include electrical carrier signals and telecommunication signals.

[0197] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.

Claims

1. A two-dimensional code recognition method, characterized in that: include: According to a preset color feature ratio, a real locator is identified in the image of the QR code to be identified; If the number of the identified real locators is incomplete, determining the geometric features of the to-be-identified two-dimensional code in the image; According to the geometric features, searching for at least two suspected locators in the image; determining a remaining true locator among the at least two suspected locators; Identify the to-be-identified QR code based on all the real locators; Wherein, if the number of the identified real locators is incomplete, determining the geometric features of the to-be-identified two-dimensional code in the image includes: If a real locator is identified, then determining the center point of the real locator and the vertex of the to-be-identified two-dimensional code in the image; If two real locators are identified, then determining the center point of each real locator and the vertex of the central black block of each real locator in the image; Wherein, when one of the real locators is identified, searching for at least two suspected locators in the image according to the geometric features includes: Determine a first suspected center point in the image according to the center point of the real locator, the first two-dimensional code vertex, and the second two-dimensional code vertex, wherein the first two-dimensional code vertex is: the vertex of the to-be-identified two-dimensional code closest to the center point of the real locator, and the second two-dimensional code vertex is: the vertex of the to-be-identified two-dimensional code farthest from the center point of the real locator; According to the intersection of the first straight line, the second straight line, the third straight line and the fourth straight line, the second suspected center point and the third suspected center point are determined in the image, wherein the first straight line is: a straight line passing through the center point of the real locator and parallel to the first side of the two-dimensional code to be identified; the second straight line is: a straight line passing through the center point of the real locator and parallel to the second side of the two-dimensional code to be identified; the third straight line is: a straight line passing through the first suspected center point and parallel to the first side; the fourth straight line is: a straight line passing through the first suspected center point and parallel to the second side; the first side and the second side are adjacent, and the first side and the second side are determined according to the vertices of the two-dimensional code to be identified; The corresponding suspected locators are determined according to the first suspected center point, the second suspected center point and the third suspected center point respectively.

2. The two-dimensional code recognition method according to claim 1, characterized in that: The method of determining the vertex includes: For each figure with vertices to be determined, find the farthest points of the boundary of the figure in at least four specified directions, wherein the figure with vertices to be determined includes: the central black block of the two-dimensional code to be identified or the real locator; Calculate the distances between the farthest points, and determine the two farthest points with the farthest distance as the vertices of the graph; On both sides of a designated line, the farthest points farthest from the designated line are respectively determined as vertices of the graph, wherein the designated line is: a line connecting the two farthest points.

3. The two-dimensional code recognition method according to claim 1, characterized in that: In the case where two real locators are identified, searching for at least two suspected locators in the image according to the geometric features includes: Determine the positional relationship between the two real locators in the to-be-identified two-dimensional code; Determining at least two suspected center points in the image according to the positional relationship and the geometric features; The corresponding suspected locators are determined according to the at least two suspected center points respectively.

4. The two-dimensional code recognition method according to claim 3, characterized in that: The central black blocks of the two real locators are respectively recorded as a first central black block and a second central black block, and the determining of at least two suspected central points in the image according to the positional relationship and the geometric features includes: When the positional relationship is an adjacent relationship, at least two suspected center points are determined in the image according to the intersection points of the fifth straight line, the sixth straight line, the seventh straight line and the eighth straight line outside the two real locators, wherein the fifth straight line and the sixth straight line are respectively the straight lines where the diagonals of the first central black block are located, and the diagonals of the first central black block are determined according to the vertices of the first central black block, and the seventh straight line and the eighth straight line are respectively the straight lines where the diagonals of the second central black block are located, and the diagonals of the second central black block are determined according to the vertices of the second central black block.

5. The two-dimensional code recognition method according to claim 3, characterized in that: The two real locators are respectively recorded as a first real locator and a second real locator, and the central black block of the first real locator is recorded as a first central black block, and the central black block of the second real locator is recorded as a second central black block. The determining of at least two suspected center points in the image according to the positional relationship and the geometric features includes: When the positional relationship is a diagonal relationship, at least two suspected center points are determined in the image according to the intersection points of the ninth straight line, the tenth straight line, the eleventh straight line and the twelfth straight line outside the two real locators, wherein the ninth straight line is: a straight line passing through the center point of the first real locator and parallel to the third side of the first center black block; the tenth straight line is: a straight line passing through the center point of the first real locator and parallel to the fourth side of the first center black block; the eleventh straight line is: a straight line passing through the center point of the second real locator and parallel to the fifth side of the second center black block; the twelfth straight line is: a straight line passing through the center point of the second real locator and parallel to the sixth side of the second center black block; the third side and the fourth side are adjacent, and the third side and the fourth side are determined according to the vertices of the first center black block; the fifth side and the sixth side are adjacent, and the fifth side and the sixth side are determined according to the vertices of the second center black block.

6. The two-dimensional code recognition method according to any one of claims 1 to 5, characterized in that: The identifying the to-be-identified two-dimensional code based on all the real locators includes: When three real locators have been identified, calculating the relative distance between any two adjacent real locators; Determine the target version number of the to-be-identified QR code according to the relative distance; Parsing the to-be-identified QR code according to the target version number; If the parsing fails, the version number adjacent to the target version number is determined as the candidate version number; The to-be-recognized QR code is parsed again according to the candidate version number.

7. A two-dimensional code recognition device, characterized in that: include: A first recognition module, used to recognize a real locator in the image of the QR code to be recognized according to a preset color feature ratio; A first determination module, configured to determine the geometric features of the to-be-identified two-dimensional code in the image if the number of the identified real locators is incomplete; A search module, used for searching at least two suspected locators in the image according to the geometric features; A second determination module, configured to determine the remaining real locators among the at least two suspected locators; A second recognition module, used for recognizing the to-be-recognized two-dimensional code based on all the real locators; Wherein, the first determining module includes: A first geometric feature determination unit, configured to determine, if one of the real locators is identified, a center point of the real locator and a vertex of the to-be-identified two-dimensional code in the image; A second geometric feature determination unit, configured to determine, if two real locators are identified, a center point of each real locator and a vertex of a central black block of each real locator in the image; Wherein, the search module includes: A first suspected center point determination unit is used to determine a first suspected center point in the image according to the center point of the real locator, a first two-dimensional code vertex, and a second two-dimensional code vertex when one of the real locators is identified, wherein the first two-dimensional code vertex is: the vertex of the to-be-identified two-dimensional code closest to the center point of the real locator, and the second two-dimensional code vertex is: the vertex of the to-be-identified two-dimensional code farthest from the center point of the real locator; A second suspected center point determination unit is used to determine a second suspected center point and a third suspected center point in the image according to the intersection of a first straight line, a second straight line, a third straight line and a fourth straight line, wherein the first straight line is a straight line passing through the center point of the real locator and parallel to the first side of the two-dimensional code to be identified; the second straight line is a straight line passing through the center point of the real locator and parallel to the second side of the two-dimensional code to be identified; the third straight line is a straight line passing through the first suspected center point and parallel to the first side; the fourth straight line is a straight line passing through the first suspected center point and parallel to the second side; the first side and the second side are adjacent, and the first side and the second side are determined according to the vertices of the two-dimensional code to be identified; The first suspected locator determining unit is used to determine the corresponding suspected locator according to the first suspected center point, the second suspected center point and the third suspected center point respectively.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 6 is implemented.

9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.