CN110543798A - two-dimensional code identification method and device - Google Patents

two-dimensional code identification method and device Download PDF

Info

Publication number
CN110543798A
CN110543798A CN201910738952.6A CN201910738952A CN110543798A CN 110543798 A CN110543798 A CN 110543798A CN 201910738952 A CN201910738952 A CN 201910738952A CN 110543798 A CN110543798 A CN 110543798A
Authority
CN
China
Prior art keywords
dimensional code
color block
unit color
current sampling
pixel
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.)
Granted
Application number
CN201910738952.6A
Other languages
Chinese (zh)
Other versions
CN110543798B (en
Inventor
屠寅海
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Advanced New Technologies Co Ltd
Advantageous New Technologies Co Ltd
Original Assignee
Alibaba Group Holding Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN201910738952.6A priority Critical patent/CN110543798B/en
Publication of CN110543798A publication Critical patent/CN110543798A/en
Application granted granted Critical
Publication of CN110543798B publication Critical patent/CN110543798B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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/14Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation using light without selection of wavelength, e.g. sensing reflected white light
    • G06K7/1404Methods for optical code recognition
    • G06K7/1408Methods for optical code recognition the method being specifically adapted for the type of code
    • G06K7/14172D bar codes
    • 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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/11Region-based segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/90Determination of colour characteristics
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10024Color image
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20021Dividing image into blocks, subimages or windows

Landscapes

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

Abstract

the embodiment of the specification provides a method and a device for identifying a two-dimensional code, according to an implementation mode, obtaining a two-dimensional code image to be identified, determining the arrangement density of unit color blocks in the two-dimensional code image, and respectively selecting corresponding current sampling pixels for the unit color blocks according to a preset rule, wherein the arrangement density indicates the number and the arrangement mode of the unit color blocks in the two-dimensional code image, then adjusting the current sampling pixels of the unit color blocks based on the color comparison between the current sampling pixels and adjacent pixels, and then determining the corresponding numerical values of the corresponding unit color blocks according to the adjusted colors of the current sampling pixels of the unit color blocks, so as to identify information contained in the two-dimensional code. Therefore, the accuracy of two-dimension code identification can be improved.

Description

two-dimensional code identification method and device
Technical Field
one or more embodiments of the present specification relate to the field of computer technology, and more particularly, to a method and apparatus for identifying information contained in a two-dimensional code by a computer.
background
two-dimensional bar code (also called two-dimensional bar code) is a bar code with readability expanded on the basis of one-dimensional bar code, and is characterized in that data symbol information is recorded by black and white alternate patterns distributed in a plane two-dimensional direction according to a certain rule by using a certain specific geometric figure, and the information is automatically read by image input equipment or photoelectric scanning equipment to realize automatic information processing by using the concepts of '0' and '1' bit streams forming the internal logic basis of a computer in code compilation and using a plurality of geometric shapes corresponding to binary systems to represent character numerical information. Common two-dimensional code forms are for example: MaxiCode (bovine eye Code), Aztec Code (Aztec Code), QR Code (quick response Code), and the like.
with the development of terminal technology, the two-dimensional code has wide application in daily life, for example, code scanning payment, information push and the like, and various information can be hidden in the two-dimensional code for rapid propagation. Therefore, the recognition of the two-dimensional code becomes very important. Since the black and white patterns in the two-dimensional code correspond to "0" or "1" in the binary number, respectively, the information contained therein is generally recognized by a pattern arrangement rule that recognizes black and white colors. In real life, the situation that two-dimension code identification fails can be met, and when two-dimension code identification failed samples are checked, the two-dimension code distortion samples account for a large proportion. Even if the two-dimensional code is laid on a non-plane surface, the two-dimensional code has nonlinear distortion. In this case, the difficulty of two-dimensional code recognition increases.
disclosure of Invention
One or more embodiments of the present specification describe a two-dimensional code recognition method and apparatus, which can fully consider the problem of nonlinear distortion of a two-dimensional code in a two-dimensional code recognition process, and improve the effectiveness of two-dimensional code recognition.
According to a first aspect, a two-dimensional code identification method is provided, and the method includes: acquiring a two-dimensional code image to be identified; determining the arrangement density of unit color blocks in the two-dimensional code image, and respectively selecting corresponding current sampling pixels for the unit color blocks according to a preset rule, wherein the arrangement density indicates the number and the arrangement mode of the unit color blocks in the two-dimensional code image; adjusting the current sampling pixel of each unit color block based on the color contrast of each current sampling pixel and the adjacent pixel; and determining the corresponding numerical value of the corresponding unit color block according to the adjusted color of the current sampling pixel of each unit color block, thereby identifying the information contained in the two-dimensional code.
In one embodiment, the determining the arrangement density of the unit color blocks in the two-dimensional code image includes: detecting a positioning graph in the two-dimensional code image according to a first proportional relation between the sizes of all color blocks in the positioning graph, wherein the size of the positioning graph and the size of a unit color block have a second proportional relation; determining the size of a unit color block in the two-dimensional code image according to the first proportional relation, the second proportional relation and the size of a positioning graph in the two-dimensional code image; and determining the arrangement density based on the size of the two-dimensional code image and the size of the unit color blocks in the two-dimensional code image.
In one embodiment, after determining the arrangement density of the unit color blocks in the two-dimensional code image, the method further includes dividing each unit region in the two-dimensional code image according to the arrangement density, where each unit region corresponds to each unit color block, and the divided unit regions include a first unit region, where the first unit region corresponds to the first unit color block; the predetermined rule includes at least one of: taking the pixel at the upper left corner of the first unit area as the current sampling pixel of the first unit color block; taking a pixel at the center position of the first unit area as a current sampling pixel of the first unit color block; and taking one of the four pixels at the central position of the first unit area as a current sampling pixel of the first unit color block.
In one embodiment, the predetermined rules include: determining a two-dimensional code standard coordinate system according to the position of at least one positioning graph in the two-dimensional code image, wherein the size of each color block in the positioning graph meets a first proportional relation; establishing a mapping relation between the two-dimension code standard coordinate system and an image coordinate system of the two-dimension code image; determining the central point of each unit color block in the two-dimensional code standard coordinate system according to the arrangement density; respectively mapping each central point to the image coordinate system according to the mapping relation to obtain each corresponding mapping point; and taking the pixel corresponding to each mapping point as the current sampling pixel of the corresponding unit color block.
In a further embodiment, the establishing a mapping relationship between the two-dimensional code standard coordinate system and the image coordinate system of the two-dimensional code image includes: acquiring a first coordinate and a second coordinate of the central point of each positioning graph in the two-dimensional code standard coordinate system and the image coordinate system respectively; inputting coordinate values in the first coordinate and the second coordinate into a mapping relation model containing undetermined parameters; and solving the undetermined parameters so as to determine the mapping relation.
In one embodiment, the unit color block includes a first unit color block whose neighboring pixels of a current sampled pixel include a first neighboring pixel along a first direction of the current sampled pixel of the first unit color block; the adjusting the current sampling pixel of each unit color block based on the color contrast of each current sampling pixel and the adjacent pixel comprises: and when the color of the current sampling pixel of the first unit color block is inconsistent with the color of the first adjacent pixel, adjusting the current sampling pixel of the first unit color block to the opposite direction of the first direction by a preset number of pixels.
In one embodiment, said adjusting the current sample pixel of each unit color block based on the color contrast of each current sample pixel with the neighboring pixels comprises: sequentially adjusting the current sampling pixel of each unit color block according to a preset traversal mode, wherein the preset traversal mode comprises at least one of the following items: traversing from left to right and from top to bottom; traversing from the middle to the two sides according to rows, wherein traversing is carried out from top to bottom for each row; and performing circular diffusion traversal from the center to the periphery.
In one embodiment, the unit color patches in the two-dimensional code image include a second unit color patch, and a third unit color patch adjacent to the second unit color patch; the adjusting the current sampling pixel of each unit color block based on the color contrast of each current sampling pixel and the adjacent pixel comprises: and when the current sampling pixel of the second unit color block is adjusted, at least carrying out linkage adjustment on the current sampling pixel of the third unit color block according to a preset linkage rule, wherein the adjustment distance of the current sampling pixel of the third unit color block is positively correlated with the adjustment distance of the current sampling pixel of the second unit color block.
in a further embodiment, the linkage rules include at least one of: the adjustment distance of the current sampling pixel of the third unit color block is consistent with the adjustment distance of the current sampling pixel of the second unit color block; the adjustment distance of the current sampling pixel of the third unit color block and the adjustment distance of the current sampling pixel of the second unit color block have a preset ratio smaller than 1; the adjustment distance of the current sampling pixel of the third unit color block has a linear relation with the spacing distance between the third unit color block and the second unit color block.
according to a second aspect, there is provided an apparatus for recognizing a two-dimensional code, the apparatus comprising:
The acquisition module is configured to acquire a two-dimensional code image to be identified;
The selection module is configured to determine the arrangement density of unit color blocks in the two-dimensional code image, and select corresponding current sampling pixels for the unit color blocks according to a predetermined rule, wherein the arrangement density indicates the number and the arrangement mode of the unit color blocks in the two-dimensional code image;
the adjusting module is configured to adjust the current sampling pixels of the unit color blocks based on the color contrast of the current sampling pixels and the adjacent pixels;
and the identification module is configured to determine a numerical value corresponding to each unit color block according to the adjusted color of the current sampling pixel of each unit color block, so as to identify the information contained in the two-dimensional code.
according to a third aspect, there is provided a computer readable storage medium having stored thereon a computer program which, when executed in a computer, causes the computer to perform the method of the first aspect.
according to a fourth aspect, there is provided a computing device comprising a memory and a processor, wherein the memory has stored therein executable code, and wherein the processor, when executing the executable code, implements the method of the first aspect.
through the two-dimensional code identification method and device provided by the embodiments of the present specification, a two-dimensional code image to be identified is obtained, the arrangement density of unit color blocks in the two-dimensional code image is determined, and corresponding current sampling pixels are respectively selected for each unit color block according to a predetermined rule, where the arrangement density of the two-dimensional code indicates the number and arrangement manner of the unit color blocks in the two-dimensional code image, then the current sampling pixels of each unit color block are adjusted based on the color comparison between each current sampling pixel and an adjacent pixel, and then the corresponding numerical values of the corresponding unit color blocks are determined according to the adjusted color of the current sampling pixels of each unit color block, so as to identify information included in the two-dimensional code. In the two-dimensional code identification process, each current sampling pixel selected for each unit color block according to a preset rule is used as an initial current sampling pixel and is continuously adjusted to finally obtain more accurate sampling pixels, so that the accuracy of two-dimensional code identification can be improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
FIG. 1 illustrates a schematic diagram of an implementation scenario of an embodiment disclosed herein;
fig. 2 shows a flowchart of a method for identifying a two-dimensional code according to an embodiment;
Fig. 3 shows a two-dimensional code diagram of a specific example;
4 a-4 c illustrate schematic diagrams of a current sample pixel selected for a unit patch according to various embodiments;
FIG. 5 illustrates a current sample pixel adjustment diagram for a specific example;
fig. 6 shows a schematic block diagram of an identification apparatus of a two-dimensional code according to an embodiment.
Detailed Description
The scheme provided by the specification is described below with reference to the accompanying drawings.
For convenience of explanation, a specific application scenario of the embodiment of the present specification shown in fig. 1 is described. In the implementation scenario of fig. 1, a user may scan any two-dimensional code image through various applications related to scanning on the terminal, so as to identify information therein, such as payment information, pushed news information, applet information, shopping information, APP information, and so on.
As can be understood by those skilled in the art, the two-dimensional code is formed by arranging a plurality of color blocks with the same size. The color block color corresponding to each color block corresponds to a corresponding numerical value, for example, the minimum color block of black and white, that is, the unit color block, corresponds to the numbers "1" and "0", respectively. Therefore, in a general two-dimensional code identification process, a user opens an application capable of identifying the two-dimensional code on the terminal, aligns a camera or a scanner on the terminal with the two-dimensional code to obtain a two-dimensional code image, and identifies information in the two-dimensional code according to a minimum black/white block on the two-dimensional code image.
However, as shown in fig. 1, in some cases, the two-dimensional code image may be attached to a non-planar structure, and the two-dimensional code may change non-linearly on the image, such as being distorted, being blocked, and the like. In this case, when the terminal divides each color block, an error may occur, which may result in that information of the two-dimensional code cannot be effectively recognized.
In the process of identifying the two-dimensional code, each unit color block in the two-dimensional code image can be roughly divided according to the width and the height of the two-dimensional code. Here, the unit color block is a color block corresponding to one numerical value, and when the two-dimensional code is generated, colors in the unit color block are generally consistent. A plurality of consecutive cell patches may also have the same color, making up a visually larger patch of graphics. However, such larger patches are typically not considered as a whole in the data processing identification process. In the two-dimensional code identification and generation processes, the minimum color block needs to be segmented. Then, a pixel may be determined from at least one pixel corresponding to each unit color block as a sampling pixel of the corresponding unit color block according to a predetermined rule. In the conventional technique, sampling may be performed according to each sampling pixel, that is, a value corresponding to each unit color block is determined. In the embodiment of the present specification, each sampling pixel determined by a predetermined rule is used as an initial sampling pixel of a corresponding color block, each initial sampling pixel is adjusted based on a color comparison between each initial sampling pixel and an adjacent pixel, so as to obtain each final sampling pixel corresponding to each unit color block, and each final sampling pixel is sampled, that is, the color of each final sampling pixel is identified, so as to determine a numerical value corresponding to the corresponding unit color block. Thereby recognizing the information contained in the two-dimensional code. Thus, through the optimization of the sampling pixels, the two-dimensional code information can be identified more accurately.
It is worth to be noted that the two-dimensional code identification method provided in this specification can be applied to any two-dimensional code identification situation, and especially in the case of two-dimensional code identification with nonlinear change, the sampling accuracy of color blocks is improved by adjusting the sampling pixels of each color block, so that the effectiveness of two-dimensional code identification can be improved.
the method for recognizing the two-dimensional code will be described in detail below.
Fig. 2 shows a flowchart of a method for identifying a two-dimensional code according to an embodiment. The execution subject of the method can be any system, device, apparatus, platform or server with computing and processing capabilities. Such as the terminal shown in fig. 1.
As shown in fig. 2, the method for identifying a two-dimensional code may include the following steps: step 201, acquiring a two-dimensional code image to be identified; step 202, determining the arrangement density of unit color blocks in the two-dimensional code image, and respectively selecting corresponding current sampling pixels for each unit color block according to a preset rule, wherein the arrangement density indicates the number and the arrangement mode of the unit color blocks in the two-dimensional code image; step 203, adjusting each initial sampling pixel based on the color contrast of each initial sampling pixel and the adjacent pixel; and step 204, determining a numerical value corresponding to the corresponding unit color block according to the adjusted color of the current sampling pixel of each unit color block, thereby identifying the information contained in the two-dimensional code.
First, in step 201, a two-dimensional code image to be recognized is acquired. As the name implies, the image of the two-dimensional code to be recognized is the image containing the two-dimensional code to be recognized. Generally, a two-dimensional code image may be acquired by a camera or a scanner or the like on the terminal.
in particular practice, the captured image process may not only include the two-dimensional code, but also may include other interfering elements, such as the background of the two-dimensional code sticker. In one possible implementation, the acquired image can be cut in the edge area of the two-dimensional code, and only the minimum image containing the two-dimensional code part is reserved as the two-dimensional code image.
Next, in step 202, the arrangement density of the unit color blocks in the two-dimensional code image is determined, and corresponding current sampling pixels are respectively selected for each unit color block according to a predetermined rule. Wherein, the unit color blocks are the minimum units forming the two-dimensional code. Each unit color block corresponds to only one color, i.e., one number. It is understood that the number of unit color patches is usually less than the number of pixels of the two-dimensional code image, that is, one unit color patch may correspond to at least one pixel. The arrangement density can indicate the number and arrangement mode of unit color blocks in the two-dimensional code image.
When the arrangement density of the unit color blocks of the two-dimensional code is determined, the size of the unit color blocks on the two-dimensional code image is determined firstly. It is understood that the cell patch size in the two-dimensional code image is related to the current size of the captured two-dimensional code image, and not the size inherent in the two-dimensional code image generation. The determination method of the unit color patch size may be various.
In one embodiment, the minimum width and the minimum length corresponding to a pattern of a certain color in the two-dimensional code image may be detected as the size of the unit color block. As shown in fig. 3, the color block 301 has the minimum width and the minimum length in the graph and is the minimum color block in the two-dimensional code, and the length and the width of the color block 301 can be represented by a unit of 1 in the standard coordinate system of the two-dimensional code, and can be represented by a specific size in the image or a corresponding number of pixels in the two-dimensional code image.
In another embodiment, the graphics with special size and meaning in the two-dimensional code can be detected first, and the size of the unit color block can be determined according to the graphics with special size and meaning. For example, in QR Code, there are typically 3 positioning patterns, each shown as pattern 302 in FIG. 3. The three graphs can be respectively positioned at the upper left corner, the upper right corner and the lower left corner of the two-dimensional code. In the positioning pattern, the sizes of the color blocks may have a predetermined first proportional relationship. For example, the length ratio of black, white, and black colors in the longitudinal direction of the graph 302 is 1: 1: 3; 1: 1. the size of the positioning pattern and the size of the unit color patches may also have a predetermined second proportional relationship. For example, in fig. 3, the length of the black patch around the pattern 302 coincides with the cell patch. In other words, if the length of the minimum color block is unit 1, the lengths of the black, white, and black colors in the longitudinal direction in the graph 302 are 1, 3, 1, and 1, respectively. In this way, the lengths of the black, white, and black colors detected in the two-dimensional code image have a ratio of 1: 1: 3; 1: 1 (the same width) image, that is, the positioning pattern, further determines the size of the unit color patch (minimum color patch).
In other embodiments, the size of the unit color blocks may be determined in more ways, which is not described herein again.
After the size of the unit color blocks in the two-dimensional code image is obtained, the arrangement density of each unit color block in the two-dimensional code image can be further determined. Wherein the arrangement density can be represented by an array layout of the unit color patches. For example, 21 × 21 indicates 21 unit patches in the length direction and 21 unit patches in the width direction.
in an optional implementation manner, the arrangement density may be determined by dividing the size of the two-dimensional code image by the size of the unit color blocks, specifically, dividing the length of the two-dimensional code image by the length of the unit color blocks as the number of color blocks in the length direction, and dividing the width of the two-dimensional code image by the width of the unit color blocks as the number of color blocks in the width direction. In general, the length direction mentioned in the present specification may be a lateral direction in fig. 3, and the width direction may be a vertical direction in fig. 3.
in another optional implementation manner, the two-dimensional code image may be further divided along the length direction and the width direction according to the size of the unit color block, and one unit color block is divided in the length direction every time the unit color block passes through the length size of one unit color block. Similarly, the unit patches are divided in the width direction, so that the number of the unit patches in the two-dimensional code image and the arrangement density of the unit patches are obtained.
After the arrangement density of the unit color blocks in the two-dimensional code image is determined, the colors on the unit color blocks can be further sampled to determine the corresponding numerical values. It can be understood that, in the two-dimensional code, each unit color block corresponds to one color and corresponds to one numerical value. In general, one pixel may be selected as a sampling pixel from the pixels corresponding to the respective unit patches according to a predetermined rule.
According to one possible design, the current sampling pixel corresponding to each unit color block can be intuitively determined through the pixel corresponding to each unit color block. The predetermined rule is, for example, the pixel at the upper left corner of each unit patch, the pixel at the center of each unit patch, and the like.
When there are few pixels (e.g., 2 × 2 pixels) corresponding to the unit color block, the central pixel cannot be obtained, and the predetermined rule may be to take one pixel at the upper left corner, the upper right corner, the lower left corner, or the lower right corner. As shown in fig. 4a, 4 color blocks arranged adjacently are shown, and taking the white color block at the upper right corner as an example, the pixel marked by the bold dashed frame at the upper left corner may be taken as the current sampling pixel of the white color block at the upper right corner, corresponding to 4 pixels.
When the number of pixels corresponding to the unit color block is large (e.g., more than 3 × 3), the pixel at the center of the unit color block may be taken as the current sampling pixel. If the corresponding pixels of a unit color block are odd by odd (e.g., 3 × 3, 5 × 5, etc.), the predetermined rule may be to take one pixel at the center of the unit color block. As shown in fig. 4b, 4 color blocks arranged adjacently are shown, and taking the white color block at the upper right corner as an example, the pixel marked by the bold dashed frame at the center can be taken as the current sampling pixel of the white color block at the upper right corner, corresponding to 3 × 3 pixels. If the pixels corresponding to a unit color block are even × even (e.g., 4 × 4, 6 × 6, etc.), the predetermined rule may be to select any one of the four pixels in the center of the unit color block. As shown in fig. 4b, 4 color blocks arranged adjacently are shown, and taking the white color block at the upper right corner as an example, the pixel marked by the bold dashed frame at the center can be taken as the current sampling pixel of the white color block at the upper right corner, corresponding to 4 × 4 pixels.
when the actual two-dimensional code image is subjected to two-dimensional code recognition, factors such as the angle inclination of the acquired picture and the surface curvature to which the two-dimensional code is attached may exist. At this time, there may be phenomena of inconsistent lengths of opposite sides of the two-dimensional code image, a part of the unit color block being blocked, and the like. In this case, the unit color blocks cannot be accurately divided by a simple dividing method. At this time, the two-dimensional code image may be roughly divided according to the arrangement density of the unit patches to divide each unit area, and each unit area corresponds to one unit patch. In this way, the unit region and the unit patches do not strictly correspond, but each unit patch can find a corresponding unit region on the two-dimensional code image. The dividing mode of the unit area can adopt an equal dividing mode. That is, assuming that the arrangement density of the two-dimensional code is n × m, the length of the two-dimensional code image is equally divided into n parts, and the width is equally divided into m parts, thereby dividing n × m unit regions.
At this time, in the current pixel sampling method of the unit color blocks, the pixel corresponding to each unit color block is converted into the pixel corresponding to each unit area. That is, taking the first unit color block corresponding to the first unit region as an example, the predetermined rule for determining the current sampling pixel of each unit color block may be changed to:
Taking the upper left corner pixel of the first unit area as the current sampling pixel of the first unit color block; and/or
taking a pixel at the central position of the first unit area as a current sampling pixel of the first unit color block; and/or
and taking one of the four pixels at the central position of the first unit area as a current sampling pixel of the first unit color block.
The specific determination method and the use condition are consistent with the pixels directly corresponding to the unit color blocks, and are not described herein again. Since each unit patch corresponds to an approximate unit region, each unit patch can determine an initial current sample pixel.
According to another possible design, the preset rule may also be: determining a two-dimensional code standard coordinate system according to the position of at least one positioning graph in the two-dimensional code image, and establishing a mapping relation between the two-dimensional code standard coordinate system and an image coordinate system of the two-dimensional code image; determining the central point of each unit color block in a two-dimensional code standard coordinate system according to the arrangement density of the unit color blocks; respectively mapping each central point to an image coordinate system according to the mapping relation to obtain each mapping point; and taking the pixel corresponding to each mapping center point as the current sampling pixel of the corresponding unit color block.
the two-dimensional code standard coordinate system may be a coordinate system established by reference points included in the two-dimensional code itself, for example, a coordinate system established by using a positioning graph included in the two-dimensional code as a reference point, such as a coordinate system established by using an upper left corner of the graph 301 as an origin, a length direction as a horizontal axis, and a width direction as a vertical axis in a two-dimensional code image shown in fig. 3. The image coordinate system corresponding to the two-dimensional code image may be a coordinate system established by using a predetermined point in an acquisition frame for acquiring the two-dimensional code image as a reference point. For example, the upper right corner of the two-dimensional code image is an origin, and the horizontal direction of the two-dimensional code acquisition frame is a coordinate system established by the horizontal axis and the vertical direction of the two-dimensional code acquisition frame is a vertical axis. The image coordinate system can be preset by the equipment before the two-dimensional code image is acquired. The image of the two-dimensional code may have an inclination angle, curvature, or the like in the image coordinate system. The two-dimensional code standard coordinate system and the image coordinate system can have a definite mapping relation, and the mapping relation is used for expressing the coordinate transformation mode of the point in one coordinate system and the corresponding point in the other coordinate system. The mapping can be determined by knowing the coordinates of the points in the two coordinate systems, respectively. The mapping of the two-dimensional coordinate systems may for example have the form:
x=x'cosθ+y'sinθ+r;
y=y'cosθ+x'sinθ+t;
wherein, (x, y) can be a first coordinate in a standard coordinate system of the two-dimensional code, and (x ', y') can be a second coordinate of a point corresponding to (x, y) in an image coordinate system. Theta is a rotation angle of the two-dimensional code image coordinate system relative to the two-dimensional code standard coordinate system, r is a translation parameter of a horizontal axis between the two coordinate systems, and t is a translation parameter of a vertical axis between the two coordinate systems. Before the mapping relation is determined, theta, r and t are undetermined parameters, and the mapping relation expression can also be called a mapping relation model. The above undetermined parameters can be solved through the coordinates of the easily recognized special points in the two coordinate systems respectively. Taking QR Code as an example, first, the center points of three positioning patterns with special size and meaning can be determined, and the first coordinate and the second coordinate of the three center points in the two-dimensional Code standard coordinate system and the image coordinate system are easy to be determined. And correspondingly substituting the coordinates of the three points into the formula, and solving the parameters r, t and theta to obtain the mapping relation of the two coordinate systems. In some cases, the mapping relationship needs to be determined by an auxiliary positioning graph (such as the graph 302 in fig. 3) at the bottom right corner of the two-dimensional code, which is not described herein again.
It is understood that, in the case where the arrangement density of the unit patches is known, the distance between the centers of the adjacent unit patches is 1 unit in the standard coordinate system of the two-dimensional code, and the standard coordinates of the centers of the respective unit patches are also easily determined. According to the coordinates of the center point of each unit color block in the two-dimensional code standard coordinate system and the determined mapping relationship, the coordinates of the corresponding mapping point of the center point of each unit color block in the image coordinate system and the corresponding pixels can be obtained, so that the current sampling pixel of each unit color block is determined in the two-dimensional code image.
because of the influence of factors such as the angle of an acquired picture and the surface curvature attached to a two-dimensional code when the actual two-dimensional code image is subjected to two-dimensional code recognition, the current sampling pixels of the determined unit color block may have a deviation, for example, a plurality of pixels corresponding to the unit area may correspond to different colors. For example, in the case of a non-linear distortion of a two-dimensional code in a two-dimensional code image (such as the two-dimensional code shown in fig. 1), a unit color block corresponding to 3 × 3 pixels may be divided, where one row of 3 pixels on the left side corresponds to white and two rows of 6 pixels on the right side correspond to black. At this time, the current sampling pixels obtained according to different predetermined rules may have different results, for example, the pixel at the upper left corner of the unit color block and the pixel at the center may obtain pixels with different colors. That is, in step 202, by the arrangement density of the unit color blocks in the two-dimensional code image, the approximate position of each unit color block can be estimated, and the corresponding current sampling pixel is preliminarily determined. In this specification, for the accuracy of the sampling result, the pixel selected according to the predetermined rule may be used as the current sampling pixel of the corresponding unit color block as the initial sampling pixel, and the correction is performed through the next step 203.
in step 203, the current sample pixel of each unit color block is adjusted based on the color contrast of each current sample pixel with the neighboring pixels. It can be understood that, according to the different selection modes of the current sampling pixel included in the predetermined rule in step 202, the adjacent color blocks to be compared in this step may also be different.
In one embodiment, one unit color block (or corresponding unit area) corresponds to four pixels, and the predetermined rule is to select the pixel at the upper left corner as the current sampling pixel (as shown in fig. 4 a), at this time, for one first unit color block, the colors of three pixels adjacent to the current sampling pixel on the right side, adjacent to the lower side, and adjacent to the lower right corner may be respectively compared with the color of the current sampling pixel. It can be understood that: if the color of the current sampling pixel is the same as the colors of the other three pixels, the current sampling pixel is not adjusted; if the color of the current sampling pixel is different from the color of the adjacent pixel on the right side, the current sampling pixel is deviated to the right, and the current sampling pixel can be adjusted to the left by one pixel; if the color of the current sampling pixel is different from the color of the adjacent pixel below, which indicates that the current sampling pixel is deviated downwards, the current sampling pixel can be adjusted upwards by one pixel; if the color of the current sampled pixel is different from the color of the lower right adjacent pixel, indicating that the current sampled pixel is deviated to the lower right, the current sampled pixel may be adjusted by one pixel to the upper left corner. In each of the above adjustment modes, the current sampling pixel is sequentially compared with each of the adjacent pixels in color, so that the adjustment modes compared with different adjacent pixels can be overlapped. For example, after the current sample pixel is adjusted to the left based on the contrast with the right adjacent pixel, the current sample pixel may also be adjusted upward based on the contrast with the lower adjacent pixel.
in another embodiment, when the number of pixels corresponding to a unit color block (or a unit area) is more than 3 (for example, more than 3), the pixel at the center of the unit color block is initially taken as the current sampling pixel, and as shown in fig. 4b and 4c, the current sampling pixel can be compared with the upper adjacent pixel, the left adjacent pixel, the right adjacent pixel, and the lower adjacent pixel respectively. It can be understood that if the color of the current sampling pixel is consistent with that of each adjacent pixel, the current sampling pixel may not be adjusted; if the color of the current sampling pixel is inconsistent with that of the upper adjacent pixel, the upward deviation of the current sampling pixel is represented, and the current sampling pixel can be downwards adjusted by a preset number of pixels; similarly, if the color of the current sampling pixel is not consistent with one of the left adjacent pixel, the right adjacent pixel and the lower adjacent pixel, which indicates that the current sampling pixel is deviated to the corresponding direction, the current sampling pixel may be adjusted by a predetermined number of pixels in the opposite direction.
The adjacent pixels of the current sampling pixel in a certain direction may be pixels corresponding to the current sampling pixel shifted by one pixel, two pixels or more pixels along the certain direction. For example, in fig. 4b, the upper neighboring pixels of the selected pixel with the bold dashed line frame may be the pixels directly above the bold dashed line frame and the pixels directly above the pixel. The predetermined number is related to the number of pixels corresponding to the unit color block, a determination method of a current sampling pixel at the initial time, and a distance between an adjacent pixel and the current sampling pixel. For example, the unit pixel corresponds to a number of pixels, which is a × a, where a is an odd number greater than or equal to 3, the current sampling pixel at the beginning is the center pixel, and the predetermined number may be the maximum number of pixels moved from the edge pixel to the center pixel, for example, the predetermined number is maximum 1 when a is 3, the predetermined number is maximum 2 when a is 5, and so on. For example, when a is 5, if the color of the current sampling pixel is not consistent with the color of the right adjacent pixel, the current sampling pixel may be adjusted to the left by 2 pixels, and if the color of the current sampling pixel is not consistent with the color of the right adjacent pixel, the current sampling pixel may be adjusted to the left by 1 pixel.
It is understood that the deformation of the two-dimensional code image is continuous, that is, the deformation of the current unit patch is correlated with the deformation of the unit patches around the current unit patch. Therefore, according to one possible design, when adjusting the current sample pixel of the current unit color block, the current sample pixels of the neighboring color blocks around (up, down, left, and right) the current unit color block may also be adjusted in a linkage manner. Assuming that the unit color blocks in the two-dimensional code image comprise second unit color blocks and third unit color blocks adjacent to the second unit color blocks, when the current sampling pixels of the second unit color blocks are adjusted, at least performing linkage adjustment on the current sampling pixels of the third unit color blocks according to a preset linkage rule, wherein the adjustment distance of the current sampling pixels of the third unit color blocks is positively correlated with the adjustment distance of the current sampling pixels of the second unit color blocks.
in one embodiment, the linkage rule includes that the adjustment distance of the current sampling pixel of the third unit color block is consistent with the adjustment distance of the current sampling pixel of the second unit color block. For example, the current sampling pixel of the current unit color block is adjusted upward by 2 pixels, and the unit color blocks adjacent to the current unit color block on the upper, lower, left, and right sides are also adjusted upward by 2 pixels.
in another embodiment, the linking rule includes that the adjustment distance of the current sampling pixel of the third unit color tile has a predetermined ratio smaller than 1 to the adjustment distance of the current sampling pixel of the second unit color tile. This predetermined proportion may also be referred to as the attenuation coefficient. Assuming that the case coefficient is 0.8, when the current sample pixel of the second unit color block is adjusted to the right by 2 pixels, the current sample pixel of the third unit color block is adjusted to the right by 2 × 0.8 — 1.6 pixels (it may be rounded up when actually adjusting, for example, by 1 or 2 pixels).
in yet another embodiment, the linkage rule includes that an adjustment distance of a current sampling pixel of a third unit color block has a linear relationship with a spacing distance of the third unit color block and the second unit color block. For example, if the current sampling pixel of the current unit color block is adjusted upward by 3 pixels, the unit color block adjacent to the current unit color block is adjusted upward by 2 pixels, the next adjacent unit color block (the unit color block adjacent to the adjacent unit color block) is adjusted upward by 1 pixel … …, the attenuation can be determined by a predetermined attenuation model, for example, the linear attenuation model is y ═ mx + b, x is the distance (which can be represented by the number of pixels) between the unit color block s and the current unit color block, b is positively correlated with the number of pixels of the current sampling pixel of the current unit color block adjusted in a certain direction, m is a constant greater than 0, and y is the number of pixels of the current sampling pixel of the unit color block s theoretically adjusted in a certain direction. In the actual adjustment, y may be rounded to an integer, which is used as the number of pixels of the unit color blocks s that are adjusted in a certain direction, for example, if y is 1.8, then the current sampling pixels of the unit color blocks s are adjusted in a certain direction by 2 pixels. When y is less than a predetermined value (e.g., 0.8 or 0.5, etc.), the adjustment of the current sample pixel of the unit patch s may also be discarded.
In more embodiments, the linkage rule may also be other reasonable various rules, which are not described herein again.
it can be understood that if the current sampling pixel of the unit color patch is a pixel in an adjacent unit color patch due to a surface curvature or the like to which the two-dimensional code is attached, it is difficult to find such an error when the current sampling pixel of one unit color patch is individually adjusted. However, in the adjusting process, when the current sampling pixel of a certain unit color block is adjusted, the current sampling pixel of the peripheral unit color block is adjusted in a linkage manner, so that the current sampling pixel of the peripheral unit color block can be corrected, and more probably falls into the pixel in the corresponding unit color block. In this way, when the current sampling pixel of the peripheral unit color block is corrected, the current sampling pixel may already fall into the correct unit color block, so that the accuracy of the current sampling pixel is improved.
For a clearer understanding of the advantages of the above adjustment process, please refer to a specific example shown in fig. 5. The current sample pixel at the beginning of the white color block 51 is 511, and the current sample pixel at the beginning of the black color block 52 is 521. It can be seen that the current sample pixel 521 of the black patch 512 initially falls within the white patch on the right, and the adjustment of the current sample pixel of the black patch 52 alone may be adjusted to the right, resulting in a larger deviation. Assuming that a pixel is adjusted to the left side to be the pixel 512 in the process of adjusting the current pixel of the white color block 51, the current sampling pixel of the black color block 52 is adjusted to be the pixel 522 in a linkage manner, and then falls into the black color block 52, and when the current sampling pixel of the black color block 52 is adjusted subsequently, the current sampling pixel is further adjusted to the left and upward, so that an accurate black pixel is obtained.
it should be noted that, during the pixel adjustment process, the adjustment can be performed for each unit color block in turn. I.e., traverse through the respective cell patches (or cell regions). The method for traversing each unit color block (or unit area) at each time may be from left to right, from top to bottom, from the center to both sides (traversing in rows, from top to bottom in each row), from the center to the periphery in a ring, and the like, which is not limited herein. After traversing each unit color block (or unit area), in order to avoid errors caused by single adjustment and improve the adjustment effectiveness, each unit color block (or unit area) can be traversed for multiple times (preset times). Thus, through multiple iterative adjustments, more accurate sampled pixels can be obtained.
and determining the current sampling pixel of each adjusted unit color block as a corresponding pixel to be sampled. Then, in step 204, according to the color of the current sampling pixel of each adjusted unit color block, a numerical value corresponding to the corresponding unit color block is determined, so as to identify information contained in the two-dimensional code. It can be understood that the adjusted current sampling pixels corresponding to each unit color block are also the sampling pixels finally determined for each unit color block, and the colors corresponding to the current sampling pixels, that is, the colors corresponding to the corresponding unit color blocks, correspond to the corresponding numerical values. For example, if a binary number is used, assuming that a black color block corresponds to "1" and a white color block corresponds to "0", the corresponding cell color block takes "1" if the sampled pixel is black, and the corresponding cell color block takes "0" if the sampled pixel is white. Furthermore, the information contained in the two-dimensional code can be identified by combining the numerical values corresponding to the unit color blocks.
Reviewing the above process, in the two-dimensional code identification process, for a two-dimensional code image to be identified, firstly determining the arrangement density of unit color blocks in the two-dimensional code image, further selecting corresponding current sampling pixels for each unit color block according to a predetermined rule based on the arrangement density of the unit color blocks, then adjusting the current sampling pixels of each unit color block based on the color comparison between each current sampling pixel and an adjacent pixel, and then determining the corresponding numerical values of the corresponding unit color blocks according to the colors of the adjusted current sampling pixels of each unit color block, thereby identifying the information contained in the two-dimensional code. In the two-dimensional code identification process, each current sampling pixel selected for each unit color block according to a preset rule is used as an initial current sampling pixel and is continuously adjusted to finally obtain more accurate sampling pixels, so that the accuracy of two-dimensional code identification can be improved.
according to an embodiment of another aspect, an identification device of a two-dimensional code is also provided. Fig. 6 shows a schematic block diagram of an identification apparatus of a two-dimensional code according to an embodiment. As shown in fig. 6, the recognition apparatus 600 for a two-dimensional code includes: an obtaining module 61 configured to obtain a two-dimensional code image to be recognized; the selecting module 62 is configured to determine an arrangement density of unit color blocks in the two-dimensional code image, and select corresponding current sampling pixels for the unit color blocks according to a predetermined rule, wherein the arrangement density indicates the number and the arrangement mode of the unit color blocks in the two-dimensional code image; an adjusting module 63 configured to adjust the current sampling pixel of each unit color patch based on the color contrast of each current sampling pixel with the neighboring pixels; and the identifying module 64 is configured to determine a numerical value corresponding to each unit color block according to the adjusted color of the current sampling pixel of each unit color block, so as to identify information contained in the two-dimensional code.
according to one embodiment, the selection module 62 is further configured to:
Detecting a positioning graph in the two-dimensional code image according to a first proportional relation between the sizes of the color blocks in the positioning graph, wherein the size of the positioning graph and the size of the unit color block have a second proportional relation;
Determining the size of the unit color block in the two-dimensional code image according to the first proportional relation, the second proportional relation and the size of the positioning graph in the two-dimensional code image;
The arrangement density of the unit color patches is determined based on the size of the two-dimensional code image and the size of the unit color patches in the two-dimensional code image.
In one embodiment, the selecting module 62 is further configured to divide and segment each unit region in the two-dimensional code image according to the arrangement density, where each unit region corresponds to each unit color block, and the segmented unit regions include a first unit region, where the first unit region corresponds to the first unit color block;
the predetermined rule includes at least one of:
taking the upper left corner pixel of the first unit area as the current sampling pixel of the first unit color block;
taking a pixel at the central position of the first unit area as a current sampling pixel of the first unit color block;
and taking one of the four pixels at the central position of the first unit area as a current sampling pixel of the first unit color block.
in one embodiment, the predetermined rule includes:
Determining a two-dimensional code standard coordinate system according to the position of at least one positioning graph in the two-dimensional code image, wherein the size of each color block in the positioning graph meets a first proportional relation;
Establishing a mapping relation between the two-dimension code standard coordinate system and an image coordinate system of the two-dimension code image;
determining the central point of each unit color block in the two-dimensional code standard coordinate system according to the arrangement density;
respectively mapping each central point to an image coordinate system according to the mapping relation to obtain each corresponding mapping point;
And taking the pixel corresponding to each mapping point as the current sampling pixel of the corresponding unit color block.
in a further embodiment, the mapping relationship is determined by:
acquiring first coordinates and second coordinates of the central point of each positioning graph in a two-dimensional code standard coordinate system and an image coordinate system respectively;
Inputting the coordinate values of each first coordinate and each corresponding second coordinate into a mapping relation model containing undetermined parameters;
And solving the undetermined parameters so as to determine the mapping relation.
according to one possible design, the unit color blocks in the two-dimensional code image include a first unit color block, and the adjacent pixels of the current sampling pixels of the first unit color block include first adjacent pixels along a first direction of the current sampling pixels of the first unit color block;
The adjustment module 63 is further configured to:
and under the condition that the color of the current sampling pixel of the first unit color block is inconsistent with the color of the first adjacent pixel, adjusting the current sampling pixel of the first unit color block to the opposite direction of the first direction by a preset number of pixels.
according to another possible design, the adjustment module 63 is further configured to:
sequentially adjusting the current sampling pixels of each unit color block according to a preset traversal mode, wherein the preset traversal mode comprises at least one of the following items:
Traversing from left to right and from top to bottom;
Traversing from the middle to the two sides according to rows, wherein traversing is carried out from top to bottom for each row;
and performing circular diffusion traversal from the center to the periphery.
according to yet another possible design, the unit patches in the two-dimensional code image include a second unit patch, and a third unit patch adjacent to the second unit patch; the adjustment module 63 is further configured to:
and when the current sampling pixel of the second unit color block is adjusted, at least performing linkage adjustment on the current sampling pixel of the third unit color block according to a preset linkage rule, wherein the adjustment distance of the current sampling pixel of the third unit color block is positively correlated with the adjustment distance of the current sampling pixel of the second unit color block.
Wherein the linkage rule may include at least one of:
The adjustment distance of the current sampling pixel of the third unit color block is consistent with the adjustment distance of the current sampling pixel of the second unit color block;
the adjustment distance of the current sampling pixel of the third unit color block and the adjustment distance of the current sampling pixel of the second unit color block have a preset ratio smaller than 1;
The adjustment distance of the current sampling pixel of the third unit color block has a linear relation with the spacing distance between the third unit color block and the second unit color block.
it should be noted that the apparatus 60 shown in fig. 6 is an apparatus embodiment corresponding to the method embodiment shown in fig. 2, and the corresponding description in the method embodiment shown in fig. 2 is also applicable to the apparatus 600, and is not repeated herein.
According to an embodiment of another aspect, there is also provided a computer-readable storage medium having stored thereon a computer program which, when executed in a computer, causes the computer to perform the method described in connection with fig. 2.
according to an embodiment of yet another aspect, there is also provided a computing device comprising a memory and a processor, the memory having stored therein executable code, the processor, when executing the executable code, implementing the method described in connection with fig. 2.
those skilled in the art will recognize that, in one or more of the examples described above, the functions described in the embodiments of this specification may be implemented in hardware, software, firmware, or any combination thereof. When implemented in software, the functions may be stored on or transmitted over as one or more instructions or code on a computer-readable medium.
The above-mentioned embodiments are intended to explain the technical idea, technical solutions and advantages of the present specification in further detail, and it should be understood that the above-mentioned embodiments are merely specific embodiments of the technical idea of the present specification, and are not intended to limit the scope of the technical idea of the present specification, and any modification, equivalent replacement, improvement, etc. made on the basis of the technical solutions of the embodiments of the present specification should be included in the scope of the technical idea of the present specification.

Claims (20)

1. A method for identifying a two-dimensional code, the method comprising:
acquiring a two-dimensional code image to be identified;
Determining the arrangement density of unit color blocks in the two-dimensional code image, and respectively selecting corresponding current sampling pixels for the unit color blocks according to a preset rule, wherein the arrangement density indicates the number and the arrangement mode of the unit color blocks in the two-dimensional code image;
adjusting the current sampling pixel of each unit color block based on the color contrast of each current sampling pixel and the adjacent pixel;
and determining the corresponding numerical value of the corresponding unit color block according to the adjusted color of the current sampling pixel of each unit color block, thereby identifying the information contained in the two-dimensional code.
2. The method of claim 1, wherein the determining of the arrangement density of the unit color blocks in the two-dimensional code image comprises:
detecting a positioning graph in the two-dimensional code image according to a first proportional relation between the sizes of all color blocks in the positioning graph, wherein the size of the positioning graph and the size of a unit color block have a second proportional relation;
Determining the size of a unit color block in the two-dimensional code image according to the first proportional relation, the second proportional relation and the size of a positioning graph in the two-dimensional code image;
And determining the arrangement density based on the size of the two-dimensional code image and the size of the unit color blocks in the two-dimensional code image.
3. The method according to claim 1, wherein after determining the arrangement density of the unit color blocks in the two-dimensional code image, the method further comprises dividing each unit area in the two-dimensional code image according to the arrangement density, wherein each unit area corresponds to each unit color block, and the divided unit areas comprise first unit areas, and each first unit area corresponds to a first unit color block;
The predetermined rule includes at least one of:
taking the pixel at the upper left corner of the first unit area as the current sampling pixel of the first unit color block;
Taking a pixel at the center position of the first unit area as a current sampling pixel of the first unit color block;
And taking one of the four pixels at the central position of the first unit area as a current sampling pixel of the first unit color block.
4. The method of claim 1, wherein the predetermined rule comprises:
Determining a two-dimensional code standard coordinate system according to the position of at least one positioning graph in the two-dimensional code image, wherein the size of each color block in the positioning graph meets a first proportional relation;
Establishing a mapping relation between the two-dimension code standard coordinate system and an image coordinate system of the two-dimension code image;
Determining the central point of each unit color block in the two-dimensional code standard coordinate system according to the arrangement density;
Respectively mapping each central point to the image coordinate system according to the mapping relation to obtain each corresponding mapping point;
and taking the pixel corresponding to each mapping point as the current sampling pixel of the corresponding unit color block.
5. the method of claim 4, wherein the establishing a mapping relationship between the two-dimensional code standard coordinate system and an image coordinate system of the two-dimensional code image comprises:
Acquiring first coordinates and second coordinates of the central point of each positioning graph in the two-dimensional code standard coordinate system and the image coordinate system respectively;
Inputting coordinate values in the first coordinate and the second coordinate into a mapping relation model containing undetermined parameters;
And solving the undetermined parameters so as to determine the mapping relation.
6. The method of claim 1, wherein the cell patch comprises a first cell patch, neighboring pixels of a current sampled pixel of the first cell patch comprising a first neighboring pixel along a first direction of the current sampled pixel of the first cell patch;
the adjusting the current sampling pixel of each unit color block based on the color contrast of each current sampling pixel and the adjacent pixel comprises:
And when the color of the current sampling pixel of the first unit color block is inconsistent with the color of the first adjacent pixel, adjusting the current sampling pixel of the first unit color block to the opposite direction of the first direction by a preset number of pixels.
7. the method of claim 1, wherein said adjusting the current sample pixel of each cell patch based on the color contrast of each current sample pixel to neighboring pixels comprises:
sequentially adjusting the current sampling pixel of each unit color block according to a preset traversal mode, wherein the preset traversal mode comprises at least one of the following items:
traversing from left to right and from top to bottom;
Traversing from the middle to two sides according to rows, wherein traversing each row from top to bottom;
and performing circular diffusion traversal from the center to the periphery.
8. the method of claim 1, wherein the cell patches in the two-dimensional code image comprise a second cell patch, and a third cell patch adjacent to the second cell patch; the adjusting the current sampling pixel of each unit color block based on the color contrast of each current sampling pixel and the adjacent pixel comprises:
and when the current sampling pixel of the second unit color block is adjusted, at least carrying out linkage adjustment on the current sampling pixel of the third unit color block according to a preset linkage rule, wherein the adjustment distance of the current sampling pixel of the third unit color block is positively correlated with the adjustment distance of the current sampling pixel of the second unit color block.
9. the method of claim 8, wherein the linkage rules include at least one of:
the adjustment distance of the current sampling pixel of the third unit color block is consistent with the adjustment distance of the current sampling pixel of the second unit color block;
The adjustment distance of the current sampling pixel of the third unit color block and the adjustment distance of the current sampling pixel of the second unit color block have a preset ratio smaller than 1;
the adjustment distance of the current sampling pixel of the third unit color block and the spacing distance of the third unit color block and the second unit color block form a linear relation.
10. An apparatus for recognizing a two-dimensional code, the apparatus comprising:
The acquisition module is configured to acquire a two-dimensional code image to be identified;
the selection module is configured to determine the arrangement density of unit color blocks in the two-dimensional code image, and select corresponding current sampling pixels for the unit color blocks according to a predetermined rule, wherein the arrangement density indicates the number and the arrangement mode of the unit color blocks in the two-dimensional code image;
The adjusting module is configured to adjust the current sampling pixels of the unit color blocks based on the color contrast of the current sampling pixels and the adjacent pixels;
And the identification module is configured to determine a numerical value corresponding to each unit color block according to the adjusted color of the current sampling pixel of each unit color block, so as to identify the information contained in the two-dimensional code.
11. the apparatus of claim 10, wherein the selection module is further configured to:
Detecting a positioning graph in the two-dimensional code image according to a first proportional relation between the sizes of all color blocks in the positioning graph, wherein the size of the positioning graph and the size of a unit color block have a second proportional relation;
Determining the size of a unit color block in the two-dimensional code image according to the first proportional relation, the second proportional relation and the size of a positioning graph in the two-dimensional code image;
And determining the arrangement density based on the size of the two-dimensional code image and the size of the unit color blocks in the two-dimensional code image.
12. the apparatus of claim 10, wherein the selecting module is further configured to segment each unit area in the two-dimensional code image according to the arrangement density, each unit area corresponding to each unit color block, the segmented unit areas comprising a first unit area, the first unit area corresponding to a first unit color block;
The predetermined rule includes at least one of:
taking the pixel at the upper left corner of the first unit area as the current sampling pixel of the first unit color block;
Taking a pixel at the center position of the first unit area as a current sampling pixel of the first unit color block;
and taking one of the four pixels at the central position of the first unit area as a current sampling pixel of the first unit color block.
13. the apparatus of claim 10, wherein the predetermined rule comprises:
Determining a two-dimensional code standard coordinate system according to the position of at least one positioning graph in the two-dimensional code image, wherein the size of each color block in the positioning graph meets a first proportional relation;
Establishing a mapping relation between the two-dimension code standard coordinate system and an image coordinate system of the two-dimension code image;
Determining the central point of each unit color block in the two-dimensional code standard coordinate system according to the arrangement density;
respectively mapping each central point to the image coordinate system according to the mapping relation to obtain each corresponding mapping point;
and taking the pixel corresponding to each mapping point as the current sampling pixel of the corresponding unit color block.
14. The apparatus of claim 13, wherein the mapping relationship is determined by:
acquiring first coordinates and second coordinates of the central point of each positioning graph in the two-dimensional code standard coordinate system and the two-image coordinate system respectively;
Inputting the coordinate values of each first coordinate and each corresponding second coordinate into a mapping relation model containing undetermined parameters;
And solving the undetermined parameters so as to determine the mapping relation.
15. the apparatus of claim 10, wherein the cell patch comprises a first cell patch, neighboring pixels of a current sampled pixel of the first cell patch comprising a first neighboring pixel along a first direction of the current sampled pixel of the first cell patch;
the adjustment module is further configured to:
and when the color of the current sampling pixel of the first unit color block is inconsistent with the color of the first adjacent pixel, adjusting the current sampling pixel of the first unit color block to the opposite direction of the first direction by a preset number of pixels.
16. The apparatus of claim 10, wherein the adjustment module is further configured to:
Sequentially adjusting the current sampling pixel of each unit color block according to a preset traversal mode, wherein the preset traversal mode comprises at least one of the following items:
traversing from left to right and from top to bottom;
traversing from the middle to two sides according to rows, wherein traversing each row from top to bottom;
and performing circular diffusion traversal from the center to the periphery.
17. the apparatus of claim 10, wherein the cell patches in the two-dimensional code image comprise a second cell patch, and a third cell patch adjacent to the second cell patch; the adjustment module is further configured to:
And when the current sampling pixel of the second unit color block is adjusted, at least carrying out linkage adjustment on the current sampling pixel of the third unit color block according to a preset linkage rule, wherein the adjustment distance of the current sampling pixel of the third unit color block is positively correlated with the adjustment distance of the current sampling pixel of the second unit color block.
18. The apparatus of claim 17, wherein the linkage rules comprise at least one of:
The adjustment distance of the current sampling pixel of the third unit color block is consistent with the adjustment distance of the current sampling pixel of the second unit color block;
The adjustment distance of the current sampling pixel of the third unit color block and the adjustment distance of the current sampling pixel of the second unit color block have a preset ratio smaller than 1;
the adjustment distance of the current sampling pixel of the third unit color block and the spacing distance of the third unit color block and the second unit color block form a linear relation.
19. a computer-readable storage medium, on which a computer program is stored which, when executed in a computer, causes the computer to carry out the method of any one of claims 1-9.
20. A computing device comprising a memory and a processor, wherein the memory has stored therein executable code that, when executed by the processor, performs the method of any of claims 1-9.
CN201910738952.6A 2019-08-12 2019-08-12 Two-dimensional code identification method and device Active CN110543798B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910738952.6A CN110543798B (en) 2019-08-12 2019-08-12 Two-dimensional code identification method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910738952.6A CN110543798B (en) 2019-08-12 2019-08-12 Two-dimensional code identification method and device

Publications (2)

Publication Number Publication Date
CN110543798A true CN110543798A (en) 2019-12-06
CN110543798B CN110543798B (en) 2023-06-20

Family

ID=68710632

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910738952.6A Active CN110543798B (en) 2019-08-12 2019-08-12 Two-dimensional code identification method and device

Country Status (1)

Country Link
CN (1) CN110543798B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113385826A (en) * 2021-07-06 2021-09-14 深圳青钿信息科技有限公司 Coding identification system and method based on high-speed galvanometer laser
CN113449534A (en) * 2021-06-28 2021-09-28 歌尔股份有限公司 Two-dimensional code image processing method and device

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2004362053A (en) * 2003-06-02 2004-12-24 Hitachi Information Technology Co Ltd Two-dimensional code reading device
JP2007052471A (en) * 2005-08-12 2007-03-01 Ricoh Co Ltd Two-dimensional pattern reader and two-dimensional pattern reading method
CN103164702A (en) * 2011-12-13 2013-06-19 李卫伟 Extracting method and device of marker central point and image processing system
WO2014092193A1 (en) * 2012-12-14 2014-06-19 株式会社コンセプト Image processing device, image processing method, image processing program, program, and mobile terminal device with camera
US20150090792A1 (en) * 2013-09-29 2015-04-02 Founder Mobile Media Technology (Beijing) Co., Ltd. System for decoding two dimensional code and method thereof

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2004362053A (en) * 2003-06-02 2004-12-24 Hitachi Information Technology Co Ltd Two-dimensional code reading device
JP2007052471A (en) * 2005-08-12 2007-03-01 Ricoh Co Ltd Two-dimensional pattern reader and two-dimensional pattern reading method
CN103164702A (en) * 2011-12-13 2013-06-19 李卫伟 Extracting method and device of marker central point and image processing system
WO2014092193A1 (en) * 2012-12-14 2014-06-19 株式会社コンセプト Image processing device, image processing method, image processing program, program, and mobile terminal device with camera
US20150090792A1 (en) * 2013-09-29 2015-04-02 Founder Mobile Media Technology (Beijing) Co., Ltd. System for decoding two dimensional code and method thereof

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113449534A (en) * 2021-06-28 2021-09-28 歌尔股份有限公司 Two-dimensional code image processing method and device
CN113385826A (en) * 2021-07-06 2021-09-14 深圳青钿信息科技有限公司 Coding identification system and method based on high-speed galvanometer laser

Also Published As

Publication number Publication date
CN110543798B (en) 2023-06-20

Similar Documents

Publication Publication Date Title
US8254683B2 (en) Code image processing method
JP3515199B2 (en) Defect inspection equipment
US8155448B2 (en) Image processing apparatus and method thereof
CA2592596C (en) Information input output method using dot pattern
CN108550113A (en) Image scanning output method, device, computer equipment and storage medium
CN111737478B (en) Text detection method, electronic device and computer readable medium
CN110569845A (en) test paper image correction method and related device
CN110543798A (en) two-dimensional code identification method and device
CN114638824B (en) Fusion method, device, equipment and medium for collecting images based on AOI equipment
JP6665595B2 (en) Character recognition device, method and program
JP2011175523A (en) Instrument reading device, method, program and computer-readable medium with the software stored
CN114332237A (en) Method for calculating conversion relation between camera coordinate system and laser coordinate system
JP2012048580A (en) Image processing apparatus, image processing method, program, and storage medium
WO2022021687A1 (en) Method for positioning quick response code area, and electronic device and storage medium
US10424066B2 (en) Image analyzing apparatus that corrects isolated pixels in target image data
EP2853089B1 (en) Pattern processing apparatus, pattern processing method, and pattern processing program
JP4335229B2 (en) QR code recognition device, QR code recognition device control method, QR code recognition device control program, and computer-readable recording medium recording the same
CN110689586B (en) Tongue image identification method in traditional Chinese medicine intelligent tongue diagnosis and portable correction color card used for same
CN202267974U (en) Positioning system used for two-dimension code and two-dimension code identification device
CN113536822B (en) Two-dimensional code correction method and device and computer readable storage medium
JP4760362B2 (en) Character reader
CN111753832B (en) Image processing method, image processing apparatus, electronic device, and storage medium
JP2019012424A (en) Image processing device and computer program
CN112767472B (en) Method for positioning lamp beads in display screen image, computing equipment and storage medium
CN112733567B (en) Method and device for identifying two-dimension code of motor vehicle and computer readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40018657

Country of ref document: HK

TA01 Transfer of patent application right

Effective date of registration: 20200924

Address after: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman Islands

Applicant after: Innovative advanced technology Co.,Ltd.

Address before: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman Islands

Applicant before: Advanced innovation technology Co.,Ltd.

Effective date of registration: 20200924

Address after: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman Islands

Applicant after: Advanced innovation technology Co.,Ltd.

Address before: A four-storey 847 mailbox in Grand Cayman Capital Building, British Cayman Islands

Applicant before: Alibaba Group Holding Ltd.

TA01 Transfer of patent application right
GR01 Patent grant
GR01 Patent grant