CN114781417A - Two-dimensional code identification method, two-dimensional code identification device and electronic equipment - Google Patents

Two-dimensional code identification method, two-dimensional code identification device and electronic equipment Download PDF

Info

Publication number
CN114781417A
CN114781417A CN202210377276.6A CN202210377276A CN114781417A CN 114781417 A CN114781417 A CN 114781417A CN 202210377276 A CN202210377276 A CN 202210377276A CN 114781417 A CN114781417 A CN 114781417A
Authority
CN
China
Prior art keywords
real
dimensional code
locators
straight line
identified
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210377276.6A
Other languages
Chinese (zh)
Inventor
李胜军
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
TP Link Technologies Co Ltd
Original Assignee
TP Link Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by TP Link Technologies Co Ltd filed Critical TP Link Technologies Co Ltd
Priority to CN202210377276.6A priority Critical patent/CN114781417A/en
Publication of CN114781417A publication Critical patent/CN114781417A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K7/00Methods or arrangements for sensing record carriers, e.g. for reading patterns
    • G06K7/10Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation
    • G06K7/10544Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation by scanning of the records by radiation in the optical part of the electromagnetic spectrum
    • G06K7/10821Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation by scanning of the records by radiation in the optical part of the electromagnetic spectrum further details of bar or optical code scanning devices
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K7/00Methods or arrangements for sensing record carriers, e.g. for reading patterns
    • G06K7/10Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation
    • G06K7/14Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation using light without selection of wavelength, e.g. sensing reflected white light
    • G06K7/1404Methods for optical code recognition
    • G06K7/1439Methods for optical code recognition including a method step for retrieval of the optical code
    • G06K7/1443Methods for optical code recognition including a method step for retrieval of the optical code locating of the code in an image

Landscapes

  • Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • Electromagnetism (AREA)
  • Health & Medical Sciences (AREA)
  • General Health & Medical Sciences (AREA)
  • Toxicology (AREA)
  • Artificial Intelligence (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Image Analysis (AREA)

Abstract

The application discloses a two-dimension code identification method, a two-dimension code identification device, electronic equipment and a computer readable storage medium. The method comprises the following steps: identifying a real locator in an image of the two-dimensional code to be identified according to a preset color characteristic ratio; if the number of the identified real locators is not complete, determining the geometric features of the two-dimensional code to be identified in the image; according to the geometric features, at least two suspected locators are found out in the image; determining remaining real locators in the at least two suspected locators; and identifying the two-dimensional code to be identified based on all the real locators. Through the scheme, the identification accuracy of the locator can be improved under the condition that the locator of the two-dimensional code is stained, and the identification success rate of the two-dimensional code can be increased to some extent.

Description

Two-dimensional code identification method, two-dimensional code identification device and electronic equipment
Technical Field
The application belongs to the technical field of two-dimension code processing, and particularly relates to a two-dimension code identification method, a two-dimension code identification device, an electronic device and a computer readable storage medium.
Background
Nowadays, two-dimensional codes are widely applied in production and life. In an actual scene, the two-dimensional code is often contaminated. Although the two-dimensional code itself has an error correction mechanism and can tolerate the contamination of the encoding region to a certain extent, if the locator of the two-dimensional code is contaminated, the two-dimensional code recognition algorithm is challenged because the accurate locator cannot be recognized, which is a problem that the error correction mechanism of the two-dimensional code cannot solve. Therefore, how to accurately identify the two-dimensional code when the locator of the two-dimensional code is contaminated becomes a problem to be solved at present.
Disclosure of Invention
The application provides a two-dimension code identification method, a two-dimension code identification device, an electronic device and a computer readable storage medium, which can improve the identification accuracy of a locator of a two-dimension code under the condition that the locator is stained, so that the identification success rate of the two-dimension code can be increased to some extent.
In a first aspect, the present application provides a two-dimensional code identification method, including:
identifying a real locator in the image of the two-dimensional code to be identified according to a preset color characteristic proportion;
if the number of the identified real locators is not complete, determining the geometric features of the two-dimensional code to be identified in the image;
according to the geometric characteristics, at least two suspected locators are found in the image;
determining the remaining real locators in the at least two suspected locators;
and identifying the two-dimensional code to be identified based on all the real locators.
In a second aspect, the present application provides a two-dimensional code recognition apparatus, including:
the first identification module is used for identifying a real locator in the image of the two-dimensional code to be identified according to a preset color characteristic proportion;
the first determining module is used for determining the geometric characteristics of the two-dimensional code to be recognized in the image if the number of the recognized real locators is not complete;
the searching module is used for searching at least two suspected locators in the image according to the geometric characteristics;
a second determining module, configured to determine remaining real locators in the at least two suspected locators;
and the second identification module is used for identifying the two-dimensional code to be identified based on all the real locators.
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 according to the first aspect when executing the computer program.
In a fourth aspect, the present application provides a computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the method of the first aspect.
In a fifth aspect, the present application provides a computer program product comprising a computer program which, when executed by one or more processors, performs the steps of the method of the first aspect as described above.
Compared with the prior art, the application has the beneficial effects that: the electronic equipment firstly identifies real locators in an image of the two-dimensional code to be identified according to a preset color feature ratio, if the number of the identified real locators is not complete, determines the geometric features of the two-dimensional code to be identified in the image, searches for at least two suspected locators in the image according to the geometric features, finally determines the remaining real locators in the at least two suspected locators, and identifies the two-dimensional code to be identified according to all the obtained real locators. In the above process, the electronic device fully considers the geometric features of the two-dimensional code under the condition that the number of the identified real locators is insufficient due to the dirty locators of the two-dimensional code, and deduces the remaining real locators according to the geometric features. Due to the fact that the operation pressure of the geometric reasoning on the electronic equipment is small, the electronic equipment can recognize all real locators in a short time, the accuracy rate of the electronic equipment for recognizing the locators is guaranteed, and the success rate of the electronic equipment for recognizing the two-dimensional codes is improved to a certain extent.
It is understood that the beneficial effects of the second aspect to the fifth aspect can be referred to the related description of the first aspect, and are not described herein again.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings without creative efforts.
Fig. 1 is a schematic flow chart illustrating an implementation of a two-dimensional code identification method provided in an embodiment of the present application;
FIG. 2 is an exemplary diagram of a fouled locator provided by an embodiment of the present application;
FIG. 3 is an exemplary diagram of a farthest point finding process provided by an embodiment of the present application;
FIG. 4 is an exemplary diagram of the farthest point found in eight specified directions provided by an embodiment of the present application;
fig. 5 is an exemplary diagram of an effect of a two-dimensional code to be recognized after preprocessing according to an embodiment of the present application;
FIG. 6 is an exemplary diagram of boundary tracing provided by embodiments of the present application;
fig. 7 is an exemplary diagram of a process for determining a suspected center point according to an embodiment of the present disclosure;
fig. 8 is a diagram of another example of a process for determining a suspected center point according to an embodiment of the present disclosure;
fig. 9 is a diagram of another example of a process for determining a suspected center point according to an embodiment of the present disclosure;
FIG. 10 is a diagram illustrating an example of a locator misidentification provided by an embodiment of the present application;
fig. 11 is a block diagram of a two-dimensional code recognition apparatus according to an embodiment of the present application;
fig. 12 is a schematic structural diagram of an electronic device provided in an embodiment of the present application.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system structures, techniques, etc. in order to provide a thorough understanding of the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
In order to explain the technical solution proposed in the present application, the following description is given by way of specific examples.
The two-dimensional code identification method provided by the embodiment of the application is applied to electronic equipment. Merely by way of example, the electronic device may be a camera-enabled electronic device, such as a smartphone, tablet, or notebook. It can be understood that, for these electronic devices, the two-dimensional code identification method proposed in the embodiments of the present application can be executed when the camera is turned on to enable the two-dimensional code scanning function. Of course, the electronic device may be an electronic device without a shooting function, such as a desktop computer or a server. It can be understood that, for the electronic devices, after receiving the image of the two-dimensional code to be recognized sent by the other device, the electronic devices may execute the two-dimensional code recognition method provided by the embodiment of the present application based on the image of the two-dimensional code to be recognized. That is, in the embodiment of the present application, the execution subject of the two-dimensional code recognition method is not limited.
Referring to fig. 1, the implementation flow of the two-dimensional code recognition method is detailed as follows:
step 101, identifying a real locator in an image of a two-dimensional code to be identified according to a preset color feature ratio.
The two-dimensional code to be identified, which is concerned by the embodiment of the application, specifically refers to a matrix type two-dimensional code (QR two-dimensional code). For the matrix type two-dimensional code, a locator is respectively arranged at the upper left corner, the lower left corner and the upper right corner of the matrix type two-dimensional code, and the locator strictly follows the following color feature proportion: the ratio of the black width to the white width in the horizontal direction, the longitudinal direction and the 45-degree oblique direction satisfies 1: 1: 3: 1: 1. based on the color characteristic proportion, searching can be carried out in the image of the two-dimensional code to be identified according to the color characteristic proportion so as to identify the real locator.
And 102, if the number of the identified real locators is not complete, determining the geometric features of the two-dimensional code to be identified in the image.
As can be seen from the foregoing description, normally, there should be three locators in the two-dimensional code to be identified. However, in an actual application scenario, the locator may be contaminated, so that the color feature ratio cannot be satisfied due to contamination of the locator, and the contaminated locator cannot be identified in step 101. That is, a case may occur where the number of recognized real locators is less than three. In this case, the geometric features of the two-dimensional code to be recognized in the image can be found, and the geometric features comprise: a center point of the real locator; and the vertex of the two-dimensional code to be identified or the vertex of the central black block of the real locator.
It should be noted that the embodiments of the present application mainly focus on the case where the real locator is identified, but the number of the real locators is insufficient. That is, if one real locator or two real locators are identified through step 101, the remaining real locators can be found through the two-dimensional code identification method provided by the embodiment of the present application; if any real locator is not identified through step 101, the remaining real locator cannot be found through the two-dimensional code identification method.
Of course, if the electronic device has already recognized all the real locators (three real locators in total) of the two-dimensional code to be recognized through step 101, step 105 can be directly performed.
Referring to FIG. 2, FIG. 2 shows an example of a multi-directional fouled locator.
Step 103, at least two suspected locators are found in the image according to the geometric features.
The geometric characteristics of the two-dimensional code to be recognized in the image actually express the position of the recognized real locator in the image to some extent. As can be seen from the foregoing description, for the matrix-type two-dimensional code, the positions of the locators in the matrix-type two-dimensional code are fixed, so that the possible positions of the remaining real locators in the image can be found according to the geometric features, and the corresponding locator areas are defined based on the positions, and the pattern expressed by each locator area is used as the pseudo locator.
And step 104, determining the remaining real locators in the at least two suspected locators.
Normally, the at least two suspected locators found typically include the remaining real locators. Based on this, the electronic device may verify each suspected locator by means other than color feature ratios to determine the remaining real locators. By way of example only, the other way may be a way of template matching; alternatively, the other manner may be a manner of prediction (classification) based on a deep learning model, and the other manner is not limited herein.
Taking the template matching as an example, the electronic device may determine the remaining real locators by:
calculating the template matching degree of the matching template and each suspected locator; determining the remaining real locators according to the sequence of the template matching degree from high to low, specifically: if a real locator is identified through step 101, determining the first two suspected locators with the highest template matching degree as the real locators, and finding three real locators, wherein the real locators are completely identified; if two real locators are identified by step 101, the only one suspected locator with the highest template matching degree is determined as the real locator, and thus three real locators are found, and thus the real locators are completely identified.
It is to be understood that the matching template may be a preset locator pattern; alternatively, the matching template may be the real locator identified in step 101, and the obtaining manner of the matching template is not limited herein.
It can be understood that, considering that there may be a deviation in the determined positions of the suspected locators, when calculating the template matching degree between the matching template and each suspected locator, a diamond search method may be adopted to compensate for the possible position deviation, and the details of the diamond search method are not described herein.
And 105, identifying the two-dimensional code to be identified based on all the real locators.
It has been described above that there are three locators for a two-dimensional code. It is understood that there are various ways of identifying "all real locators": both the case where three real locators are identified directly by step 101 and the case where three real locators are identified by step 101 and 104. That is, as long as the electronic device can find all the real locators in the two-dimensional code to be recognized (find the complete number of real locators), the step can be triggered to be executed. According to all the real locators (three real locators in total) found currently, the electronic equipment can identify the two-dimensional code to be identified so as to acquire the information carried by the two-dimensional code to be identified.
In some embodiments, for the case where a true locator is identified, the geometric features determined by the electronic device may be: the center point of the real locator and the vertex of the two-dimensional code to be identified. For the case where two real locators are identified, the geometric features determined by the electronic device may be: the center point of each real locator and the vertex of the central black block of each real locator.
When the electronic equipment identifies the real locator, the coordinates of the central 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.
The two-dimensional code to be recognized and the central black block are actually squares, so that the vertex of the two-dimensional code to be recognized and the vertex of the central black block of the real locator can be obtained through the following processes:
a1, finding the farthest points of the boundary of the graph of the vertex to be determined in at least four specified directions respectively;
it can be understood that, in the case of identifying a real locator, the graph of the vertex to be determined refers to the two-dimensional code to be identified; in the case where two real locators are identified, the graph of vertices to be determined refers to the central black block of any one of the identified real locators. That is, for convenience of description, the concept of the graph of the vertex to be determined is introduced, and actually, according to different application scenarios, the central black block of the two-dimensional code to be identified or the real locator is referred to.
The electronic device may first perform boundary tracing on the graph of the vertex to be determined, and then find the farthest points in at least four designated directions on the traced boundaries, respectively. For example only, the specified directions may be four directions of vertical up (abbreviated as up), vertical down (abbreviated as down), horizontal left (abbreviated as left), and horizontal right (abbreviated as right). Considering that the two-dimensional code to be recognized may be inclined in the image, the specified direction may be added to eight directions of up, down, left, and right, a direction inclined upward at an angle of 45 ° with respect to the horizontal left direction (referred to as "upper left" for short), a direction inclined downward at an angle of 45 ° with respect to the horizontal left direction (referred to as "lower left" for short), a direction inclined upward at an angle of 45 ° with respect to the horizontal right direction (referred to as "upper right" for short), and a direction inclined downward at an angle of 45 ° with respect to the horizontal right direction (referred to as "lower right" for short). It will be understood that horizontal in the above description refers to a direction parallel to the x-axis of the image coordinate system; vertical in the above description, refers to a direction parallel to the y-axis of the image coordinate system; wherein the origin of the image coordinate system is the top left vertex of the image.
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 detailed as follows:
for the up direction: and determining the point with the minimum longitudinal coordinate value on the boundary as the farthest point in the direction.
For the following directions: the point on the boundary where the ordinate value is the largest is determined as the farthest point in that direction.
For the left direction: the point on the boundary where the horizontal coordinate value is minimum is determined as the farthest point in the direction.
For the right direction: the point on the boundary where the abscissa value is largest is determined as the farthest point in the direction.
For the upper left direction: and determining the point with the minimum sum of the ordinate value and the abscissa value on the boundary as the farthest point in the direction.
For the lower left direction: the point on the boundary where the difference between the ordinate and abscissa values (i.e., y-x) is greatest is determined to be the farthest point in the direction.
For the upper right direction: the point on the boundary where the difference between the abscissa and ordinate values (i.e., x-y) is greatest is determined to be the farthest point in that direction.
For the lower right direction: and determining the point with the maximum sum of the ordinate value and the abscissa value on the boundary as the farthest point in the direction.
In some application scenarios, it is possible to find more than three farthest points in a certain direction by the above determination. In order to reduce the complexity of subsequent data processing, more than three farthest points in the direction may be filtered, specifically:
generally, the three or more farthest points are necessarily in the same straight line. Based on this, one line segment can be obtained by connecting the three or more farthest points. The direction is left with only the end point of the line segment remaining as the final farthest point in the direction, and the remaining points being discarded, so that the direction remains only two farthest points in the end.
For example, in the way of determining the farthest point described above, it is found that the sum of the ordinate and abscissa values of all four points P1, P2, P3, and P4 is the minimum in the upper left direction, and thus these four points are necessarily located on a straight line y ═ x + k, where k is the minimum value of the sum of the ordinate and abscissa values. Connecting P1, P2, P3 and P4 to obtain a line segment, wherein P1 is an end point of the line segment, P4 is another end point of the line segment, and both P2 and P3 are some points on the line segment other than the end point. The electronic device may discard P2 and P3, leaving only P1 and P4 as the farthest points in the upper-left direction.
It will be appreciated that if only one or two farthest points are found in a direction by the determination of the farthest points described above, the farthest points in that direction need not be filtered.
Therefore, two farthest points can be obtained at most in each direction, and when eight specified directions are set, sixteen farthest points can be obtained at most by the electronic device. Of course, a minimum of one farthest point is available in each direction, and in the case where eight designated directions are set, the electronic device can obtain a minimum of eight farthest points.
Referring to fig. 3, fig. 3 shows an example of the search process for the farthest point. In fig. 3, in order to highlight the farthest points, the farthest points are shown as gray small circles, and each farthest point should be a pixel point.
And A2, calculating the distance between the farthest points, and determining the two farthest points with the farthest distances as the vertexes of the graph.
In any case, the graph is a square, and the vertex of the square has the following characteristics: the vertex of the opposite angle is farthest away, and based on this, the electronic device can start with the feature and find two vertices at opposite angles. To find the two vertices that are in opposite corners, the electronic device may calculate the distance between the farthest points two by two, and then determine the two farthest points that are the farthest distances calculated as the two vertices of the graph. So far, two vertices have been found in the image, and only the other two vertices have not been found.
A3, respectively determining farthest points farthest from the designated connecting line as vertexes of the graph on two sides of the designated connecting line, wherein the designated connecting line is: the line connecting the two farthest points that are farthest away.
Connecting the two farthest points, i.e. the two vertices determined in step a2, a connecting line is obtained. On either side of the line, if the side has only one farthest point, the farthest point is the vertex; if the side has more than two farthest points, the distances from the two farthest points to the specified connecting line can be calculated, and the farthest point from the specified connecting line is determined as a vertex of the image. Through the process, the two sides of the connecting line are respectively searched, and the remaining two vertexes can be found, wherein the two vertexes are respectively positioned on different sides of the connecting line.
For ease of understanding, steps a2 and A3 are described below by way of specific examples:
referring to fig. 4, fig. 4 shows an example of the farthest point of the boundary of the center black block found in eight specified directions. In fig. 4, the farthest points found are P1, P2, … …, and P12 respectively, and there are 12 farthest points.
By calculating the distance between the farthest points through step A2, and determining that P4 and P10 are farthest, both P4 and P10 are determined as vertices. Connecting P4 and P10 results in the designated line, shown as a gray line segment in FIG. 4. As can be seen from FIG. 4, 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.
Calculating the distances between P1, P2, P3, P11 and P12 and the designated connecting line respectively through the step A3, determining that the P1 is farthest from the designated connecting line, and then the P1 is the determined vertex on one side of the designated connecting line; similarly, the distances between P5, P6, P7, P8 and P9 and the designated connecting line are respectively calculated, the P8 is determined to be farthest from the designated connecting line, and then the P8 is the determined vertex on the other side of the designated connecting line. So far, all vertices of the graph are found, which are respectively: p4, P10, P1 and P8.
In some embodiments, the number of the farthest points found in step a1 may be as many as ten, and 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: points that are too close in distance are merged. For example, if there is another farthest point in the eight neighbors of a farthest point, the farthest point of the two farthest points can be randomly retained, and the other farthest point can be discarded without participating in the operations of the subsequent steps a2 and A3.
In some embodiments, the boundary tracking process for the graph of vertices to be determined may be:
b1, searching from the center point of the graph of the vertex to be determined in any fixed direction, and finding the first white pixel point as the first point on the boundary, based on which, the first white pixel point is determined as the current tracking point.
It will be appreciated that the fixed direction may be any direction when searching out from the center point of the graph of vertices to be determined has not yet begun; but once outward seeking is initiated, the fixed direction should not be changed.
It should be noted that when the graph of the vertex to be determined is the two-dimensional code to be recognized, the two-dimensional code to be recognized needs to be preprocessed first, and then the boundary of the two-dimensional code to be recognized can be found through the steps B1-B3. The pretreatment process is briefly described as follows:
and carrying out image segmentation on the two-dimensional code to be recognized by using an enhanced run-length entropy image segmentation algorithm, and blacking the two-dimensional code area of the two-dimensional code to be recognized.
Referring to fig. 5, fig. 5 shows an example of the effect of the two-dimensional code to be recognized after the preprocessing.
B2, searching eight neighborhoods of the current tracking point in the specified searching order, wherein the first searched point in the eight neighborhoods is: the last black pixel searched before the current tracking point is determined. The search order can be determined according to the tracking order of the boundary, specifically: if the tracking sequence is counterclockwise, the searching sequence is clockwise; if the tracking order is clockwise, then the search order is counterclockwise.
B3, determining the first white pixel point searched in the eight neighborhoods as a new current tracking point, and returning to execute the step B2 until the boundary is searched for a circle and then stopping; i.e., until the initial current tracking point (i.e., the current tracking point determined in step B1) is traversed again.
For ease of understanding, referring to fig. 6, the above-mentioned boundary tracking process is described with reference to fig. 6:
the gray dashed arrow in fig. 6 indicates the direction of searching outwards from the center point of the graph of vertices to be determined (i.e., the fixed direction of step B1). It can be seen that based on the fixed orientation shown in fig. 6, the first point on the found boundary (i.e., the first current tracking point) is point S.
Searching is carried out in the eight neighborhoods of the point S, wherein the point A is the first point searched for at this time because the last black pixel point searched for before the point S is found is the point A. Assuming the current tracking order is clockwise, the search order is counterclockwise, i.e., starting from point a, eight neighborhoods of point S are traversed counterclockwise. Therefore, the first white pixel point T in the eight neighborhoods can be found. The point T may be determined as a new point on the boundary. Meanwhile, the current tracking point is updated, that is, the point T is updated to a new current tracking point.
Searching is carried out in eight neighborhoods of the point T, wherein the point A is the first point searched for at this time because the last black pixel point searched for before the point T is found is the point A. Starting from the point a, the eight neighborhoods of the point T are traversed counterclockwise, and after the points A, B and C are passed, the first white pixel point R in the eight neighborhoods is found. The point R may be determined as a new point on the boundary. At the same time, the current tracking point is updated, i.e. point R is updated to a new current tracking point.
And repeating the steps until the point S is searched again, wherein the search is known to be finished for one circle. At this point, the boundary tracing of the graph of vertices to be determined has been completed.
It is understood that, in steps B1-B3, since the searching order is different from the tracking order, and the last black pixel searched before the current tracking point is determined is used as the first searched point in the current searching of the eight neighborhoods during searching, the path of searching the next current tracking point will enter the area of the graph with the vertex to be determined first. Based on this, in the process of searching out from the inside of the region (i.e. black region), the first white pixel point encountered must be close to the inside of the region (i.e. black region), thereby ensuring that each current tracking point is the outer boundary point of the graph of the vertex to be determined.
Of course, conventional boundary tracing methods may also be employed to obtain the boundaries of the graph of vertices to be determined. However, since the conventional boundary tracking method usually needs to extract the edge first, the processing flow of the conventional boundary tracking method is more complicated than that of the new boundary tracking method (i.e. steps B1-B3) proposed in the embodiment of the present application, and may affect the speed and efficiency of the electronic device in identifying the locator of the two-dimensional code to some extent.
In some embodiments, as described above, in the case that 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 two-dimensional code to be identified. As can be seen from the foregoing, the real locator is usually located near one corner of the two-dimensional code to be recognized, and thus the remaining two real locators are located near the remaining three corners. Based on this, step 103 can be embodied as:
and C1, determining 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.
The first two-dimensional code vertex refers to: the vertex of the two-dimensional code to be identified, which is closest to the central 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 recognized, and the first two-dimensional code vertex is the vertex of the two-dimensional code to be recognized at the corner. Similarly, the second two-dimensional code vertex refers to: the vertex of the two-dimensional code to be identified, which is farthest from the central point of the real locator; in other words, the vertex of the second two-dimensional code is the vertex of the two-dimensional code to be identified at the opposite angle of the corner.
For the convenience of describing the process of determining the first suspected center point, please refer to FIG. 7. The center point O of the identified real locator is shown in fig. 7, and four vertices A, B, C and D of the two-dimensional code to be identified. According to the definition given above, a is the first two-dimension code vertex and C is the second two-dimension code vertex.
As can be seen from fig. 7, in the case that the perspective of the two-dimensional code to be recognized is not very serious, ABCD is approximately in the shape of a parallelogram, and in this case: AO — CQ. Because 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 known, the coordinates of the point Q, which is the first suspected center point, can be determined according to the result that AO is-CQ.
Wherein perspective herein refers to near-far-small effect. The perspective is very serious, which means that when the electronic device shoots the two-dimensional code, the lens of the electronic device is close to the two-dimensional code, and the shooting angle is inclined, so that the position difference (which means relative difference, namely division is performed instead of subtraction) between different areas of the two-dimensional code and the lens is very large, and further, the magnification of the near two-dimensional code area is obviously higher than that of the far two-dimensional code area during imaging.
And C2, determining a second suspected center point and a third suspected center point in the image according to the intersection point of the first straight line, the second straight line, the third straight line and the fourth straight line.
The first line means: and a straight line passing through the center point of the real locator and being parallel to the first edge of the two-dimensional code to be identified.
The second straight line means: and a straight line passing through the center point of the real locator and being parallel to the second edge of the two-dimensional code to be identified.
The third line means: the first suspected center point is parallel to a straight line of a first edge of the two-dimensional code to be identified.
The fourth line refers to: the first suspected center point is parallel to a straight line of a second edge of the two-dimensional code to be identified.
The first edge and the second edge are two different adjacent edges of the two-dimensional code to be identified. That is, the first edge and the second edge are two different edges having a common end point among four edges of the two-dimensional code to be recognized.
Please still refer to fig. 7. The first side in fig. 7 refers to AB (or DC) and the second side refers to AD (or BC). The straight line l in fig. 71Is the first straight line l1Passes through the center point O of the real locator and is parallel to AB; straight line l2I.e. the second straight line, the straight line l2Passes through the center point O of the real locator and is parallel to AD; straight line l3I.e. the third straight line, the straight line l3Passes through the first suspected center point Q and is parallel to AB; straight line l4I.e. the fourth straight line, the straight line l4Passes the first suspect centre point Q and is parallel to AD. It is understood that since the coordinates of O, Q, A, B, C and D are known, the equations of the first line, the second line, the third line and the fourth line can be inferred based on knowledge of plane geometry, and will not be described herein.
As can be seen from fig. 7, four intersection points are formed based on the four straight lines, wherein two of the intersection points are the center point O and the first pseudo-center point Q of the real locator, and the remaining two intersection points P and R are the second pseudo-center point and the third pseudo-center point, respectively. That is, the intersection focused in step C2 refers to an intersection where any two lines of the first line, the second line, the third line, and the fourth line intersect with each other except for the center point of the real locator and the first pseudo-center point.
And C3, determining the corresponding suspected localizer according to the first suspected center point, the second suspected center point and the third suspected center point.
And two of the three suspected center points should be respectively near the center points of the remaining two real locators. Based on this, three suspected locators can be determined from the three suspected center points, respectively, and the remaining two real locators are found in the three suspected locators by the subsequent step 104.
It can be understood that the image of the two-dimensional code to be recognized may have distortion. Generally, when the distortion is not large, the two-dimensional code to be recognized can still be approximately regarded as a parallelogram for processing, and three corresponding suspected locators are obtained. Although the coordinates of the center point (i.e. the suspected center point) of the three suspected locators may have errors due to the distortion, the precise positions of the remaining real locators can still be matched when the template matching is performed by using the diamond search subsequently.
In some embodiments, as described above, where two real locators are identified, the geometric features determined by the electronic device are the center point of the real locators and the vertices of the central black blocks of the two real locators. As can be seen from the foregoing, the real locator is usually located near one corner of the two-dimensional code to be recognized, and thus the remaining one real locator is located near the remaining two corners. In an actual application scenario, when two real locators are identified, the two real locators may have two different positional relationships as follows: adjacent relations and diagonal relations. As the name implies, the neighborhood relationship refers to: the corners where these two real locators are located are adjacent; the diagonal relationship means: the corner where these two real locators are located is the diagonal. The embodiment of the application provides different determination modes of the suspected locator aiming at the two different position relations. That is, the present application will first determine the position relationship between two identified real locators; if the position relationship is an adjacent relationship, determining at least two suspected center points in a first mode; otherwise, if the position relationship is a diagonal relationship, determining at least two suspected central points in a second mode; and finally, determining corresponding suspected locators according to the determined at least two suspected center points.
The position relation of the two real locators can be judged through the following processes:
d1, selecting any real locator, and calculating the straight line equation of two diagonal lines of the real locator according to the vertex of the central black block of the real locator.
D2, calculating a straight line equation of the straight lines of the two central points according to the coordinates of the central points of the two real locators;
d3, calculating the included angles between the straight line of D2 and the two diagonal lines of D1 according to the straight line equation of the two diagonal lines obtained by D1 and the straight line equation of the straight line obtained by D2, and obtaining two included angle values.
D4, comparing the relatively smaller included angle value of the two included angle values with a preset included angle threshold (for example, 5 degrees), and if the relatively smaller included angle value is smaller than the included angle threshold, it means that the connecting line of the center points of the two real locators is approximately parallel to a certain diagonal line of the real locators, that is, the two real locators are in a diagonal relationship; otherwise, if the relatively small included angle value is greater than or equal to the included angle threshold, it indicates that the two real locators are in an adjacent relationship.
In some embodiments, where the two identified real locators are in a neighboring relationship, the first way to determine the suspected center point employed may include:
and determining at least two suspected center points 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.
For convenience of illustration, the center black blocks of the two real locators are respectively referred to as a first center black block and a second center black block, and then: the fifth straight line and the sixth straight line are respectively straight lines where the diagonal line of the first center black block is located, and the diagonal line of the first center black block can be determined according to the vertex of the first center black block; the seventh straight line and the eighth straight line are respectively straight lines where the diagonal line of the second center black block is located, and the diagonal line of the second center black block can be determined according to the vertex of the second center black block.
It is understood that the fifth line, the sixth line, the seventh line and the eighth line together form four intersection points, wherein two intersection points are necessarily inside the two identified real locators, and the two inside intersection points can be ignored. That is, the embodiments of the present application focus on two intersections of the fifth line, the sixth line, the seventh line, and the eighth line outside of the two real locators.
In the case that the two identified real locators are in an adjacent relationship, the electronic device may specifically determine a symmetric point of the center points of the two real locators with respect to the two intersection points as a suspected center point, so that four suspected center points may be obtained.
For the purpose of describing the process of determining a suspected center point when two real locators are identified as being in a neighboring relationship, please refer to fig. 8. Shown in fig. 8:
the center point O1 of a certain real locator and the center point O2 of another real locator;
fifth straight line l5The fifth straight line l5The straight line where one diagonal line of the first center black block is located is obtained by two vertexes, located at the diagonal line, of the first center black block;
sixth straight line l6The sixth straight line l6The straight line where the other diagonal line of the first center black block is located is obtained from the top points of the two remaining diagonal lines of the first center black block;
the seventh straight line l7The seventh straight line l7The straight line where one diagonal line of the second center black block is located is obtained by two vertexes, located at the diagonal line, of the second center black block;
eighth straight line l8The eighth straight line l8The straight line where the other diagonal line of the second central black block is positioned is formed by the rest of the second central black blockTwo vertices at opposite angles.
As can be seen from fig. 8, the four straight lines have 4 intersection points, wherein two intersection points are respectively inside the two real locators and are respectively located in close proximity to O1 and O2 (not shown in fig. 8), and the two intersection points do not need to be considered. That is, the embodiment of the present application only considers the intersection points outside the two real locators, i.e., Q and P.
The electronic device may find the center point O1 of the real locator to be symmetric O4 about the intersection point P and to be symmetric O5 about the intersection point Q; similarly, the symmetry O3 of the center point O2 of the real locator with respect to the intersection point P and the symmetry 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 the four symmetric points are all suspected center points.
In some embodiments, in the case that the two identified real locators are in a diagonal relationship, the second way to determine the suspected center point may include:
and determining 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.
For convenience of explanation, two real locators are respectively marked as a first real locator and a second real locator, a center black block of the first real locator is marked as a first center black block, and a center black block of the second real locator is marked as a second center 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 center black block; the tenth straight line is: a straight line passing through a center point of the first real locator and parallel to a fourth side of the first center black block; the eleventh straight line is: a straight line passing through a center point of the second real locator and parallel to a 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 edge and the fourth edge are two different edges adjacent to the first central black block. That is, the third side and the fourth side are two different sides having a common end point among the four sides of the first central black block.
The fifth side and the sixth side are two different sides adjacent to the second central black block. That is, the fifth side and the sixth side are two different sides having a common end point among the four sides of the second center black block.
It can be understood that, since the coordinates of the vertex of the first central black block, the vertex of the second central black block, and the center points of the two real locators are known, the linear equations of the ninth line, the tenth line, the eleventh line, and the twelfth line can be inferred according to the knowledge of plane geometry, and are not described herein again.
It is understood that the ninth line, the tenth line, the eleventh line and the twelfth line together form four intersection points, wherein two intersection points are necessarily inside the two identified real locators (the center point of the first real locator and the center point of the second real locator, respectively), and the two inside intersection points can be ignored. That is, the embodiments of the present application focus on two intersections of the fifth line, the sixth line, the seventh line, and the eighth line outside of the two real locators.
In the case that the two identified real locators are in a diagonal relationship, the electronic device may specifically directly determine two intersection points outside the real locators as the suspected center points, and thus may obtain the two suspected center points.
For the purpose of describing the process of determining the suspected center point when two real locators are identified as being in a diagonal relationship, please refer to fig. 9. Shown in fig. 9 are:
a center point O1 of the first real locator and a center point O2 of the second real locator;
four vertices of the first central black block, a1, a2, A3, and a 4;
the four vertices B1, B2, B3, and B4 of the second center black block;
ninth straight line l9The ninth line l9A line passing through O1 and parallel to the third side of the first central black block, which can be derived from O1, A1 and A2;
the tenth straight lineLine l10The tenth straight line l10A line passing through O1 and parallel to the fourth side of the first central black block, which can be derived from O1, A1 and A4;
eleventh straight line l11The eleventh straight line l11A line passing through O2 and parallel to the fifth side of the second central black block, which can be derived from O2, B1 and B2;
twelfth straight line l12The twelfth straight line l12A line that passes through O2 and is parallel to the sixth side of the second central black block can be found from O2, B1, and B4.
As can be seen from fig. 9, the four straight lines have 4 intersection points, two of which are O1 and O2, respectively, and the two intersection points are not considered. That is, the embodiments of the present application only consider the intersection points, i.e., P and Q, outside the first real locator and the second real locator. The intersection points P and Q are both suspected center points.
In some embodiments, it can be understood that the process of identifying the two-dimensional code is a process of parsing the two-dimensional code. In order to improve the success rate of identifying the two-dimensional code to be identified, step 105 may specifically include:
e1, under the condition that three real locators are found, calculating the relative distance between any two adjacent real locators, and determining the target version number of the two-dimensional code to be identified according to the relative distance;
e2, analyzing the two-dimensional code to be recognized according to the target version number;
and E3, if the analysis fails, determining the version number adjacent to the target version number as a candidate version number, and continuing to analyze the two-dimensional code to be identified again according to the candidate version number.
The relative distance between adjacent real locators is not in the unit of the number of pixel points, but in the unit of the minimum square unit of the two-dimensional code. That is, the relative distance expresses: the number of minimum square cells in any row (or column) between two adjacent real locators. It will be appreciated that the size of the real locators is known, as a matrix of 7 by 7; i.e. the number of minimum square cells in any row (or column) of a real locator is 7. And then, by calculating the number x of the minimum square units in any row (or column) between two adjacent real locators, the size L of the two-dimensional code to be recognized can be obtained, that is, the number L of the minimum square units in any row (or column) of the two-dimensional code to be recognized is 7+7+ x. According to the two-dimensional code standard, the following relationship exists between the size L and the version number V of the two-dimensional code: l ═ V-1 × 4+ 21. Therefore, the corresponding target version number can be calculated according to the relative distance.
However, there is some error inevitable due to the position of the real locator, and the smaller the size of the two-dimensional code, the greater the influence of such 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, the electronic device can try decoding with the nearby version, and therefore the decoding success rate of the contaminated two-dimensional code is further improved. For example, the target version number calculated by the relative distance is v0The electronic device attempts to match the target version number v0Decoding the two-dimensional code to be recognized; if the decoding fails, sequentially determining the version numbers adjacent to the target version number as candidate version numbers, and trying to decode based on the determined candidate version numbers; and returning once the decoding is successful, otherwise, continuing to attempt decoding with the new candidate version number. Therefore, the problem of version information calculation error caused by position error of the real locator can be avoided.
It should be noted that if the target version number v0Is 1, then only v0+1 may be determined as a candidate version number; if the target version number is 40, then only v0-1 can be determined as a candidate version number; if the target version number v0If the decoding condition is not 1 or 40, v can be successively determined according to the actual decoding condition and the appointed sequence0-1 and v0+1 is determined as a candidate version number.
In some embodiments, when the electronic device identifies the locators of the image of the two-dimensional code to be identified according to the preset color feature ratio, three "locators" may be directly identified, but this does not necessarily mean that the three "locators" are the real locators, and it can only be stated that three regions all satisfy the color feature ratio in the preset direction. In a real environment, a certain area around the two-dimensional code may satisfy the color feature ratio in a preset direction, which may result in misidentification of the locator. Referring to fig. 10, fig. 10 shows an example of a locator misidentification. In fig. 10, the locator at the lower right corner of the two-dimensional code is contaminated and cannot be recognized as the real locator through the color feature ratio, and a very small area in the surrounding environment happens to satisfy the color feature ratio in all directions, so that the area is mistakenly recognized as the "locator" by the electronic device. Of course, when the electronic device recognizes four or more "locators", it means that there must be "locators" that are misrecognized. Based on this, the electronic device can perform preliminary screening on the recognition result obtained according to the color feature proportion, and delete the 'locator' with wrong separation spectrum, so as to obtain the real locator. Step 101 may specifically include:
identifying the image of the two-dimensional code to be identified according to a preset color characteristic proportion; if the number of the identified locators is less than 3, determining the identified locators as real locators; if the number of identified locators is greater than or equal to 3, calculating the average size of all identified locators; respectively calculating the size error of the size of each locator and the average size; if the target size error exists, deleting the locator corresponding to the target size error, and determining the locator which is not deleted as a real locator; wherein, the target size error refers to a size error exceeding a preset size error threshold.
As can be seen from the above, in the embodiment of the present application, in the case that the number of the identified real locators is insufficient due to the dirty locators of the two-dimensional code, the electronic device fully considers the geometric features of the identified real locators in the two-dimensional code, and infers the remaining real locators according to the geometric features. Due to the fact that the operation pressure of the geometric reasoning on the electronic equipment is small, the electronic equipment can recognize all real locators in a short time, the accuracy rate of the electronic equipment for recognizing the locators is guaranteed, and the success rate of the electronic equipment for recognizing the two-dimensional codes is improved to a certain extent.
Corresponding to the two-dimension code identification method provided above, the embodiment of the application further provides a two-dimension code identification device. Referring to fig. 11, the two-dimensional code recognition apparatus 1100 includes:
the first identification module 1101 is configured to identify a real locator in an image of a two-dimensional code to be identified according to a preset color feature ratio;
the first determining module 1102 is configured to determine a geometric feature of the two-dimensional code to be recognized in the image if the number of the recognized real locators is not complete;
a searching module 1103, configured to search for at least two suspected locators in the image according to the geometric features;
a second determining module 1104, configured to determine remaining real locators in the at least two suspected locators;
a second identifying module 1105, configured to identify the two-dimensional code to be identified based on all the real locators.
Optionally, the first determining module 1102 includes:
the first geometric feature determining unit is used for determining a central point of a real locator and a vertex of the two-dimensional code to be identified in the image if the real locator is identified;
and the second geometric feature determination unit is used for determining the central 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.
Optionally, the vertex determining manner includes:
aiming at the graph of each vertex to be determined, searching the farthest points of the boundary of the graph in at least four specified directions respectively, wherein the graph of the vertex to be determined comprises the following steps: a central black block of the two-dimensional code or the real locator to be identified;
calculating the distance between every two farthest points, and determining the two farthest points with the farthest distances as the top points of the graph;
respectively determining farthest points which are farthest away from the designated connecting line as vertexes of the graph on two sides of the designated connecting line, wherein the designated connecting line is as follows: the line connecting the two farthest points that are farthest away.
Optionally, the lookup module 1103 includes:
the first suspected center point determining unit is used for determining 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 under the condition that the real locator is identified, wherein the first two-dimensional code vertex is as follows: the vertex of the two-dimensional code to be identified, which is closest to the central point of the real locator, is the vertex of the second two-dimensional code: the vertex of the two-dimensional code to be identified, which is farthest from the central point of the real locator;
the second suspected center point determining unit is used for determining a second suspected center point and a third suspected center point in the image according to the intersection point of the first straight line, the second straight line, the third straight line and the fourth straight line, wherein the first straight line is as follows: a straight line passing through the center point of the real locator and being parallel to the first edge 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 edge of the two-dimensional code to be identified; the third straight line is: a straight line passing through the first suspected center point and being parallel to the first edge; the fourth straight line is: a straight line passing through the first suspected center point and being parallel to the second edge; the first edge and the second edge are adjacent.
And the first suspected locator determining unit is used for determining corresponding suspected locators according to the first suspected center point, the second suspected center point and the third suspected center point respectively.
Optionally, the lookup module 1103 includes:
the position relation judging unit is used for judging the position relation of the two real locators in the two-dimensional code to be identified under the condition that the two real locators are identified;
the third suspected central point determining unit is used for determining at least two suspected central points in the image according to the position relation and the geometric characteristics;
and the second suspected locator determining unit is used for determining corresponding suspected locators according to the at least two suspected center points respectively.
Optionally, the center black blocks of the two real locators are respectively a first center black block and a second center black block, and the third suspected center point determining unit is specifically configured to determine at least two suspected center points in the image according to intersection points of a fifth straight line, a sixth straight line, a seventh straight line and an eighth straight line outside the two real locators when the positional relationship is an adjacent relationship, where the fifth straight line and the sixth straight line are respectively straight lines where diagonals of the first center black block are located, the diagonal line of the first center black block is determined according to a vertex of the first center black block, the seventh straight line and the eighth straight line are respectively straight lines where diagonals of the second center black block are located, and the diagonal line of the second center black block is determined according to a vertex of the second center black block.
Optionally, the two real locators are respectively marked as a first real locator and a second real locator, a central black block of the first real locator is marked as a first central black block, a central black block of the second real locator is marked as a second central black block, and the third suspected center point determining unit is specifically configured to determine, when the positional relationship is a diagonal relationship, at least two suspected center points in the image according to intersection points of a ninth line, a tenth line, an eleventh line, and a twelfth line outside the two real locators, where the ninth 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 a center point of the first real locator and parallel to a fourth side of the first center black block; the eleventh straight line is: a straight line passing through a center point of the second real locator and parallel to a 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 edge and the fourth edge are adjacent, and the third edge and the fourth edge are determined according to the vertex of the first central black block; the fifth side and the sixth side are adjacent, and the fifth side and the sixth side are determined according to the vertex of the second center black block.
Optionally, the second identifying module 1105 includes:
a calculation unit configured to calculate a relative distance between any two adjacent real locators when three real locators have been identified;
the target version number determining unit is used for determining a target version number of the two-dimensional code to be identified according to the relative distance;
the analysis unit is used for analyzing the two-dimensional code to be identified according to the target version number;
the candidate version number determining unit is further used for determining a version number adjacent to the target version number as a candidate version number if the analysis fails;
and the analyzing unit is also used for analyzing the two-dimensional code to be identified again according to the candidate version number.
As can be seen from the above, in the embodiment of the present application, in the case that the number of the identified real locators is insufficient due to the dirty locators of the two-dimensional code, the electronic device fully considers the geometric features of the identified real locators in the two-dimensional code, and infers the remaining real locators according to the geometric features. Due to the fact that the operation pressure of the geometric reasoning on the electronic equipment is small, the electronic equipment can recognize all real locators in a short time, the accuracy rate of the electronic equipment for recognizing the locators is guaranteed, and the success rate of the electronic equipment for recognizing the two-dimensional codes is improved to a certain extent.
Corresponding to the two-dimensional code identification method provided above, the embodiment of the application further provides an electronic device. Referring to fig. 12, the electronic device 12 in the embodiment of the present application includes: a memory 1201, one or more processors 1202 (only one shown in fig. 12), and a computer program stored on the memory 1201 and executable on the processors. Wherein: the memory 1201 is used for storing 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, so as to acquire resources corresponding to the preset events. Specifically, the processor 1202 implements each step in the above method embodiments by running the above computer program stored in the memory 1201, and details are not described here.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned functions may be distributed as different functional units and modules according to needs, that is, the internal structure of the apparatus may be divided into different functional units or modules to implement all or part of the above-mentioned functions. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working processes of the units and modules in the system may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the above embodiments, the description of each embodiment has its own emphasis, and reference may be made to the related description of other embodiments for parts that are not described or recited in any embodiment.
The integrated unit may be stored in a computer-readable storage medium if it is implemented in the form of a software functional unit and sold or used as a separate product. Based on such understanding, all or part of the flow in the method of the embodiments described above can be realized by the present application, and the computer program can also be executed by associated hardware, and the computer program can be stored in a computer readable storage medium, and when the computer program is executed by a processor, the steps of the method embodiments described above can be realized. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable storage medium may include: any entity or device capable of carrying the above-described computer program code, recording medium, U disk, removable hard disk, magnetic disk, optical disk, computer readable Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier signal, telecommunications signal, software distribution medium, and the like. It should be noted that the computer-readable storage media described above may be appropriately increased or decreased as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer-readable storage media may not include electrical carrier signals or telecommunication signals in accordance with legislation and patent practice.
The above embodiments are only used to illustrate the technical solutions of the present application, and not to limit the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present application and are intended to be included within the scope of the present application.

Claims (11)

1. A two-dimensional code recognition method is characterized by comprising the following steps:
identifying a real locator in the image of the two-dimensional code to be identified according to a preset color characteristic proportion;
if the number of the identified real locators is not complete, determining the geometric features of the two-dimensional code to be identified in the image;
according to the geometric features, at least two suspected locators are found in the image;
determining remaining real locators in the at least two suspected locators;
and identifying the two-dimensional code to be identified based on all the real locators.
2. The method for identifying two-dimensional codes according to claim 1, wherein if the number of the identified real locators is not complete, determining the geometric features of the two-dimensional codes to be identified in the image comprises:
if one real locator is identified, determining a central point of the real locator and a vertex of the two-dimensional code to be identified in the image;
if two real locators are identified, determining a center point of each real locator and a vertex of a center black block of each real locator in the image.
3. The two-dimensional code recognition method of claim 2, wherein the vertex determination method comprises:
for each graph of the vertex to be determined, finding the farthest points of the boundary of the graph in at least four specified directions respectively, wherein the graph of the vertex to be determined comprises: the center black block of the two-dimensional code to be identified or the real locator;
calculating the distance between every two farthest points, and determining the two farthest points with the farthest distance as the vertexes of the graph;
determining the farthest points farthest from the designated connecting line as the vertexes of the graph respectively on two sides of the designated connecting line, wherein the designated connecting line is as follows: the line connecting the two farthest points which are farthest away.
4. The two-dimensional code recognition method according to claim 2, wherein, in a case where one of the real locators is recognized, the finding out at least two suspected locators in the image according to the geometric features includes:
determining a first suspected central point in the image according to the central point of the real locator, a first two-dimensional code vertex and a second two-dimensional code vertex, wherein the first two-dimensional code vertex is as follows: the vertex of the two-dimensional code to be identified, which is closest to the central point of the real locator, is the vertex of the second two-dimensional code: the vertex of the two-dimensional code to be identified is farthest from the central point of the real locator;
determining a second suspected center point and a third suspected center point in the image according to the intersection point of the first straight line, the second straight line, the third straight line and the fourth straight line, wherein the first straight line is as follows: a straight line passing through the center point of the real locator and being parallel to the first edge 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 edge of the two-dimensional code to be identified; the third straight line is: a line passing through the first suspected center point and parallel to the first edge; the fourth straight line is: a line passing through the first suspected center point and parallel to the second edge; the first edge and the second edge are adjacent, and the first edge and the second edge are determined according to the vertex of the two-dimensional code to be identified;
and determining corresponding suspected locators according to the first suspected center point, the second suspected center point and the third suspected center point respectively.
5. The two-dimensional code recognition method according to claim 2, wherein, in a case where two true locators are recognized, the finding out at least two suspected locators in the image according to the geometric features includes:
judging the position relation of the two real locators in the two-dimensional code to be identified;
determining at least two suspected central points in the image according to the position relation and the geometric characteristics;
and determining corresponding suspected locators according to the at least two suspected central points respectively.
6. The two-dimensional code recognition method according to claim 5, wherein the step of recording center black blocks of the two real locators as a first center black block and a second center black block respectively, and the step of determining at least two suspected center points in the image according to the position relationship and the geometric feature includes:
and under the condition that the position relationship is an adjacent relationship, determining at least two suspected center points in the image according to intersection points of a fifth straight line, a sixth straight line, a seventh straight line and an eighth straight line outside the two real locators, wherein the fifth straight line and the sixth straight line are respectively straight lines where diagonal lines of the first center black block are located, the diagonal lines of the first center black block are determined according to the vertex of the first center black block, the seventh straight line and the eighth straight line are respectively straight lines where diagonal lines of the second center black block are located, and the diagonal lines of the second center black block are determined according to the vertex of the second center black block.
7. The two-dimensional code identification method according to claim 5, wherein the step of marking two real locators as a first real locator and a second real locator respectively, marking a central black block of the first real locator as a first central black block, and marking a central black block of the second real locator as a second central black block, wherein the step of determining at least two suspected central points in the image according to the position relationship and the geometric features comprises:
determining at least two suspected center points in the image according to intersection points of a ninth straight line, a tenth straight line, an eleventh straight line and a twelfth straight line outside the two real locators when the position relationship is a diagonal relationship, wherein the ninth straight line is: a 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 line passing through a center point of the first real locator and parallel to a fourth side of the first center black block; the eleventh straight line is: a straight line passing through a center point of the second real locator and parallel to a fifth side of the second center black block; the twelfth straight line is: a straight line passing through a center point of the second real locator and parallel to a sixth side of the second center black block; the third side and the fourth side are adjacent and determined according to the vertex of the first central black block; the fifth edge and the sixth edge are adjacent, and the fifth edge and the sixth edge are determined according to vertices of the second center black block.
8. The two-dimensional code identification method according to any one of claims 1 to 7, wherein the identifying the two-dimensional code to be identified based on all the real locators comprises:
in the case where three real locators have been identified, calculating the relative distance between any two adjacent real locators;
determining a target version number of the two-dimensional code to be identified according to the relative distance;
analyzing the two-dimensional code to be identified according to the target version number;
if the analysis fails, determining a version number adjacent to the target version number as a candidate version number;
and analyzing the two-dimensional code to be identified again according to the candidate version number.
9. The utility model provides a two-dimensional code recognition device which characterized in that includes:
the first identification module is used for identifying a real locator in the image of the two-dimensional code to be identified according to a preset color characteristic proportion;
the first determining module is used for determining the geometric characteristics of the two-dimensional code to be recognized in the image if the number of the recognized real locators is not complete;
the searching module is used for searching at least two suspected locators in the image according to the geometric features;
a second determining module for determining remaining real locators among the at least two suspected locators;
and the second identification module is used for identifying the two-dimensional code to be identified based on all the real locators.
10. 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 method of any of claims 1 to 8 when executing the computer program.
11. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1 to 8.
CN202210377276.6A 2022-04-12 2022-04-12 Two-dimensional code identification method, two-dimensional code identification device and electronic equipment Pending CN114781417A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210377276.6A CN114781417A (en) 2022-04-12 2022-04-12 Two-dimensional code identification method, two-dimensional code identification device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210377276.6A CN114781417A (en) 2022-04-12 2022-04-12 Two-dimensional code identification method, two-dimensional code identification device and electronic equipment

Publications (1)

Publication Number Publication Date
CN114781417A true CN114781417A (en) 2022-07-22

Family

ID=82428282

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210377276.6A Pending CN114781417A (en) 2022-04-12 2022-04-12 Two-dimensional code identification method, two-dimensional code identification device and electronic equipment

Country Status (1)

Country Link
CN (1) CN114781417A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116778195A (en) * 2023-08-16 2023-09-19 北京华源技术有限公司 Equipment identification method and system based on color codes

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116778195A (en) * 2023-08-16 2023-09-19 北京华源技术有限公司 Equipment identification method and system based on color codes
CN116778195B (en) * 2023-08-16 2023-11-24 北京华源技术有限公司 Equipment identification method and system based on color codes

Similar Documents

Publication Publication Date Title
JP4301775B2 (en) Two-dimensional code reading device, two-dimensional code reading method, two-dimensional code reading program, and recording medium for the program
WO2020119301A1 (en) Two-dimensional code identification method, apparatus, and device
US5054094A (en) Rotationally impervious feature extraction for optical character recognition
Zamberletti et al. Robust angle invariant 1d barcode detection
WO2013044875A1 (en) Linear barcode identification method and system
JP2018142189A (en) Program, distance measuring method, and distance measuring device
JP7121132B2 (en) Image processing method, apparatus and electronic equipment
CN114781417A (en) Two-dimensional code identification method, two-dimensional code identification device and electronic equipment
CN113297870A (en) Image processing method, image processing device, electronic equipment and computer readable storage medium
CN117911668A (en) Drug information identification method and device
WO2022021687A1 (en) Method for positioning quick response code area, and electronic device and storage medium
CN111914890B (en) Image block matching method between images, image registration method and product
Zhao et al. Learning probabilistic coordinate fields for robust correspondences
Santellani et al. S-TREK: Sequential Translation and Rotation Equivariant Keypoints for local feature extraction
CN110969612B (en) Two-dimensional code printing defect detection method
CN116542998B (en) Contour detection method, device, equipment and medium for photoetching film inductance
CN109977715B (en) Two-dimensional code identification method based on contour identification and two-dimensional code
CN116678418A (en) Improved laser SLAM quick loop-back detection method
CN111523331B (en) Two-dimensional code identification method and device
CN111767752A (en) Two-dimensional code identification method and device
CN111340134A (en) Rapid template matching method based on local dynamic warping
Rampurkar et al. An approach towards text detection from complex images using morphological techniques
CN114359322A (en) Image correction and splicing method, and related device, equipment, system and storage medium
Shao et al. Grouped outlier removal for robust ellipse fitting
CN117237657A (en) RSCD arc detection method based on hough transformation

Legal Events

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