CN110490021B - Two-dimensional code positioning method, medium, device and computing equipment - Google Patents

Two-dimensional code positioning method, medium, device and computing equipment Download PDF

Info

Publication number
CN110490021B
CN110490021B CN201910775253.9A CN201910775253A CN110490021B CN 110490021 B CN110490021 B CN 110490021B CN 201910775253 A CN201910775253 A CN 201910775253A CN 110490021 B CN110490021 B CN 110490021B
Authority
CN
China
Prior art keywords
pixel
position detection
standard
graph
area
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.)
Active
Application number
CN201910775253.9A
Other languages
Chinese (zh)
Other versions
CN110490021A (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.)
Netease Hangzhou Network Co Ltd
Original Assignee
Netease Hangzhou Network 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 Netease Hangzhou Network Co Ltd filed Critical Netease Hangzhou Network Co Ltd
Priority to CN201910775253.9A priority Critical patent/CN110490021B/en
Publication of CN110490021A publication Critical patent/CN110490021A/en
Application granted granted Critical
Publication of CN110490021B publication Critical patent/CN110490021B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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/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

Abstract

The embodiment of the invention provides a two-dimensional code positioning method, a medium, a two-dimensional code positioning device and computing equipment. The method comprises the following steps: determining a plurality of pixel scanning areas positioned on a binary image according to pixel distribution information in the binary image; when the number of pixels in the pixel scanning area is the standard number of pixels, determining the pixel scanning area as a standard pixel scanning area; when the number of pixels in the pixel scanning area is the number of auxiliary pixels, determining the pixel scanning area as an auxiliary pixel scanning area with a defect area; and determining a position detection graph for positioning the two-dimensional code according to the standard pixel scanning area and the auxiliary pixel scanning area. The method can identify the position detection graph of the defect area in the binary image, and improves the positioning accuracy and the positioning success rate of the two-dimensional code.

Description

Two-dimensional code positioning method, medium, device and computing equipment
Technical Field
The embodiment of the invention relates to the technical field of computers, in particular to a two-dimensional code positioning method, a medium, a two-dimensional code positioning device and computing equipment.
Background
This section is intended to provide a background or context to the embodiments of the invention that are recited in the claims. The description herein is not admitted to be prior art by inclusion in this section.
Along with the popularity of code scanning payment, the use scene of the two-dimensional code is deep into the aspect of daily life of people. Although the japanese Denso corporation develops a standard quick response two-dimensional Code (QR Code) and sets a standard specification that can quickly locate a positioning pattern therein, in actual daily life, some merchants and individuals intentionally add some complicated backgrounds for the purpose of marketing promotion, resulting in that the generated two-dimensional Code image no longer conforms to the standard specification. In addition, in the code scanning process of the camera, due to the influence of factors such as a shooting angle and illumination, a common image binarization algorithm cannot accurately distinguish a two-dimensional code region from a surrounding background region, so that the normal positioning of a positioning pattern is influenced. Both of the above cases can cause the failure of the two-dimensional code recognition algorithm developed based on the standard specification.
Disclosure of Invention
The invention aims to provide a two-dimension code positioning method, a medium, a two-dimension code positioning device and a computing device, and further solves the problem that two-dimension codes cannot be accurately positioned and identified due to the limitation of related technologies to a certain extent.
According to a first aspect of the present invention, there is provided a two-dimensional code positioning method, including: determining a plurality of pixel scanning areas on the binary image according to pixel distribution information in the binary image; when the number of pixels in the pixel scanning area is the standard number of pixels, determining the pixel scanning area as a standard pixel scanning area; when the number of pixels in the pixel scanning area is the number of auxiliary pixels, determining the pixel scanning area as an auxiliary pixel scanning area with a defect area; and determining a position detection graph for positioning the two-dimensional code according to the standard pixel scanning area and the auxiliary pixel scanning area.
In some exemplary embodiments of the present invention, based on the above technical solution, the pixel scanning area is a horizontal scanning area or a vertical scanning area; the method for determining a plurality of pixel scanning areas on a binarized image according to pixel distribution information in the binarized image comprises the following steps: determining a transverse scanning line along the arrangement direction of the row pixels and a longitudinal scanning line along the arrangement direction of the column pixels on the binary image; determining one or more transverse scanning areas on the transverse scanning lines according to the pixel distribution information on the transverse scanning lines; and determining one or more longitudinal scanning areas on the longitudinal scanning lines according to the pixel distribution information on the longitudinal scanning lines.
In some exemplary embodiments of the present invention, based on the above technical solution, the pixel scanning area includes a plurality of pixel arrangement blocks distributed continuously; wherein, two adjacent pixel arrangement blocks have different pixel values.
In some exemplary embodiments of the present invention, based on the above technical solution, when the number of pixels in the pixel scanning area is a standard number of pixels, determining the pixel scanning area as a standard pixel scanning area includes: acquiring the pixel number of each pixel arrangement block in the pixel scanning area; determining the standard block unit width and the standard width error limit of the pixel scanning area according to the pixel number of each pixel arrangement block; determining a standard pixel number range corresponding to each pixel arrangement block according to the standard block unit width and the standard width error limit; when the number of the pixels of each pixel arrangement block is within the range of the standard number of the pixels, the number of the pixels in the pixel scanning area is determined to be the standard number of the pixels, and the pixel scanning area is determined to be the standard pixel scanning area.
In some exemplary embodiments of the present invention, based on the above technical solution, the standard width error is limited to 0.5 to 0.75 times the standard block unit width.
In some exemplary embodiments of the present invention, based on the above technical solution, determining the pixel scanning area as an auxiliary pixel scanning area with a defect area when the number of pixels in the pixel scanning area is the auxiliary pixel number, includes: when the pixel number of one or more pixel arrangement blocks positioned at one side edge of the pixel scanning area is out of the standard pixel number range, taking the pixel arrangement blocks as defective blocks; using other pixel arrangement blocks in the pixel scanning area except the defective block as standard blocks, and determining auxiliary block unit width and auxiliary width error limit of the pixel scanning area according to the number of pixels of the standard blocks; determining an auxiliary pixel number range corresponding to each standard block according to the auxiliary block unit width and the auxiliary width error limit; when the pixel number of each of the standard block and the defective block is within the auxiliary pixel number range, determining the pixel number in the pixel scanning area as the auxiliary pixel number, and determining the pixel scanning area as the auxiliary pixel scanning area with the defective area.
In some exemplary embodiments of the present invention, based on the above technical solution, the auxiliary width error is limited to 0.5 to 0.75 times of the unit width of the auxiliary block.
In some exemplary embodiments of the present invention, based on the above technical solution, the determining a position detection pattern for positioning a two-dimensional code according to the standard pixel scanning area and the auxiliary pixel scanning area includes: determining a candidate position detection area according to the standard pixel scanning area and the auxiliary pixel scanning area, and determining the area center of the candidate position detection area; selecting a plurality of area size reference lines which pass through the center of the area in the candidate position detection area; acquiring the length of each region size reference line, and determining a standard region size difference value according to the length; and when the length of each region size reference line meets the standard region size difference, determining the candidate position detection region as a position detection graph for positioning the two-dimensional code.
In some exemplary embodiments of the present invention, based on the above technical solutions, the determining the candidate position detection region as a position detection pattern for positioning a two-dimensional code includes: determining a central pixel block positioned in the center of the candidate position detection area according to the position and the pixel value of the area center; and when the central pixel block is a closed block with a plurality of boundary lines, determining the candidate position detection area as a position detection graph for positioning the two-dimensional code.
In some exemplary embodiments of the present invention, based on the above technical solution, determining the candidate position detection region as a position detection pattern for positioning a two-dimensional code when the central pixel block is a closed block having a plurality of boundary lines, includes: determining a plurality of boundary lines of the central pixel block, and acquiring the vertical distance between the center of the area and each boundary line; and when the boundary lines form a closed block and the vertical distance is within a standard distance range, determining the candidate position detection area as a position detection graph for positioning the two-dimensional code.
In some exemplary embodiments of the present invention, based on the above technical solution, after determining the position detection pattern for positioning the two-dimensional code according to the standard pixel scanning area and the auxiliary pixel scanning area, the method further includes: forming a position detection graph set by the position detection graphs in the binary image; clustering the position detection graph set according to the size information and the position information of each position detection graph to obtain a ternary graph combination consisting of three position detection graphs; and determining the position of the two-dimensional code in the binary image according to the ternary graph combination.
In some exemplary embodiments of the present invention, based on the above technical solution, the clustering the position detection graph set according to the size information and the position information of each position detection graph to obtain a ternary graph combination composed of three position detection graphs includes: selecting two position detection graphs with similar sizes from the position detection graph set to form a binary graph combination according to the size information of each position detection graph; selecting a position detection graph with the size similar to the combined size of the binary graphs from the position detection graph set as a third candidate graph; judging whether the binary pattern combination and the third candidate pattern accord with a standard position relation or not according to the position information of each position detection pattern; when the binary graph combination and the third candidate graph accord with the standard position relation, the binary graph combination and the third candidate graph form a ternary graph combination; and when the binary graph combination and the third candidate graph do not accord with the standard position relation, selecting a new third candidate graph from the position detection graph set, and continuously judging whether the newly selected third candidate graph and the binary graph can form the ternary graph combination.
In some exemplary embodiments of the present invention, based on the above technical solution, selecting two position detection graphs with similar sizes from the position detection graph set to form a binary graph combination according to the size information of each position detection graph includes: according to the size information of each position detection graph, performing size sequencing on each position detection graph in the position detection graph set to obtain a graph sequence; forming a candidate graph combination by every two adjacent position detection graphs in the graph sequence, and determining the size difference of the two position detection graphs in the candidate graph combination; performing difference sorting on each candidate graph combination according to the size difference to obtain a combination sequence; and selecting candidate graph combinations from the combination sequence in sequence as the binary graph combinations.
In some exemplary embodiments of the present invention, based on the above technical solution, the determining whether the binary pattern combination and the third candidate pattern meet a standard position relationship according to the position information of each position detection pattern includes: determining a central connection line between two position detection graphs in the binary graph combination and the third candidate graph according to the position information of each position detection graph; acquiring the connecting line length of each central connecting line, and determining two short-side connecting lines and a long-side connecting line according to the connecting line length; when the length difference value of the two short edge connecting lines is smaller than the length error limit and neither short edge connecting line passes through the defect region of the position detection graph, judging that the binary graph combination and the third candidate graph accord with a standard position relation; and when the length difference value of the two short edge connecting lines is greater than or equal to the length error limit or the short edge connecting line passes through the defect area of the position detection graph, judging that the binary graph combination and the third candidate graph do not accord with the standard position relation.
In some exemplary embodiments of the present invention, based on the above technical solution, after determining two short side connection lines and one long side connection line according to the connection line length, the method further includes: and determining a length error limit according to the length of the connecting line of the two short sides.
According to a second aspect of the present invention, there is provided a medium having stored thereon a program which, when executed by a processor, implements a method as in the above exemplary embodiments.
According to a third aspect of the present invention, there is provided a two-dimensional code positioning device, the device comprising: a scanning area determining module configured to determine a plurality of pixel scanning areas located on the binarized image according to pixel distribution information in the binarized image; a standard area determination module configured to determine the pixel scanning area as a standard pixel scanning area when the number of pixels within the pixel scanning area is a standard pixel number; an auxiliary area determination module configured to determine the pixel scanning area as an auxiliary pixel scanning area with a defect area when the number of pixels within the pixel scanning area is the auxiliary pixel number; and the detection pattern determining module is configured to determine a position detection pattern for positioning the two-dimensional code according to the standard pixel scanning area and the auxiliary pixel scanning area.
In some exemplary embodiments of the present invention, based on the above technical solution, the pixel scanning area is a horizontal scanning area or a vertical scanning area; the scan region determination module includes: a scan line determination unit configured to determine a horizontal scan line in a row pixel arrangement direction and a vertical scan line in a column pixel arrangement direction on the binarized image; a transverse scanning area determination unit configured to determine one or more transverse scanning areas on the transverse scanning lines according to pixel distribution information on the transverse scanning lines; a longitudinal scanning area determination unit configured to determine one or more longitudinal scanning areas on the longitudinal scanning lines according to pixel distribution information on the longitudinal scanning lines.
In some exemplary embodiments of the present invention, based on the above technical solution, the pixel scanning area includes a plurality of pixel arrangement blocks distributed continuously; wherein, two adjacent pixel arrangement blocks have different pixel values.
In some exemplary embodiments of the present invention, based on the above technical solutions, the standard region determining module includes: a pixel number acquisition unit configured to acquire the number of pixels of each of the pixel arrangement blocks within the pixel scanning area; a standard width determination unit configured to determine a standard block unit width and a standard width error limit of the pixel scanning area according to the number of pixels of each of the pixel arrangement blocks; a standard range determination unit configured to determine a standard pixel number range corresponding to each of the pixel arrangement blocks according to the standard block unit width and the standard width error limit; a standard area determination unit configured to determine the number of pixels in the pixel scanning area as a standard number of pixels and determine the pixel scanning area as a standard pixel scanning area when the number of pixels of each of the pixel arrangement blocks is within the standard number of pixels.
In some exemplary embodiments of the present invention, based on the above technical solution, the standard width error is limited to 0.5 to 0.75 times of the standard block unit width.
In some exemplary embodiments of the present invention, based on the above technical solutions, the auxiliary area determining module includes: a defective block determination unit configured to, when the number of pixels of one or more pixel arrangement blocks located at one side edge of the pixel scanning area is out of the standard pixel number range, take the pixel arrangement block as a defective block; an auxiliary width determination unit configured to take other pixel arrangement blocks in the pixel scanning area except the defective block as standard blocks and determine an auxiliary block unit width and an auxiliary width error limit of the pixel scanning area according to the number of pixels of the standard blocks; an auxiliary range determining unit configured to determine an auxiliary pixel number range corresponding to each of the standard patches according to the auxiliary patch unit width and the auxiliary width error limit; an auxiliary area determining unit configured to determine the number of pixels in the pixel scanning area as the number of auxiliary pixels and determine the pixel scanning area as an auxiliary pixel scanning area with a defective area when the number of pixels of each of the standard block and the defective block is within the range of the number of auxiliary pixels.
In some exemplary embodiments of the present invention, based on the above technical solution, the auxiliary width error is limited to 0.5 to 0.75 times the unit width of the auxiliary block.
In some exemplary embodiments of the present invention, based on the above technical solutions, the detection pattern determining module includes: a detection region determination unit configured to determine a candidate position detection region from the standard pixel scanning region and the auxiliary pixel scanning region, and determine a region center of the candidate position detection region; a reference line determination unit configured to select a plurality of area size reference lines passing through the area center within the candidate position detection area; a standard size determination unit configured to acquire lengths of the respective region size reference lines and determine a standard region size difference value according to the lengths; a detection pattern determination unit configured to determine the candidate position detection region as a position detection pattern for positioning a two-dimensional code when the length of each of the region size reference lines satisfies the standard region size difference.
In some exemplary embodiments of the present invention, based on the above technical solutions, the detection pattern determining unit includes: a central block determination subunit configured to determine a central pixel block located at the center of the candidate position detection area according to the position and the pixel value of the area center; a detection pattern determination subunit configured to determine the candidate position detection region as a position detection pattern for positioning a two-dimensional code when the center pixel block is a closed block having a plurality of boundary lines.
In some exemplary embodiments of the present invention, based on the above technical solutions, the probe pattern determining subunit includes: a boundary line determining subunit configured to determine a plurality of boundary lines of the central pixel block and acquire a vertical distance between the area center and each of the boundary lines; a closed block determination subunit configured to determine the candidate position detection region as a position detection pattern for positioning the two-dimensional code when each of the boundary lines forms a closed block and the vertical distance is within a standard distance range.
In some exemplary embodiments of the present invention, based on the above technical solutions, the apparatus further includes: a graph set composition module configured to compose position detection graphs in the binarized image into a position detection graph set; the ternary graph combination module is configured to cluster the position detection graph set according to the size information and the position information of each position detection graph to obtain a ternary graph combination consisting of three position detection graphs; and the two-dimensional code position determining module is configured to determine the position of the two-dimensional code in the binary image according to the ternary graph combination.
In some exemplary embodiments of the present invention, based on the above technical solution, the ternary graph combination module includes: the binary figure combination unit is configured to select two position detection figures with similar sizes from the position detection figure set to form a binary figure combination according to the size information of each position detection figure; a candidate pattern selecting unit configured to select a position detection pattern having a size similar to the combined size of the binary patterns from the position detection pattern set as a third candidate pattern; a position relation judging unit configured to judge whether the binary pattern combination and the third candidate pattern meet a standard position relation according to position information of each of the position detection patterns; a first graph combination unit configured to combine the binary graph combination and the third candidate graph into a ternary graph combination when the binary graph combination and the third candidate graph meet the standard positional relationship; and the second graph combination unit is configured to select a new third candidate graph from the position detection graph set when the binary graph combination and the third candidate graph do not accord with the standard position relation, and continuously judge whether the newly selected third candidate graph can form a ternary graph combination with the binary graph.
In some exemplary embodiments of the present invention, based on the above technical solution, the binary graphic composition unit includes: the graphic sequence subunit is configured to perform size sequencing on each position detection graphic in the position detection graphic set according to the size information of each position detection graphic to obtain a graphic sequence; a candidate pattern combination subunit configured to combine each two adjacent position detection patterns in the pattern sequence into one candidate pattern combination, and determine a size difference value of the two position detection patterns in the candidate pattern combination; the combined sequence subunit is configured to perform difference sorting on each candidate graph combination according to the size difference to obtain a combined sequence; and the binary graph combination subunit is configured to select candidate graph combinations from the combination sequence in sequence as the binary graph combinations.
In some exemplary embodiments of the present invention, based on the above technical solutions, the position relation determination unit includes: a central connecting line determining subunit configured to determine, according to the position information of each of the position detection patterns, a central connecting line between two position detection patterns in the binary pattern combination and the third candidate pattern; a connecting line length acquiring unit configured to acquire a connecting line length of each of the center connecting lines and determine two short side connecting lines and one long side connecting line according to the connecting line length; a first position relation judging subunit, configured to judge that the binary pattern combination and the third candidate pattern meet a standard position relation when a length difference between the two short edge connecting lines is smaller than a length error limit and neither of the two short edge connecting lines passes through a defect region of the position detection pattern; and the second position relation judging subunit is configured to judge that the binary pattern combination and the third candidate pattern do not accord with a standard position relation when the length difference value of the two short edge connecting lines is greater than or equal to a length error limit or the short edge connecting line passes through a defect area of the position detection pattern.
In some exemplary embodiments of the present invention, based on the above technical solution, the position relation determination unit further includes: a length error limit determination subunit configured to determine a length error limit according to the length of the two short side connecting lines.
According to a fourth aspect of the invention, there is provided a computing device comprising: a processor and a memory, the memory storing executable instructions, the processor for invoking the memory stored executable instructions to perform a method as in the above exemplary embodiments.
In the technical scheme provided by the invention, the pixel scanning areas are determined on the binary image, and the pixel distribution condition in the pixel scanning areas is judged according to the standard pixel quantity specification and the auxiliary pixel quantity specification, so that the position detection graph of the defective area in the binary image can be identified, the positioning accuracy and the positioning success rate of the two-dimensional code are improved, the identification efficiency of the two-dimensional code is improved, and the two-dimensional code scanning experience of a user is improved.
Drawings
The above and other objects, features and advantages of exemplary embodiments of the present invention will become readily apparent from the following detailed description read in conjunction with the accompanying drawings. Several embodiments of the invention are illustrated by way of example, and not by way of limitation, in the figures of the accompanying drawings and in which:
fig. 1 shows a schematic structural diagram of a quick response two-dimensional code;
FIG. 2 is a view schematically showing a pixel distribution scale rule of a position detection pattern in a two-dimensional code image;
fig. 3 schematically shows two-dimensional code images with some blank areas contaminated;
FIG. 4 shows a system architecture diagram to which exemplary embodiments of the present invention are applied;
fig. 5 schematically illustrates a flow chart of steps of a two-dimensional code positioning method in some exemplary embodiments of the invention;
FIG. 6 is a diagram showing the distribution of pixel scanning areas in a binarized image;
FIG. 7 schematically illustrates a flow chart of steps for determining pixel scan areas in some exemplary embodiments of the invention;
FIG. 8 schematically illustrates a flow chart of steps for determining a standard pixel scan area in some exemplary embodiments of the invention;
FIG. 9 schematically illustrates a flow chart of steps for determining an auxiliary pixel scan area in some exemplary embodiments of the invention;
FIG. 10 schematically illustrates a flowchart of the steps of determining a position detection profile in some exemplary embodiments of the invention;
FIG. 11 schematically illustrates a flowchart of the steps of determining a position detection pattern in some exemplary embodiments of the invention;
FIG. 12 schematically illustrates a flowchart of the steps for determining a position detection pattern based on border line distances in some exemplary embodiments of the present invention;
FIG. 13 schematically illustrates a flow chart of steps for determining a position of a two-dimensional code in some exemplary embodiments of the invention;
FIG. 14 schematically illustrates a flowchart of the steps for determining a ternary graphical composition in some exemplary embodiments of the present invention;
FIG. 15 schematically illustrates a flowchart of the steps of determining a binary pattern combination in some exemplary embodiments of the invention;
FIG. 16 schematically illustrates a flowchart showing steps in determining positional relationships in some exemplary embodiments of the invention;
fig. 17 is a flowchart schematically illustrating steps of a two-dimensional code positioning method in a specific application scenario according to an exemplary embodiment of the present invention;
FIG. 18 is a schematic diagram showing various position detection patterns having a regular pixel arrangement along the row and column pixel directions;
FIG. 19 is a schematic view showing a position detection figure candidate and its center position;
FIG. 20 is a diagram showing pixel arrangement checking in various directions by the width consistency rule applied under different polarity conditions;
FIG. 21 is a schematic diagram of two ternary candidate combinations;
fig. 22 is a block diagram schematically illustrating a two-dimensional code positioning apparatus according to some exemplary embodiments of the present invention;
fig. 23 is a block diagram schematically illustrating a two-dimensional code positioning apparatus according to another exemplary embodiment of the present invention.
In the drawings, the same or corresponding reference numerals indicate the same or corresponding parts.
Detailed Description
The principles and spirit of the present invention will be described with reference to several exemplary embodiments. It is understood that these embodiments are given only to enable those skilled in the art to better understand and to implement the present invention, and do not limit the scope of the present invention in any way. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the invention to those skilled in the art.
As will be appreciated by one skilled in the art, embodiments of the present invention may be embodied as a system, apparatus, device, method, or computer program product. Thus, the present invention may be embodied in the form of: entirely hardware, entirely software (including firmware, resident software, micro-code, etc.), or a combination of hardware and software.
In this context, it is to be understood that the relevant terms referred to are to be interpreted as follows:
position Detection Pattern (Position Detection Pattern): the main positioning pattern of the two-dimensional code is a specific pattern in a shape like a Chinese character 'hui', which is composed of black, white, black, white and black modules arranged in the width ratio of 1. The quick response two-dimensional Code (QR Code) has three position detection graphs which are respectively positioned at the upper left corner, the upper right corner and the lower left corner of a two-dimensional Code image, and the position of the two-dimensional Code can be quickly detected by utilizing the combination of the three graphs.
Blank (quench Zone): and the blank area around the two-dimensional code is quickly responded, and the blank area is used for helping the two-dimensional code positioning algorithm to find the black area of the initial state of the position detection graph. The blank area is polluted, namely the blank area does not have enough width so that the distinguishing degree between the two-dimensional code and the surrounding image background is not obvious, and finally, the position detection graph which meets the standard of the two-dimensional code cannot be obtained by an image binarization algorithm, and the position detection graph area does not present a standard 'return' shape any more.
Furthermore, the number of any elements in the drawings is intended to be illustrative and not restrictive, and any nomenclature is used for distinction only and not for any restrictive meaning.
The principles and spirit of the present invention are explained in detail below with reference to several representative embodiments of the invention.
Summary of The Invention
Fig. 1 shows a schematic structural diagram of a quick response two-dimensional code. As shown in fig. 1, position detection patterns 110 are arranged at three positions, namely, the upper left corner, the upper right corner and the lower left corner of the two-dimensional code image, and are used for quickly positioning the position of the two-dimensional code. The central area 120 defined by the three position detection patterns 110 is used to store actual two-dimensional code encoded data and an error correction code word for correcting errors caused by two-dimensional code damage. In order to accurately find the position of the position detection pattern 110, a blank area 130 for spacing the position detection pattern 110 and other image portions is further provided at the outer edge of the two-dimensional code image.
Fig. 2 schematically shows a pixel distribution scale rule of the position detection pattern in the two-dimensional code image. As shown in fig. 2, the position detection pattern is formed by alternately arranging black and white pixels in both the horizontal and vertical directions, and the number ratio of the pixels satisfies 1:1:3:1:1, standard rule. However, when the blank area of the two-dimensional code image is contaminated by pixels of other colors or other gray values, a part of the pixel area of the position detection pattern will no longer satisfy the above-mentioned standard rule of the number ratio. Fig. 3 schematically shows a two-dimensional code image in which some blank areas are contaminated. For the two-dimensional code images with the blank areas polluted, if the position detection graph is still searched according to the standard rule, the two-dimensional code images obviously cannot be accurately positioned, so that reliable sampling and decoding of binary data in the two-dimensional code cannot be completed.
In order to improve the success rate of identifying the two-dimensional code image, the invention provides a two-dimensional code positioning method capable of dealing with the pollution of a blank area. The two-dimensional code image is positioned based on the position detection graph meeting the standard proportion standard or the auxiliary proportion standard, and the problem that the two-dimensional code image cannot be accurately identified due to the fact that the blank area is polluted can be effectively solved.
Having described the basic principles of the invention, various non-limiting embodiments of the invention are described in detail below.
Application scene overview
It should be noted that the following application scenarios are merely illustrated for the convenience of understanding the spirit and principles of the present invention, and the embodiments of the present invention are not limited in this respect. Rather, embodiments of the present invention may be applied to any scenario where applicable.
Fig. 4 shows a schematic diagram of a system architecture to which exemplary embodiments of the present invention are applied. As shown in fig. 4, system architecture 400 may include client 410, network 420, and server 430. The client 410 may include various terminal devices such as a barcode scanner, a smart phone, a tablet computer, a notebook computer, and a desktop computer, and the client 410 may be installed with barcode scanning software for scanning a two-dimensional code. The server 430 may include various server devices such as a web server, an application server, a database server, and the like, and the server 430 may provide network resources and data services for the client 410. Network 420 may be any of a variety of connection types of communication media capable of providing communication links between client 410 and server 430, such as wired communication links, wireless communication links, or fiber optic cables, to name a few.
The system architecture of the exemplary embodiments of this invention may have any number of clients, networks, and servers, as desired for implementation. For example, the server 430 may be a server group consisting of a plurality of server devices. The two-dimensional code positioning method provided by the exemplary embodiment of the present invention may be mainly applied to the client 410, and may also be applied to the server 430, which is not particularly limited in the present invention.
In addition, the two-dimensional code positioning method provided by the exemplary embodiment of the present invention may be used in a scene of positioning and identifying one two-dimensional code alone, and may also be used in a scene of positioning and identifying a plurality of two-dimensional code images in batch, which is not limited in this respect.
Exemplary method
In the following, in conjunction with the above application scenarios, a two-dimensional code positioning method according to an exemplary embodiment of the present invention is described with reference to fig. 2 to 21.
Fig. 5 schematically illustrates a flowchart of steps of a two-dimensional code positioning method in some exemplary embodiments of the present invention. As shown in fig. 5, the method may mainly include the following steps:
and step S510, determining a plurality of pixel scanning areas on the binary image according to the pixel distribution information in the binary image.
The method comprises the steps of firstly obtaining a binary image possibly comprising one or more two-dimensional codes, and then determining a plurality of pixel scanning areas according to pixel distribution information of black and white pixels in the binary image. The pixel scanning area can be mainly a black and white pixel combination area which is sequentially arranged in the row pixel direction or the column pixel direction, and the distribution quantity and the distribution ratio of two kinds of pixels in the pixel scanning area should meet a certain ratio specification. In addition, in some other embodiments, the pixel scanning area may also be a pixel combination area in a diagonal direction or any other angle direction.
And S520, when the number of the pixels in the pixel scanning area is the standard number of the pixels, determining the pixel scanning area as the standard pixel scanning area.
For the plurality of pixel scanning areas determined in step S510, the pixel distribution number and the distribution ratio relationship of the black and white pixels in each pixel scanning area may be determined according to the pixel distribution information, and if it is determined that the pixel number in one pixel scanning area satisfies the standard pixel number, the pixel scanning area may be determined as the standard pixel scanning area. For example, the pixel distribution in a pixel scanning area is in a number proportion relationship of black, white, black, white and black substantially satisfying 1.
Step s530, when the number of pixels in the pixel scanning area is the auxiliary pixel number, determining the pixel scanning area as an auxiliary pixel scanning area with a defect area.
Similarly to step S520, if it is determined that the number of pixels within one pixel scanning area satisfies the number of auxiliary pixels, the pixel scanning area may be determined as an auxiliary pixel scanning area with a defect area. For example, the pixel distribution in a pixel scanning area basically satisfies the number proportion relationship of x: 1. For another example, the pixel distribution in a pixel scanning area basically satisfies the number proportion relationship of x: y: 3.
And S540, determining a position detection graph for positioning the two-dimensional code according to the standard pixel scanning area and the auxiliary pixel scanning area.
According to the judgment results of step S520 and step S530, a standard pixel scanning area satisfying the standard pixel number specification and/or an auxiliary pixel scanning area satisfying the auxiliary pixel scanning number specification may be determined on the binarized image. And determining a position detection pattern for positioning the two-dimensional code according to the positions of the standard pixel scanning area and the auxiliary pixel scanning area on the binary image.
For example, as shown in fig. 6, a rectangular area 630 can be determined from a standard pixel scanning area 610 along the row pixel direction and an auxiliary pixel scanning area 620 along the column pixel direction, and the rectangular area 630 can be determined as a position detection pattern in the two-dimensional code. And then, other standard pixel scanning areas and auxiliary pixel scanning areas in the binary image are continuously utilized to determine other two or more position detection graphs, and the positioning of the two-dimensional code can be completed by selecting three position detection graphs.
In the two-dimensional code positioning method provided by the exemplary embodiment of the invention, the pixel scanning areas are determined on the binary image, and the pixel distribution condition in the pixel scanning areas is judged according to the standard pixel quantity specification and the auxiliary pixel quantity specification, so that the position detection graph with the defect area in the binary image can be identified, the positioning accuracy and the positioning success rate of the two-dimensional code are improved, the identification efficiency of the two-dimensional code is improved, and the two-dimensional code scanning experience of a user is improved.
The key to determining the position detection pattern in the binarized image is the determination of the pixel scanning area. In general, a pixel scanning area can be searched in two mutually perpendicular directions of a row pixel direction and a column pixel direction in the binarized image, and the correspondingly determined pixel scanning area can be a transverse scanning area or a longitudinal scanning area. Fig. 7 schematically illustrates a flow chart of steps for determining pixel scan areas in some exemplary embodiments of the invention. As shown in fig. 7, on the basis of the above embodiment, step s510. Determining a plurality of pixel scanning areas located on the binarized image according to the pixel distribution information in the binarized image may include the steps of:
step S710. Determining a transverse scanning line along the row pixel arrangement direction and a longitudinal scanning line along the column pixel arrangement direction on the binary image.
Firstly, determining a plurality of groups of scanning lines on the binary image, wherein the groups of scanning lines comprise transverse scanning lines along the arrangement direction of row pixels and longitudinal scanning lines along the arrangement direction of column pixels. In general, one horizontal scan line represents one pixel row in the binarized image, and one vertical scan line represents one pixel column in the binarized image. With continued reference to fig. 6, two transverse scan lines 640, 650 in the row pixel arrangement direction and two longitudinal scan lines 660, 670 in the column pixel arrangement direction may be determined on the binarized image.
And S720, determining one or more transverse scanning areas on the transverse scanning lines according to the pixel distribution information on the transverse scanning lines.
For the pixel row corresponding to the horizontal scanning line, this step may acquire pixel distribution information on the pixel row, and then determine one or more horizontal scanning areas on the horizontal scanning line according to the pixel distribution information. As shown in fig. 6, two lateral scan regions may be defined on the lateral scan line 640 located at the upper side in the figure, and one lateral scan region may be defined on the lateral scan line 650 located at the lower side in the figure.
Step s730. One or more longitudinal scanning areas are determined on the longitudinal scanning lines according to the pixel distribution information on the longitudinal scanning lines.
For a pixel column corresponding to a vertical scanning line, this step may acquire pixel distribution information on the pixel column, and then determine one or more vertical scanning areas on the vertical scanning line according to the pixel distribution information. As shown in fig. 6, two longitudinal scanning areas can be determined on the longitudinal scanning line 660 located on the left side in the figure, and one longitudinal scanning area can be determined on the longitudinal scanning line 670 located on the right side in the figure.
Fig. 6 shows a binarized image including only one two-dimensional code, and when a plurality of two-dimensional codes are included in the binarized image to be recognized, more pixel scanning areas may be distributed on each of the transverse scanning lines and the longitudinal scanning lines.
In some exemplary embodiments of the present invention, for a pixel scanning area, a plurality of pixel arrangement blocks distributed in succession may be included inside the pixel scanning area, each pixel arrangement block is composed of pixel points having the same pixel value, and each two adjacent pixel arrangement blocks have different pixel values. In other words, in a binarized image, the pixel arrangement blocks in the pixel scanning area are arranged in a black-white interval distribution. When it is necessary to determine whether a pixel scanning area is a standard pixel scanning area or an auxiliary pixel scanning area, the determination may be performed according to the pixel number relationship of each pixel arrangement block inside the pixel scanning area.
Fig. 8 schematically illustrates a flow chart of steps for determining a standard pixel scan area in some exemplary embodiments of the invention. As shown in fig. 8, on the basis of the above exemplary embodiments, step s520, when the number of pixels in the pixel scanning area is the standard number of pixels, determining the pixel scanning area as the standard pixel scanning area may further include the steps of:
step S810, acquiring the pixel quantity of each pixel arrangement block in the pixel scanning area.
Aiming at a pixel scanning area to be judged, the step obtains the pixel quantity of each pixel block in the pixel scanning area by identifying the pixel value of each pixel point. For example, one pixel scanning area includes five sequentially connected pixel arrangement blocks, and the number of pixels of each pixel arrangement block is p 1 、p 2 、p 3 、p 4 And p 5
Step S820, determining the standard block unit width and the standard width error limit of the pixel scanning area according to the pixel number of each pixel arrangement block.
The number of pixels per pixel arrangement block can be regarded as the block pixel width of the pixel arrangement block. The standard block width and standard width error limit of the pixel scanning area can be determined according to the pixel number of each pixel arrangement block. For example, the standard block width d can be represented by the formula d = (p) 1 +p 2 +p 3 +p 4 +p 5 ) And/7 is calculated. The standard width error limit Δ represents the allowable range of the pixel number error associated with the standard block width d. Alternatively, the standard width error limit Δ may be 0.5 to 0.75 times the standard block unit width d.
Step S830, determining a standard pixel number range corresponding to each pixel arrangement block according to the standard block unit width and the standard width error limit.
After determining the standard block unit width and the standard width error limit, this step may determine the standard pixel number ranges respectively corresponding to the respective pixel arrangement blocks. For example, for four pixel arrangement blocks located on both sides, the criteria thereof can be determinedThe number range of the pixels is max (d-delta, 1) is less than or equal to p i D + Δ ≦ (i =1,2,4,5); for a pixel arrangement block located at the center, it can be determined that the standard pixel number thereof is in the range of max (3 d-3 Δ, 1) ≦ p 3 Not more than 3d +3 delta. The standard pixel number range can be used for judging whether the pixel number of each pixel arrangement block substantially satisfies the number proportion relationship of 1.
Step s840, when the number of pixels in each pixel arrangement block is within the standard number of pixels, determining the number of pixels in the pixel scanning area as the standard number of pixels, and determining the pixel scanning area as the standard pixel scanning area.
According to the standard pixel number range determined in step S830, the number of pixels of each pixel arrangement block may be detected, and if the number of pixels of each pixel arrangement block in one pixel scanning area is within the standard pixel number range, it may be determined that the number of pixels in the pixel scanning area is the standard pixel number, and further, the pixel scanning area may be determined as the standard pixel scanning area.
Similar to the determination method of the standard pixel scanning area, the number of pixels of each pixel arrangement block in the pixel scanning area may be detected using the auxiliary pixel number range, so that the auxiliary pixel scanning area may be determined. Fig. 9 schematically illustrates a flow chart of steps for determining an auxiliary pixel scanning area in some exemplary embodiments of the invention. As shown in fig. 9, on the basis of the above exemplary embodiments, step s530. When the number of pixels in the pixel scanning area is the auxiliary pixel number, determining the pixel scanning area as an auxiliary pixel scanning area with a defect area may further include the steps of:
step S910, when the number of pixels of one or more pixel arrangement blocks located at one side edge of the pixel scanning area is out of the range of the standard number of pixels, the pixel arrangement block is taken as a defect block.
According to the detection result of the number of pixels in step S840, if the pixel is located at one side edge of the pixel scanning areaThe number of pixels of one or more pixel arrangement blocks is out of the standard pixel number range, and those pixel arrangement blocks whose number of pixels does not satisfy the standard pixel number range may be regarded as defective blocks. For example, of five consecutive pixel arrangement blocks, the number p of pixels of the fourth pixel arrangement block located on one side 4 And the number p of pixels of the fifth pixel arrangement block 5 If the standard pixel number range is not satisfied, the two pixel arrangement blocks are determined as defective blocks.
Step s920, using other pixel arrangement blocks in the pixel scanning area except the defective block as standard blocks, and determining the auxiliary block unit width and the auxiliary width error limit of the pixel scanning area according to the number of pixels of the standard blocks.
After the defective block is determined by step S910, this step may determine other pixel arrangement blocks in the pixel scanning area except for the defective block as the standard blocks, while the auxiliary-block unit width and the auxiliary-width error limit of the pixel scanning area may be determined according to the number of pixels of each standard block. For example, if it is determined that the first four pixel arrangement blocks in the pixel scanning area are standard blocks and the fifth pixel arrangement block is a defective block, the auxiliary block unit width d 'may be defined by the formula d' = (p) 1 +p 2 +p 3 +p 4 ) And/6 is calculated. For another example, if it is determined that the first three pixel arrangement blocks in the pixel scanning area are standard blocks and the last two pixel arrangement blocks are defective blocks, the auxiliary block unit width d 'may be represented by the formula d' = (p) 1 +p 2 +p 3 ) And/5 is calculated. The auxiliary width error limit Δ 'represents a pixel number error tolerance range associated with the auxiliary block width d'. Alternatively, the auxiliary width error limit Δ 'may be 0.5 to 0.75 times the auxiliary block unit width d'.
And S930, determining the auxiliary pixel number range corresponding to each standard block according to the auxiliary block unit width and the auxiliary width error limit.
After determining the auxiliary block unit width and the auxiliary width error limit, this step can determineThe auxiliary pixel number range is respectively corresponding to each pixel arrangement block. For example, for a standard block located on both sides, it can be determined that the number of auxiliary pixels is in the range of max (d- Δ, 1) ≦ p i D + Δ ≦ (i =1,2); for a standard tile located at the center, it can be determined that the number of its auxiliary pixels is in the range max (3 d-3 Δ, 1) ≦ p 3 Not more than 3d +3 delta. The auxiliary pixel number range can be used for judging whether the pixel number of each standard block substantially satisfies 1.
Step s940, when the number of pixels of each standard block and the defective block is within the range of the number of auxiliary pixels, determining the number of pixels in the pixel scanning area as the number of auxiliary pixels, and determining the pixel scanning area as an auxiliary pixel scanning area with a defective area.
According to the auxiliary pixel number range determined in step S930, the pixel number of each standard block may be detected, and if the pixel number of each standard block in a pixel scanning area is within the auxiliary pixel number range, it may be determined that the pixel number in the pixel scanning area is the auxiliary pixel number, and the pixel scanning area may be determined as the auxiliary pixel scanning area with the defect area.
Based on the technical scheme provided by the above exemplary embodiments, the standard pixel scanning area and the auxiliary pixel scanning area can be determined in the binarized image, and on the basis, the position detection pattern for positioning the two-dimensional code can be further determined. Fig. 10 schematically illustrates a flowchart of the steps for determining a position detection pattern in some exemplary embodiments of the invention. As shown in fig. 10, on the basis of the above exemplary embodiments, step s540. Determining a position detection pattern for positioning a two-dimensional code according to a standard pixel scanning area and an auxiliary pixel scanning area may further include the following steps:
step S1010, determining a candidate position detection area according to the standard pixel scanning area and the auxiliary pixel scanning area, and determining the area center of the candidate position detection area.
After the standard pixel scanning area and the auxiliary pixel scanning area are determined in the binarized image, the candidate position detection area can be determined according to the position relationship of each pixel scanning area in the step. In some alternative embodiments, one candidate position detection region may be determined by two similar standard pixel scanning regions, and one candidate position detection region may be determined by two similar auxiliary pixel scanning regions. In addition, a candidate position detection region can be determined by a standard pixel scanning region and an auxiliary pixel scanning region located close to the standard pixel scanning region. The candidate position detection region may be a region that is generally approximately rectangular, and the geometric center of the candidate position detection region may be the region center of the candidate position detection region in this step.
Step S1020, a plurality of area size reference lines passing through the center of the area are selected in the candidate position detection area.
After determining the area center of the candidate position detection area, this step may select a plurality of area size reference lines passing through the area center in the subsequent position detection area. The region size reference line is used to determine the region width of the candidate position detection region in each direction. For example, in some alternative embodiments, one area size reference line may be determined in each of the lateral, longitudinal, and two diagonal directions, respectively, and thus four area size reference lines corresponding to one candidate position detection area may be determined.
Step S1030, the length of each area size reference line is obtained, and a standard area size difference value is determined according to the length.
For each region size reference line, the number of pixels of the coverage region represents the length of the region size reference line, and a standard region size difference value can be determined according to the length of each region size reference line. For example, one area size reference line in the horizontal direction has a length d h A length of one area size reference line in the vertical direction is d v The length of the region size reference line in the upper left to lower right diagonal direction is d d1 Regional ruler along diagonal direction from upper right to lower leftThe length of the inch reference line is d d2 Then, this step may determine the standard region size difference σ as:
Figure BDA0002174829690000201
and S1040, when the length of each area size reference line meets the standard area size difference, determining the candidate position detection area as a position detection graph for positioning the two-dimensional code.
According to the standard area size difference determined in step S1030, the step may determine the length relationship of each area size reference line, and if the standard area size difference is satisfied, the candidate position detection area may be determined as a position detection pattern for positioning the two-dimensional code. For example, if d h 、d v
Figure BDA0002174829690000211
And
Figure BDA0002174829690000212
the difference between every two of the four length values is smaller than the size difference sigma of the standard area, so that the candidate position detection area can be judged to basically meet the requirement in four directions
Figure BDA0002174829690000213
The width consistency rule of (2). And the candidate position detection region satisfying the width consistency rule can be determined as the position detection pattern for positioning the two-dimensional code.
When the position detection pattern is determined, in addition to the detection judgment by using the width consistency rule, the further judgment can be performed by using the area center closing rule. Fig. 11 schematically illustrates a flow chart of the steps for determining a position detection pattern in some exemplary embodiments of the invention. As shown in fig. 11, on the basis of the above exemplary embodiments, the determining the candidate position detection area as the position detection pattern for positioning the two-dimensional code in step S1040 may further include the following steps:
step S1110, determining a central pixel block located in the center of the candidate position detection area according to the position and the pixel value of the area center.
Based on the area center determined in step S1010 and the pixel value of the area center, this step may determine a center pixel patch located at the center of the candidate position detection area. For example, for a position detection pattern of a two-dimensional code, the inner center thereof is generally a rectangular black pixel region.
Step s1120, when the central pixel block is a closed block having a plurality of boundary lines, determining the candidate position detection area as a position detection pattern for positioning the two-dimensional code.
According to the central pixel block determined in step S1110, this step determines whether the area is closed, and if it is determined that the central pixel block is a closed block with a plurality of boundary lines, the corresponding candidate position detection area may be determined as a position detection pattern for positioning the two-dimensional code. If the central pixel block is not closed, the candidate position detection region is not considered to be a real position detection pattern.
In general, the central pixel block in a position detection pattern may be a rectangular block having four boundary lines, and the region center of the position detection pattern should also be the geometric center of the central pixel block. On the basis, the distance relation between the area center and each boundary line can be used for further judging the credibility of the position detection graph. As shown in fig. 12, on the basis of the above exemplary embodiments, step s1120, when the central pixel block is a closed block having a plurality of boundary lines, determining the candidate position detection area as the position detection pattern for positioning the two-dimensional code may further include the steps of:
s1210, determining a plurality of boundary lines of the central pixel block, and acquiring the vertical distance between the center of the area and each boundary line;
and S1220, when the boundary lines form a closed block and the vertical distance is within the standard distance range, determining the candidate position detection area as a position detection graph for positioning the two-dimensional code.
In the present exemplary embodiment, a standard distance range may be determined according to the number of pixels of the standard pixel scanning area and the auxiliary pixel scanning area in the candidate position detection area, and if each boundary line of the center pixel block forms a closed block and the distance between the area center of the center pixel block and each boundary line is within the standard distance range, the candidate position detection area may be determined as a position detection pattern for positioning the two-dimensional code. If either of the two conditions of the block closure and the standard distance range is not satisfied, it can be regarded that the candidate position detection region is not a real position detection pattern.
If it can be determined that only one two-dimensional code is contained in one binarized image, the position of the two-dimensional code in the image can be basically determined as long as three position detection patterns are recognized in the binarized image by the two-dimensional code positioning method provided in each of the above exemplary embodiments. However, if a plurality of two-dimensional codes are contained in one binarized image at the same time, more than three or more position detection patterns may be recognized in the binarized image by using the two-dimensional code positioning method provided in each of the above exemplary embodiments. On the basis, further judgment needs to be carried out on each position detection graph so as to accurately position one or more two-dimensional codes from the binary image. Figure 13 schematically shows a flow chart of the steps of determining the position of a two-dimensional code in some exemplary embodiments of the invention. As shown in fig. 13, on the basis of the above exemplary embodiments, the two-dimensional code positioning method further includes the following steps:
and S1310, forming a position detection graph set by the position detection graphs in the binary image.
As described above, one or more two-dimensional codes may be included in one binarized image, and after the detection of all position detection patterns in the binarized image is completed, this step may combine the position detection patterns into one position detection pattern set.
And S1320, clustering the position detection graph set according to the size information and the position information of each position detection graph to obtain a ternary graph combination consisting of three position detection graphs.
Based on the position detection image set obtained in step S1310, this step can perform clustering processing on each position detection pattern included in the set, the clustering processing being mainly based on the size information and the position information of each position detection pattern. After clustering processing, three position detection images with similar sizes and positions can form a three-dimensional graph combination. For example, if the position detection image set includes nine position detection patterns, three combinations of three ternary patterns can be obtained after the clustering process.
And S1330, determining the position of the two-dimensional code in the binary image according to the ternary graph combination.
Generally, a two-dimensional code includes three position detection patterns, which are respectively located at the upper left corner, the lower left corner and the upper right corner of the two-dimensional code. Therefore, a three-dimensional pattern combination consisting of three position detection patterns can substantially determine the position of a two-dimensional code.
The two-dimension code identification of the batch of the binary images comprising a plurality of two-dimension codes can be realized by clustering the position detection graphs. Of course, if two-dimensional codes with close sizes and close position distances are included in one binarized image, the position detection patterns in the two-dimensional codes may interfere with each other. Therefore, how to determine the ternary graph combination is the key point for accurately positioning the two-dimensional code. FIG. 14 schematically illustrates a flowchart of the steps for determining a combination of ternary graphs, in some exemplary embodiments of the present invention. As shown in fig. 14, on the basis of the above exemplary embodiments, step s1320, after performing clustering processing on the position detection pattern set according to the size information and the position information of each position detection pattern, a ternary pattern combination composed of three position detection patterns is obtained, which may further include the following steps:
and S1410, selecting two position detection graphs with similar sizes from the position detection graph set to form a binary graph combination according to the size information of each position detection graph.
The clustering processing of the position detection graphs is mainly based on the size information and the position information of each position detection graph, the step firstly takes the size information as the clustering basis, two position detection graphs with similar sizes are selected from a position detection graph set to form a binary graph combination, and the size of the binary graph combination can be determined according to the sizes of the two position detection graphs forming the binary graph combination. The size of the binary pattern combination can be represented as a size range, the lower limit of the range is the smaller size of the two position detection patterns, and the upper limit of the range is the larger size of the two position detection patterns; alternatively, the average of the sizes of the two position detection patterns may be directly used as the size of the binary pattern combination.
And S1420, selecting the position detection graph with the size similar to the combined size of the binary graphs from the position detection graph set as a third candidate graph.
And after the binary figure combination is determined, continuously selecting a position detection figure with the size close to the size of the binary figure combination from the position detection figure set as a third candidate figure. In other words, the third candidate pattern should have a size close to that of any one of the position detection patterns in the binary pattern combination, and specifically, the difference between the sizes of the third candidate pattern and the two position detection patterns in the binary pattern combination is within a certain error range.
And S1430, judging whether the binary pattern combination and the third candidate pattern accord with the standard position relation or not according to the position information of each position detection pattern.
The binary pattern combination and a third candidate pattern with similar sizes can be determined through size information judgment, and if the three position detection patterns determined by the size information belong to the same two-dimensional code, the position relation of the position detection patterns needs to be continuously judged. The step detects the position information of each position detection graph by using the standard position relation, thereby judging whether the binary graph combination and the third candidate graph accord with the standard position relation.
And S1440, when the binary graph combination and the third candidate graph accord with the standard position relation, the binary graph combination and the third candidate graph form a ternary graph combination.
And if the binary pattern combination and the third candidate pattern are judged to accord with the standard position relation, the binary pattern combination and the third candidate pattern can be combined into a ternary pattern combination for further determining the position of the two-dimensional code.
And S1450, when the binary graph combination and the third candidate graph do not accord with the standard position relation, selecting a new third candidate graph from the position detection graph set, and continuously judging whether the newly selected third candidate graph can form a ternary graph combination with the binary graph.
If the binary pattern combination and the third candidate pattern are judged not to conform to the standard position relationship, the binary pattern combination and the third candidate pattern may be considered not to be the same position detection pattern belonging to the two-dimensional code, at this time, step S1420 may be continuously performed to select a new third candidate pattern from the position detection pattern set, and step S1430 may be performed again to judge whether the newly selected third candidate pattern and the binary pattern conform to the standard position relationship, so as to judge whether the newly selected third candidate pattern and the binary pattern can form a ternary pattern combination.
As can be appreciated from the above exemplary embodiments, in order to determine a ternary pattern combination, a binary pattern combination may first be determined in a set of position detection patterns, and FIG. 15 schematically illustrates a flow chart of steps for determining a binary pattern combination in some exemplary embodiments of the present invention. As shown in fig. 15, on the basis of the above exemplary embodiments, in step s1410, according to the size information of each position detection pattern, two position detection patterns with similar sizes are selected from the position detection pattern set to form a binary pattern combination, which may further include the following steps:
and S1510, performing size sequencing on each position detection graph in the position detection graph set according to the size information of each position detection graph to obtain a graph sequence.
For the position detection patterns in the position detection pattern set, the step performs size sorting on the position detection patterns according to respective size information of the position detection patterns to obtain a pattern sequence. For example, the position detection patterns in the position detection pattern set may be sorted in order of size from small to large or from large to small.
Step S1520, forming a candidate pattern combination by every two adjacent position detection patterns in the pattern sequence, and determining the size difference of the two position detection patterns in the candidate pattern combination.
Based on the graph sequence obtained in step S1520, in this step, every two adjacent position detection graphs in the graph sequence are combined to form a plurality of candidate graph combinations, and each candidate graph thus obtained includes two position detection graphs with similar sizes. For example, the pattern sequence includes nine position detection patterns arranged in sequence, and eight candidate pattern combinations can be obtained after two-by-two combination. Meanwhile, the step can also calculate the size difference of the two position detection graphs in the candidate graph combination as the basis for continuously sequencing the candidate graph combination.
And S1530, sorting each candidate graph combination according to the size difference to obtain a combination sequence.
The size difference can reflect the size similarity of the two position detection patterns, and after the candidate pattern combinations and the size differences corresponding to the candidate pattern combinations are obtained in step S1520, the candidate pattern combinations are sorted according to the size differences to obtain a combination sequence. Alternatively, this step may sort the candidate graphic combinations in order of the size difference from small to large.
And S1540, sequentially selecting candidate graph combinations from the combination sequence as binary graph combinations.
The two position detection patterns with smaller size difference have higher size similarity, so according to the arrangement sequence of the candidate pattern combinations in the combination sequence, the step can sequentially select the candidate pattern combination from the combination sequence as the binary pattern combination, which is equivalent to sequentially selecting the two position detection patterns from the position detection pattern set as the binary pattern combination according to the size similarity.
And for each binary graph combination, continuously selecting a third candidate graph from the position detection graph set, and judging whether the binary graph combination and the third candidate graph can form a ternary graph combination or not by utilizing the standard position relation. Fig. 16 schematically illustrates a flowchart of steps for determining a positional relationship in some exemplary embodiments of the present invention. As shown in fig. 16, on the basis of the above exemplary embodiments, step s1430, determining whether the binary pattern combination and the third candidate pattern meet the standard position relationship according to the position information of each position detection pattern, may further include the following steps:
step S1610, according to the position information of each position detection graph, determining a central connecting line between every two position detection graphs and a third candidate graph in the binary graph combination.
According to the position information of each position detection pattern in the binary image, the step can determine the central positions of two position detection patterns in the binary pattern combination and the central position of one position detection pattern serving as a third candidate pattern, and then can determine the central connecting line between every two three position detection patterns.
Step S1620, the connecting line length of each central connecting line is obtained, and two short-side connecting lines and a long-side connecting line are determined according to the connecting line length.
Three central connecting lines can be formed among the three position detection patterns, and two short-side connecting lines and one long-side connecting line can be determined according to the length relation among the three central connecting lines. If the three position detection patterns belong to the same standard two-dimensional code, then according to the standard position relationship, the three central connecting lines should basically form the shape of an isosceles right triangle, the connecting line of the two short sides is the two right-angle sides of the isosceles right triangle, and the connecting line of the long sides is the hypotenuse of the isosceles right triangle.
Step S1630, when the length difference value of the two short side connecting lines is smaller than the length error limit and neither short side connecting line passes through the defect area of the position detection graph, judging that the binary graph combination and the third candidate graph accord with the standard position relation.
The standard position relation refers to the position relation that the three position detection graphs are respectively distributed at the upper left corner, the lower left corner and the lower right corner of the two-dimensional code, and according to the position relation, the length of the connecting line of the two short edges is basically equal. In addition, in the two-dimensional code, the central connecting lines of the three position detection patterns should be located on the inner side of the two-dimensional code without being affected by the blank area pollution, and therefore, the three central connecting lines should not pass through the defect areas distributed on the outer side of the two-dimensional code in the position detection patterns. If the length difference value of the two short-edge connecting lines is judged to be smaller than a preset length error limit, and the two short-edge connecting lines do not pass through the defect area of the position detection pattern, the corresponding binary pattern combination and the third candidate pattern can be judged to accord with the standard position relation. Optionally, a length error limit may be determined before this step based on the length of the two short edges connecting the line. For example, the length of the two short side lines is l 1 And l 2 The length error limit may be determined to be 0.2 x min (l) 1 ,l 2 )。
Step S1640, when the length difference of the two short edge connecting lines is greater than or equal to the length error limit or the short edge connecting line passes through the defect area of the position detection pattern, judging that the binary pattern combination and the third candidate pattern do not accord with the standard position relation.
If the difference between the lengths of the two short edge connecting lines is judged to be larger than or equal to the length error limit or any one short edge connecting line passes through the defect area of the position detection pattern, the corresponding binary pattern combination and the third candidate pattern can be judged not to accord with the standard position relation.
Fig. 17 schematically shows a flowchart of steps of the method provided in the above exemplary embodiments in a specific application scenario. In the application scene, a new method for detecting the two-dimensional code based on the position detection graph is provided for the two-dimensional code with the polluted blank area, so as to realize the positioning of the two-dimensional code. Alternatively, for a binarized input image, the method firstly designs two state rules for detecting the position detection patterns in the directions of row pixels and column pixels (diagonal pixels or pixels at any angle) and a polarity rule for marking whether a blank area on one side of the position detection patterns is polluted or not, and is used for detecting the position detection patterns with defects in the input image. After the candidate objects of the position detection graph are detected, the candidate objects of the position detection graph with false positives are removed through two screening rules, namely 1) width consistency rules in the horizontal direction, the vertical direction and the diagonal direction and 2) a region closing rule of a central square. And finally, clustering the remaining position detection graph candidate objects into a group of three, wherein each combination obtained by clustering is used as positioning of the primary two-dimensional code and can be used for identification of the subsequent two-dimensional codes.
As shown in fig. 17, the method may mainly include the following steps:
step s1701. Obtain the binarized input image.
In an actual application scene, in order to beautify the visual effect of the two-dimensional code, the color of the standard black and white two-dimensional code is usually transformed, so that the image needs to be subjected to binarization processing before the two-dimensional code in the image is positioned. The general binarization algorithm (e.g. binarization in ZBar, ZXing) can stably separate the two-dimensional code with blank space from the background, thereby ensuring that the area of the position detection pattern can meet the standard specification. However, for the two-dimensional code with a polluted blank area, the two-dimensional code area cannot be completely separated from the background by the binarization algorithms, and the detection of the position detection pattern is finally influenced. The invention does not limit the binarization algorithm, and can be applied to binarization of the image before the invention as long as a robust algorithm is adopted, thereby ensuring that the original standard-conforming two-dimensional code positioning effect is not influenced.
Step 1702, detecting pixel arrangement conforming to the rule on the binary image according to a preset scanning rule.
For the input binary image, the pixel array with 5 states of black, white, black, white and black continuously changing can be scanned along the row pixel direction, and the number of pixels in each state can be recorded at the same time. If the proportion of the number of the pixels in each state of the arrangement preferentially meets 1.
If the array does not meet the standard specification, whether the array meets the first auxiliary state rule is checked, namely the ratio of the number of the pixels of each state is x:1 (x is more than or equal to 0) 1 、p 2 、p 3 、p 4 And p 5 If the first auxiliary state rule is satisfied from left to right, p is 1 :p 2 :p 3 :p 4 :p 5 1 (x ≧ 1) 5 :p 4 :p 3 :p 3 :p 1 1 (= x: 1). If the arrangement meets the first auxiliary state rule, the arrangement is determined to be a pixel arrangement meeting the rule.
If the pixel number of the pixel does not accord with the first auxiliary state rule, continuously checking whether the pixel number of the pixel accords with a second auxiliary state rule, namely that the ratio of the number of the pixels in each state is x: y:3>1) In the practical operation, the number of black and white pixels on one side is not subjected to proportion check, the number proportion of the remaining black, white and black pixels meets the following requirement of 1. During scanning along the row pixel direction, it is checked whether the arrangement complies with the second auxiliary state rule from left to right or from right to left (similarly, a left-to-right coincidence means p) 1 :p 2 :p 3 :p 4 :p 5 =x:y:3:1:1(x≥0,y>1) From the rightBy left coincidence is meant p 5 :p 4 :p 3 :p 3 :p 1 =x:y:3:1:1(x≥0,y>1). If the arrangement meets the second auxiliary state rule, the arrangement is determined to be a pixel arrangement meeting the rule. If not, skipping the array and continuing to scan the next pixel array with 5 states of black, white, black, white and black continuously changing.
In an actual binarized image, the ratio of the number of pixels in each state does not strictly meet the state rule, and therefore a certain error allowable range Δ is given to each state. Usually, Δ is set to 0.5 times the width d of the corresponding pixel arrangement unit, and in order to better detect a two-dimensional code with affine transformation in the present invention, Δ is set to 0.75 times d. Specifically, the number p of pixels in a certain arrangement is checked 1 、p 2 、p 3 、p 4 And p 5 If the standard specification is met, the unit width calculation formula is
Figure BDA0002174829690000291
Error tolerance range Δ =0.75d, in which case the ratio check can be changed to a check of the corresponding error tolerance range, i.e. max (d- Δ, 1) ≦ p i ≤d+Δ(i=1,2,4,5),max(3d-3Δ,1)≤p 3 Not more than 3d +3 delta; while checking an arrangement p 1 、p 2 、p 3 、p 4 And p 5 If the first auxiliary state rule is satisfied, the calculation of the unit width only needs to be related to the state for performing the ratio check, and if the check is satisfied from left to right, the calculation formula is
Figure BDA0002174829690000292
If the check is right to left, the calculation formula is
Figure BDA0002174829690000293
The subsequent scale check is as described above; in the same way, the arrangement p can be checked 1 、p 2 、p 3 、p 4 And p 5 Whether the second auxiliary state rule is met or not, and when whether the second auxiliary state rule is met or not is checked, the calculation formula of the unit width d is
Figure BDA0002174829690000301
And checking whether the right to left is consistent, wherein the calculation formula is
Figure BDA0002174829690000302
The scanning in the row pixel direction is a preset scanning rule, and 5 pixel arrangements in which the states of black, white, and black are continuously changed may be scanned in the column pixel direction, and the number of pixels in each state may be recorded. The rules for the checks are in the same row of pixel directions, except that the left-to-right, right-to-left checks change to top-to-bottom, bottom-to-top checks.
FIG. 18 is a schematic diagram showing various position detection patterns having a regular pixel arrangement in the row and column pixel directions. Fig. 18 (a) is a position detection pattern conforming to the standard specification, fig. 18 (b) is a position detection pattern conforming to the first auxiliary state rule from left to right, fig. 18 (c) is a position detection pattern conforming to the first auxiliary state rule from right to left, fig. 18 (d) is a position detection pattern conforming to the first auxiliary state rule from top to bottom, fig. 18 (e) is a position detection pattern conforming to the first auxiliary state rule from bottom to top, fig. 18 (f) is a position detection pattern conforming to the second auxiliary state rule from left to right, fig. 18 (g) is a position detection pattern conforming to the second auxiliary state rule from right to left, fig. 18 (h) is a position detection pattern conforming to the second auxiliary state rule from top to bottom, and fig. 18 (i) is a position detection pattern conforming to the second auxiliary state rule from bottom to top.
And S1703, determining whether the pixel arrangement accords with the rule or not according to the determined pixel arrangement.
Checking the order of the standard specification, the first auxiliary state rule and the second auxiliary state rule in turn, and if the pixel arrangement preferably meets the standard specification, determining that the arrangement has no polarity; if the pixel arrangement meets the first auxiliary state rule or the second auxiliary state rule, the arrangement is determined to have polarity.
And S1704, determining the polarity of the pixel arrangement according to the condition of meeting the auxiliary state rule.
When scanning along the row pixel direction, if the pixel arrangement with polarity accords with a first auxiliary state rule or a second auxiliary state rule from left to right, the polarity is determined as negative; if the pixel arrangement with polarity meets the first auxiliary state rule or the second auxiliary state rule from right to left, the polarity is determined to be positive (i.e. the polarity is opposite from left to right to left). When scanning along the column pixel direction, if the pixel arrangement with polarity accords with the first auxiliary state rule or the second auxiliary state rule from top to bottom, the polarity is determined as negative; and if the arrangement of the pixels with the polarity accords with the first auxiliary state rule or the second auxiliary state rule from bottom to top, determining the polarity of the pixels as positive.
Step S1705, aiming at the pixel arrangement with the determined polarity, the central position of the arrangement is calculated.
When scanning along the row pixel direction, for the pixel arrangement meeting the standard specification, if the number of the pixels arranged along the scanning direction is p 1 、p 2 、p 3 、p 4 And p 5 The horizontal center position of the array may be shifted back with reference to the outer edge of the 5 th black state
Figure BDA0002174829690000311
Determining the distance; for arrangements conforming to the first auxiliary state rule or the second auxiliary state rule, the horizontal center position thereof may be shifted back with reference to the outer edge of the 5 th black state
Figure BDA0002174829690000312
And (4) determining the distance. The above calculation method can eliminate the influence of the black square (3 rd black state) at the center of the arrangement on the center position estimation of the position detection pattern when there is an internal offset.
The calculation of the position of the vertical center of the arrangement when scanning in the column pixel direction is as described above.
Step s1706, with respect to the pixel arrangement at the determined central position, checks whether the pixel arrangement in the vertical direction at the center thereof meets the rule, thereby determining a candidate object of the position detection figure.
If the above-mentioned pixel arrangement is determined in the row pixel direction, it is checked whether the nearest pixel arrangement conforms to the rule in the column pixel direction at the center thereof. The nearest pixel arrangement refers to an arrangement that 3 continuous changes of black, white and black are scanned upwards from the center, 3 continuous changes of black, white and black are scanned downwards, and finally, a middle black state is combined to form a pixel arrangement that 5 continuous changes of black, white, black, white and black are combined from top to bottom. Step S1702 is applied to the pixel arrangement, and it is determined whether it is a pixel arrangement that meets the rule. If the pixel array is not matched, the area near the row and column pixel array is determined as a candidate object of the position detection graph, the polarity of the pixel array in the column pixel direction is determined by applying the step S1703 and the step S1704, and if the pixel array is not matched, the further inspection of the area is cancelled.
If the pixel arrangement passing through the determined center position is determined in the column direction, the pixel arrangement is checked in the line pixel direction at the center similarly, thereby determining a candidate for the position detection pattern.
S1707, aiming at the candidate object of the determined position detection graph, the central position of the candidate object is calculated according to the row pixel arrangement and the column pixel arrangement of the determined polarity.
For the column pixel arrangement (or row pixel arrangement) of the candidate object, the vertical center position (or horizontal center position) thereof can be obtained by applying step S1705, and then the horizontal center position of the row pixel arrangement and the vertical center position of the column pixel arrangement of the candidate object are taken as the center position of the candidate object.
Fig. 19 shows a schematic diagram of a position detection figure candidate and its central position. Fig. 19 (a) shows the position detection figure candidate determined by checking the row pixel arrangement first and then the column pixel arrangement, the circle indicating the horizontal center position of the row pixel arrangement, and the asterisk indicating the vertical center position of the column pixel arrangement. Fig. 19 (b) shows the position detection pattern candidates determined by checking the column pixel arrangement first and then the row pixel arrangement.
S1708, screening the candidate objects according to the center positions of the candidate objects, and determining the candidate objects meeting the conditions by applying a first screening rule-a width consistency rule of the position detection graph in the horizontal, vertical and diagonal directions.
Estimating the width of the position detection pattern according to the determined polarity combination condition of the row pixel arrangement and the column pixel arrangement in the position detection pattern candidate object. If the row pixel arrangement and the column pixel arrangement both have no polarity or have polarity in only one direction, scanning of pixel arrangement with 5 states of black, white, black, white and black continuously changing in 4 directions of horizontal, vertical, upper left to lower right diagonal and upper right to lower left diagonal is required, the scanning process is the same as step S1706, scanning is performed from the center to two sides, and the pixel arrangement obtained by scanning is synchronized with step S1702 to perform corresponding rule check. If the 4 arrays meet the rule, estimating the width of the position detection graph in each direction; if one direction does not accord with the rule, the candidate object is directly removed.
The estimated width of the position detection pattern is 7 times the width d of the pixel arrangement unit that meets the correspondence rule in step S1702. Recording the width of the position detection pattern in the horizontal direction as d h Width in the vertical direction of d v The width of the upper left diagonal to the lower right diagonal is d d1 The width of the diagonal line from the upper right to the lower left is d d2 The rule of width consistency means
Figure BDA0002174829690000321
In practice, given a certain deviation tolerance σ for the estimated width in each direction, this value can be set to 0.2 times the minimum width, i.e. the minimum width
Figure BDA0002174829690000322
So that the absolute value of the estimated width difference for each direction should be less than sigma. If the 4 directions of the candidate object all meet the width consistency rule, the candidate object is reserved; otherwise, the candidate object is eliminated.
If the row pixel arrangement and the column pixel arrangement have polarities, the pixel arrangement with 5 states of black, white, black, white and black continuously changing in 3 directions of the horizontal direction, the vertical direction and the one-place diagonal is checked. The above-mentioned one adapted diagonal line means that only one side of the diagonal line enters the defective area of the position detection pattern. If the uniform pixel arrangement conforms to the rule, checking the consistency rule of the width of the position detection graph in each direction, as above; if one direction is not matched, the candidate object is directly removed.
Fig. 20 shows a schematic diagram of pixel arrangement checking in each direction by the width consistency rule applied under different polarity conditions. Fig. 20 (a) shows that the inspection in 4 directions is required when the rows and columns have no polarity, fig. 20 (b) shows that the inspection in 4 directions is required when the pixels in the rows have polarity, and fig. 20 (c) and 20 (d) show the inspection in 3 directions when the rows and columns have polarity, respectively.
S1709, for the determined position detection graph candidate object, further applying a second screening rule-a central square area closing rule-to determine a candidate object meeting the rule.
Besides the characteristics that each state is in a certain proportion, the central black square and the outer black pixels of the position detection graph are usually separated, so that the false positive position detection graph introduced in the previous step can be further eliminated by utilizing the characteristic that the central square area is closed. If the area is closed, the candidate object is reserved, otherwise, the candidate object is removed. In actual operation, the position of the closed line can be scanned horizontally upwards and downwards along the center position of the candidate object respectively, so as to judge whether the central black area is closed or not. The closed line is an intersection line of the scanning line and two side edges of the central black area, which is just in a certain critical state, and if the scanning line continuously deviates to the outside, the length of the intersection line is 0. Meanwhile, the vertical distance between the center of the candidate object and the closed line is required to be 1.5 times of the unit width estimated by the column pixel arrangement, and a certain error tolerance range, such as 1 time to 2 times, can be given in practical cases. If the maximum range of the error tolerance is reached, the upward or downward horizontal scanning still does not detect the closed line, namely, the central black area of the candidate object is considered not to be closed, and the central black area of the candidate object is rejected.
And S1710, clustering the determined position detection graph candidate object set in groups of three, wherein each combination obtained by clustering is used as positioning of a primary two-dimensional code.
When the number of the candidate objects is less than 3, determining that no two-dimensional code exists in the current binary image; and when the number of the candidate objects is more than or equal to 3, performing conditional clustering. First, the estimated widths of all the candidates are sorted, and the estimated widths are taken into the horizontal direction d h And a vertical direction d v Is measured. And then, calculating the difference value of the estimated widths of the sorted adjacent candidate objects. And selecting two candidate objects with the minimum difference value as reference points of primary clustering, and selecting a third candidate object with the width closest to any reference point to form a candidate combination.
And connecting the centers of the candidate objects in the candidate combination. Selecting two minimum connecting lines, temporarily setting the two minimum connecting lines as the connecting lines of the upper left position detection graph and the upper right position detection graph of the two-dimensional code, and the upper left position detection graph and the lower left position detection graph of the two-dimensional code, and further checking whether the two connecting lines meet the conditions: 1) The two are equal in length, 2) if the candidate object has polarity, the connection line should not pass through the side with the defect. For condition 1), in practical cases, the difference in the lengths of the two connecting lines is allowed to be within a certain error tolerance. Let two connecting lines be l 1 And l 2 The condition to be satisfied is | l 1 -l 2 |<0.2*min(l 1 ,l 2 ). For the condition 2, the defective side corresponds to an outer region of the two-dimensional code, the region through which the connecting line normally passes is an inner region of the two-dimensional code, and if the defective region passes, it means that the candidate object may belong to a different two-dimensional code.
If the two connecting lines meet the two conditions, the combination formed by the three candidate objects is judged to be the primary positioning of the two-dimensional code, and the three candidate objects are simultaneously removed from the candidate object set. The above steps are then repeated for the remaining candidates in the set.
If the two connection lines cannot satisfy the above two conditions at the same timeThen, the candidate object whose width is close to any reference point is reselected to form a ternary candidate combination, and the judgment of the connecting line in the combination is executed in the same way. And if the connection line still does not meet the condition, continuously selecting a third close candidate object to form a ternary candidate combination for judgment, and repeating the process until the difference between the width of the selected third candidate object and the width of the reference point exceeds a preset threshold value. The width of the reference point is respectively w 1 And w 2 The width of the selected third candidate is w 3 . The threshold is 0.2 times the minimum width of the reference point, i.e. when min (| w) 3 -w 1 |,|w 3 -w 2 |)>0.2*min(w 1 ,w 2 ) The combining process is stopped. And then, two candidate objects with the next-to-two adjacent difference values are selected as reference points again, and the steps are repeatedly executed until the remaining candidate objects in the candidate set can not form the qualified ternary combination.
FIG. 21 shows a schematic diagram of two ternary candidate combinations. In FIG. 21 (a), since the two smallest connecting lines pass through the defect side of the candidate object of the position detection graph, the combination does not satisfy the clustering condition; the ternary candidate combination shown in fig. 21 (b) satisfies the clustering condition. Therefore, a two-dimensional code can be located by using the ternary candidate combination corresponding to fig. 21 (b).
Exemplary Medium
Having described the method of the exemplary embodiments of the present invention, the media of the exemplary embodiments of the present invention will be described next.
In some possible embodiments, the various aspects of the present invention may also be implemented as a medium having a program code stored thereon, which when executed by a processor of a device, is used to implement the steps in the two-dimensional code positioning method according to various exemplary embodiments of the present invention described in the above section "exemplary method" of this specification.
It should be noted that: the above-mentioned medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example but not limited to: an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of the readable storage medium include: an electrical connection having one or more wires, a portable disk, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
A readable signal medium may include a propagated data signal with readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take a variety of forms, including, but not limited to: an electromagnetic signal, an optical signal, or any suitable combination of the foregoing. A readable signal medium may also be any readable medium that is not a readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
Program code for carrying out operations for aspects of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user computing device, partly on a remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device over any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computing device (e.g., over the internet using an internet service provider).
Exemplary devices
Having described the medium of the exemplary embodiment of the present invention, next, a two-dimensional code positioning device of the exemplary embodiment of the present invention will be described with reference to fig. 22 and 23.
Fig. 22 schematically illustrates a structural block diagram of a two-dimensional code positioning apparatus in some exemplary embodiments of the present invention. As shown in fig. 22, the two-dimensional code positioning apparatus 2200 includes: a scan region determination module 2210, a standard region determination module 2220, an auxiliary region determination module 2230, and a probe pattern determination module 2240.
The scan region determination module 2210 is configured to determine a plurality of pixel scan regions located on the binarized image according to the pixel distribution information in the binarized image; the standard area determination module 2220 is configured to determine the pixel scanning area as a standard pixel scanning area when the number of pixels within the pixel scanning area is the standard pixel number; the auxiliary area determining module 2230 is configured to determine the pixel scanning area as an auxiliary pixel scanning area with a defective area when the number of pixels within the pixel scanning area is the auxiliary pixel number; the detection pattern determination module 2240 is configured to determine a position detection pattern for positioning the two-dimensional code from the standard pixel scanning area and the auxiliary pixel scanning area.
In some exemplary embodiments of the present invention, based on the above technical solution, the pixel scanning area is a horizontal scanning area or a vertical scanning area; the scan region determination module 2210 comprises: the scanning line determining unit 2211 is configured to determine a horizontal scanning line in the row pixel arrangement direction and a vertical scanning line in the column pixel arrangement direction on the binarized image; the transverse scanning area determining unit 2212 is configured to determine one or more transverse scanning areas on the transverse scanning lines from the pixel distribution information on the transverse scanning lines; the longitudinal scanning area determining unit 2213 is configured to determine one or more longitudinal scanning areas on the longitudinal scanning lines from the pixel distribution information on the longitudinal scanning lines.
In some exemplary embodiments of the present invention, based on the above technical solution, the pixel scanning area includes a plurality of pixel arrangement blocks which are continuously distributed; wherein, two adjacent pixel arrangement blocks have different pixel values.
In some exemplary embodiments of the present invention, based on the above technical solutions, the standard area determination module 2220 includes: the pixel number acquisition unit 2221 is configured to acquire the number of pixels of each pixel arrangement section within the pixel scanning area; the standard width determination unit 2222 is configured to determine a standard block unit width and a standard width error limit of the pixel scanning area according to the number of pixels of each pixel arrangement block; the standard range determination unit 2223 is configured to determine a standard pixel number range corresponding to each pixel arrangement block from the standard block unit width and the standard width error limit; the standard area determination unit 2224 is configured to, when the number of pixels of each pixel arrangement section is within the standard pixel number range, determine the number of pixels within the pixel scanning area as the standard pixel number, and determine the pixel scanning area as the standard pixel scanning area.
In some exemplary embodiments of the present invention, based on the above technical solution, the standard width error is limited to 0.5 to 0.75 times the standard block unit width.
In some exemplary embodiments of the present invention, based on the above technical solutions, the auxiliary area determining module 2230 includes: the defective area determination unit 2231 is configured to treat the pixel arrangement area as a defective area when the number of pixels of one or more pixel arrangement areas located at one side edge of the pixel scanning area is out of the standard pixel number range; the auxiliary width determination unit 2232 is configured to take other pixel arrangement blocks in the pixel scanning area except the defective block as standard blocks, and determine an auxiliary block unit width and an auxiliary width error limit of the pixel scanning area according to the number of pixels of the standard blocks; the auxiliary range determination unit 2233 is configured to determine an auxiliary pixel number range corresponding to each standard patch from the auxiliary tile unit width and the auxiliary width error limit; the auxiliary area determining unit 2234 is configured to determine the number of pixels within the pixel scanning area as the number of auxiliary pixels when the number of pixels of each of the standard block and the defective block is within the range of the number of auxiliary pixels, and determine the pixel scanning area as the auxiliary pixel scanning area with the defective area.
In some exemplary embodiments of the present invention, based on the above technical solution, the auxiliary width error is limited to 0.5 to 0.75 times the unit width of the auxiliary block.
In some exemplary embodiments of the present invention, based on the above technical solutions, the detection pattern determining module 2240 includes: the detection region determining unit 2241 is configured to determine a candidate position detection region from the standard pixel scanning region and the auxiliary pixel scanning region, and determine a region center of the candidate position detection region; a reference line determination unit configured to select a plurality of area size reference lines passing through the area center within the candidate position detection area; the standard size determination unit 2242 is configured to acquire the lengths of the respective area size reference lines, and determine a standard area size difference value from the lengths; the detection pattern determination unit 2243 is configured to determine the candidate position detection region as the position detection pattern for positioning the two-dimensional code when the length of each region size reference line satisfies the standard region size difference value.
In some exemplary embodiments of the present invention, based on the above technical solutions, the detection pattern determining unit 2243 includes: the central block determining subunit is configured to determine a central pixel block located at the center of the candidate position detection area according to the position of the area center and the pixel value; the detection pattern determination subunit is configured to determine the candidate position detection region as a position detection pattern for positioning the two-dimensional code when the center pixel block is a closed block having a plurality of boundary lines.
In some exemplary embodiments of the present invention, based on the above technical solutions, the detection pattern determination subunit includes: a boundary line determining subunit configured to determine a plurality of boundary lines of the central pixel block and acquire a vertical distance between the center of the region and each of the boundary lines; and a closed block determining subunit configured to determine the candidate position detection area as a position detection pattern for positioning the two-dimensional code when the respective boundary lines form a closed block and the vertical distance is within the standard distance range.
As shown in fig. 23, in some exemplary embodiments of the present invention, based on the above technical solutions, the two-dimensional code positioning apparatus 2200 further includes: a graph set composition module 2310, a ternary graph combination module 2320 and a two-dimensional code position determination module 2330.
The pattern set composition module 2310 is configured to compose position detection patterns in the binarized image into a position detection pattern set; the ternary pattern combination module 2320 is configured to cluster the position detection pattern sets according to the size information and the position information of each position detection pattern to obtain a ternary pattern combination composed of three position detection patterns; the two-dimensional code position determination module 2330 is configured to determine the position of a two-dimensional code in a binarized image from a ternary graphic combination.
In some exemplary embodiments of the present invention, based on the above technical solution, the ternary pattern combining module 2320 includes: the binary pattern combination unit 2321 is configured to select two position detection patterns with similar sizes from the position detection pattern set to form a binary pattern combination according to the size information of each position detection pattern; the candidate pattern selecting unit 2322 is configured to select a position detection pattern having a size similar to the combined size of the binary patterns from the position detection pattern set as a third candidate pattern; the position relation determining unit 2323 is configured to determine whether the binary pattern combination and the third candidate pattern meet a standard position relation according to the position information of each position detection pattern; the first graph combination unit 2324 is configured to combine the binary graph combination with the third candidate graph into a ternary graph combination when the binary graph combination and the third candidate graph meet the standard positional relationship; the second graph combination unit 2325 is configured to select a new third candidate graph from the position detection graph set when the binary graph combination and the third candidate graph do not meet the standard position relationship, and continuously determine whether the newly selected third candidate graph can form a ternary graph combination with the binary graph.
In some exemplary embodiments of the present invention, based on the above technical solution, the binary pattern combining unit 2321 includes: the graphic sequence subunit is configured to perform size sequencing on each position detection graphic in the position detection graphic set according to the size information of each position detection graphic to obtain a graphic sequence; a candidate pattern combination subunit configured to combine each two adjacent position detection patterns in the pattern sequence into one candidate pattern combination, and determine a size difference value of the two position detection patterns in the candidate pattern combination; the combined sequence subunit is configured to perform difference sorting on each candidate graph combination according to the size difference to obtain a combined sequence; and the binary graph combination subunit is configured to sequentially select candidate graph combinations from the combination sequence as the binary graph combinations.
In some exemplary embodiments of the present invention, based on the above technical solutions, the position relation determining unit 2323 includes: a central connecting line determining subunit configured to determine a central connecting line between two position detection patterns and a third candidate pattern in the binary pattern combination according to the position information of each position detection pattern; a connecting line length acquiring unit configured to acquire a connecting line length of each center connecting line and determine two short side connecting lines and one long side connecting line according to the connecting line length; a first position relation judging subunit configured to judge that the binary pattern combination and the third candidate pattern meet the standard position relation when the length difference of the two short-side connecting lines is smaller than the length error limit and neither of the two short-side connecting lines passes through the defect region of the position detection pattern; and the second position relation judging subunit is configured to judge that the binary pattern combination and the third candidate pattern do not accord with the standard position relation when the length difference value of the two short edge connecting lines is greater than or equal to the length error limit or the short edge connecting line passes through the defect area of the position detection pattern.
In some exemplary embodiments of the present invention, based on the above technical solution, the position relation determining unit 2323 further includes: a length error limit determination subunit configured to determine a length error limit according to the length of the two short side connecting lines.
The details of the exemplary apparatus in the above exemplary embodiments have been described in the exemplary method section, and thus are not described herein again.
Exemplary computing device
Having described the method, medium, and apparatus of exemplary embodiments of the present invention, a computing device in accordance with another exemplary embodiment of the present invention is described.
As will be appreciated by one skilled in the art, aspects of the present invention may be embodied as a system, method or program product. Thus, various aspects of the invention may be embodied in the form of: an entirely hardware embodiment, an entirely software embodiment (including firmware, microcode, etc.) or an embodiment combining hardware and software aspects that may all generally be referred to herein as a "circuit," module "or" system.
In some possible implementations, a computing device according to an embodiment of the invention may include at least one processor, and at least one memory. Wherein the memory stores program code that, when executed by the processor, causes the processor to perform the steps in the two-dimensional code positioning method according to various exemplary embodiments of the present invention described in the "exemplary methods" section above in this specification.
It should be noted that although in the above detailed description several units or sub-units of the two-dimensional code positioning device are mentioned, such division is merely exemplary and not mandatory. Indeed, the features and functions of two or more modules or units described above may be embodied in one module or unit according to an embodiment of the invention. Conversely, the features and functions of one module or unit described above may be further divided into embodiments by a plurality of modules or units.
Moreover, while the operations of the method of the invention are depicted in the drawings in a particular order, this does not require or imply that the operations must be performed in this particular order, or that all of the illustrated operations must be performed, to achieve desirable results. Additionally or alternatively, certain steps may be omitted, multiple steps combined into one step execution, and/or one step broken down into multiple step executions.
While the spirit and principles of the invention have been described with reference to several particular embodiments, it is to be understood that the invention is not limited to the particular embodiments disclosed, nor is the division of the aspects, which is for convenience only as the features in these aspects may not be combined to benefit from the present disclosure. The invention is intended to cover various modifications and equivalent arrangements included within the spirit and scope of the appended claims.

Claims (32)

1. A two-dimensional code positioning method comprises the following steps:
determining a plurality of pixel scanning areas positioned on the binary image according to pixel distribution information in the binary image, wherein the pixel scanning areas comprise a plurality of pixel arrangement blocks which are distributed continuously;
when the number of pixels of each pixel arrangement block in the pixel scanning area is the standard number of pixels, determining the pixel scanning area as a standard pixel scanning area;
when the number of pixels of each pixel arrangement block in the pixel scanning area is the number of auxiliary pixels, determining the pixel scanning area as an auxiliary pixel scanning area with a defect area;
and determining a position detection graph for positioning the two-dimensional code according to the size reference lines of the standard pixel scanning area and the auxiliary pixel scanning area.
2. The two-dimensional code positioning method according to claim 1, wherein the pixel scanning area is a transverse scanning area or a longitudinal scanning area; the method for determining a plurality of pixel scanning areas on a binarized image according to pixel distribution information in the binarized image comprises the following steps:
determining a transverse scanning line along the arrangement direction of the row pixels and a longitudinal scanning line along the arrangement direction of the column pixels on the binary image;
determining one or more transverse scanning areas on the transverse scanning lines according to the pixel distribution information on the transverse scanning lines;
and determining one or more longitudinal scanning areas on the longitudinal scanning lines according to the pixel distribution information on the longitudinal scanning lines.
3. The two-dimensional code positioning method according to claim 1, wherein two adjacent pixel arrangement blocks have different pixel values.
4. The two-dimensional code positioning method according to claim 3, wherein when the number of pixels of each pixel arrangement block in the pixel scanning area is a standard number of pixels, determining the pixel scanning area as a standard pixel scanning area comprises:
acquiring the pixel number of each pixel arrangement block in the pixel scanning area;
determining the standard block unit width and the standard width error limit of the pixel scanning area according to the pixel number of each pixel arrangement block;
determining a standard pixel number range corresponding to each pixel arrangement block according to the standard block unit width and the standard width error limit;
when the number of the pixels of each pixel arrangement block is within the range of the standard number of the pixels, the number of the pixels in the pixel scanning area is determined to be the standard number of the pixels, and the pixel scanning area is determined to be the standard pixel scanning area.
5. The two-dimensional code positioning method according to claim 4, wherein the standard width error limit is 0.5-0.75 times of the unit width of the standard block.
6. The two-dimensional code positioning method according to claim 4, wherein when the number of pixels of each pixel arrangement block in the pixel scanning area is the number of auxiliary pixels, determining the pixel scanning area as an auxiliary pixel scanning area with a defect area comprises:
when the pixel number of one or more pixel arrangement blocks positioned at one side edge of the pixel scanning area is out of the standard pixel number range, taking the pixel arrangement blocks as defective blocks;
taking other pixel arrangement blocks except the defective block in the pixel scanning area as standard blocks, and determining the auxiliary block unit width and the auxiliary width error limit of the pixel scanning area according to the number of pixels of the standard blocks;
determining an auxiliary pixel number range corresponding to each standard block according to the auxiliary block unit width and the auxiliary width error limit;
when the pixel number of each of the standard block and the defective block is within the auxiliary pixel number range, determining the pixel number in the pixel scanning area as the auxiliary pixel number, and determining the pixel scanning area as the auxiliary pixel scanning area with the defective area.
7. The two-dimensional code positioning method according to claim 6, wherein the auxiliary width error limit is 0.5 to 0.75 times the unit width of the auxiliary block.
8. The two-dimensional code positioning method according to claim 1, wherein the determining of the position detection pattern for positioning the two-dimensional code according to the size reference lines of the standard pixel scanning area and the auxiliary pixel scanning area comprises:
determining a candidate position detection area according to the standard pixel scanning area and the auxiliary pixel scanning area, and determining the area center of the candidate position detection area;
selecting a plurality of area size reference lines which pass through the center of the area in the candidate position detection area;
acquiring the length of each region size reference line, and determining a standard region size difference value according to the length;
and when the length of each region size reference line meets the standard region size difference, determining the candidate position detection region as a position detection graph for positioning the two-dimensional code.
9. The two-dimensional code positioning method according to claim 8, wherein the determining the candidate position detection region as a position detection pattern for positioning a two-dimensional code comprises:
determining a central pixel block positioned in the center of the candidate position detection area according to the position and the pixel value of the area center;
and when the central pixel block is a closed block with a plurality of boundary lines, determining the candidate position detection area as a position detection graph for positioning the two-dimensional code.
10. The two-dimensional code positioning method according to claim 9, wherein when the central pixel block is a closed block having a plurality of boundary lines, determining the candidate position detection region as a position detection pattern for positioning a two-dimensional code includes:
determining a plurality of boundary lines of the central pixel block, and acquiring the vertical distance between the center of the area and each boundary line;
and when the boundary lines form a closed block and the vertical distance is within a standard distance range, determining the candidate position detection area as a position detection graph for positioning the two-dimensional code.
11. The two-dimensional code positioning method according to claim 1, after determining the position detection pattern for positioning the two-dimensional code according to the standard pixel scanning area and the auxiliary pixel scanning area, the method further comprising:
forming a position detection graph set by the position detection graphs in the binary image;
clustering the position detection graph set according to the size information and the position information of each position detection graph to obtain a ternary graph combination consisting of three position detection graphs;
and determining the position of the two-dimensional code in the binary image according to the ternary graph combination.
12. The two-dimensional code positioning method according to claim 11, wherein the clustering the position detection pattern sets according to the size information and the position information of each position detection pattern to obtain a ternary pattern combination consisting of three position detection patterns comprises:
selecting two position detection graphs with similar sizes from the position detection graph set to form a binary graph combination according to the size information of each position detection graph;
selecting a position detection graph with the size similar to the combined size of the binary graphs from the position detection graph set as a third candidate graph;
judging whether the binary graph combination and the third candidate graph meet the standard position relation or not according to the position information of each position detection graph;
when the binary graph combination and the third candidate graph accord with the standard position relation, the binary graph combination and the third candidate graph form a ternary graph combination;
and when the binary graph combination and the third candidate graph do not accord with the standard position relation, selecting a new third candidate graph from the position detection graph set, and continuously judging whether the newly selected third candidate graph can form the ternary graph combination with the binary graph.
13. The two-dimensional code positioning method according to claim 12, wherein selecting two position detection graphs with similar sizes from the position detection graph set to form a binary graph combination according to the size information of each position detection graph comprises:
according to the size information of each position detection graph, performing size sequencing on each position detection graph in the position detection graph set to obtain a graph sequence;
forming a candidate graph combination by every two adjacent position detection graphs in the graph sequence, and determining the size difference of the two position detection graphs in the candidate graph combination;
performing difference sorting on each candidate graph combination according to the size difference to obtain a combination sequence;
and selecting candidate graph combinations from the combination sequence in sequence as the binary graph combinations.
14. The two-dimensional code positioning method according to claim 12, wherein the determining whether the binary pattern combination and the third candidate pattern meet a standard position relationship according to the position information of each position detection pattern includes:
determining a central connection line between two position detection graphs in the binary graph combination and the third candidate graph according to the position information of each position detection graph;
acquiring the connecting line length of each central connecting line, and determining two short-side connecting lines and a long-side connecting line according to the connecting line length;
when the length difference value of the two short edge connecting lines is smaller than the length error limit and the two short edge connecting lines do not pass through the defect area of the position detection graph, judging that the binary graph combination and the third candidate graph accord with the standard position relation;
and when the length difference value of the two short edge connecting lines is greater than or equal to the length error limit or the short edge connecting line passes through the defect area of the position detection graph, judging that the binary graph combination and the third candidate graph do not accord with the standard position relation.
15. The two-dimensional code positioning method according to claim 14, after determining two short side connecting lines and one long side connecting line according to the connecting line length, the method further comprising:
and determining a length error limit according to the length of the connecting line of the two short sides.
16. A medium having stored thereon a program which, when executed by a processor, carries out the method of any one of claims 1 to 15.
17. A two-dimensional code positioner includes:
a scanning area determining module configured to determine a plurality of pixel scanning areas located on the binarized image according to pixel distribution information in the binarized image, wherein the pixel scanning areas comprise a plurality of pixel arrangement blocks which are continuously distributed;
a standard area determination module configured to determine the pixel scanning area as a standard pixel scanning area when the number of pixels of each of the pixel arrangement blocks in the pixel scanning area is a standard pixel number;
an auxiliary area determination module configured to determine the pixel scanning area as an auxiliary pixel scanning area with a defective area when the number of pixels of each of the pixel arrangement blocks within the pixel scanning area is the auxiliary pixel number;
and the detection pattern determining module is configured to determine a position detection pattern for positioning the two-dimensional code according to the size reference lines of the standard pixel scanning area and the auxiliary pixel scanning area.
18. The two-dimensional code positioning device according to claim 17, wherein the pixel scanning area is a transverse scanning area or a longitudinal scanning area; the scan region determination module includes:
a scan line determination unit configured to determine a horizontal scan line in a row pixel arrangement direction and a vertical scan line in a column pixel arrangement direction on the binarized image;
a transverse scanning area determination unit configured to determine one or more transverse scanning areas on the transverse scanning lines according to pixel distribution information on the transverse scanning lines;
a longitudinal scanning area determination unit configured to determine one or more longitudinal scanning areas on the longitudinal scanning lines according to pixel distribution information on the longitudinal scanning lines.
19. The two-dimensional code positioning device according to claim 17, wherein two adjacent pixel arrangement blocks have different pixel values.
20. The two-dimensional code positioning device of claim 19, the standard area determination module, comprising:
a pixel number acquisition unit configured to acquire the number of pixels of each of the pixel arrangement blocks within the pixel scanning area;
a standard width determination unit configured to determine a standard block unit width and a standard width error limit of the pixel scanning area according to the number of pixels of each of the pixel arrangement blocks;
a standard range determining unit configured to determine a standard pixel number range corresponding to each of the pixel arrangement blocks according to the standard block unit width and the standard width error limit;
a standard area determination unit configured to determine the number of pixels in the pixel scanning area as a standard number of pixels and determine the pixel scanning area as a standard pixel scanning area when the number of pixels of each of the pixel arrangement blocks is within the standard number of pixels.
21. The two-dimensional code positioning device according to claim 20, wherein the standard width error limit is 0.5-0.75 times of the standard block unit width.
22. The two-dimensional code positioning device of claim 20, the auxiliary area determination module, comprising:
a defective block determination unit configured to, when the number of pixels of one or more pixel arrangement blocks located at one side edge of the pixel scanning area is out of the standard pixel number range, take the pixel arrangement block as a defective block;
an auxiliary width determination unit configured to take other pixel arrangement blocks in the pixel scanning area except the defective block as standard blocks and determine an auxiliary block unit width and an auxiliary width error limit of the pixel scanning area according to the number of pixels of the standard blocks;
an auxiliary range determining unit configured to determine an auxiliary pixel number range corresponding to each of the standard patches according to the auxiliary patch unit width and the auxiliary width error limit;
an auxiliary area determining unit configured to determine the number of pixels within the pixel scanning area as the number of auxiliary pixels and determine the pixel scanning area as an auxiliary pixel scanning area with a defective area when the number of pixels of each of the standard block and the defective block is within the range of the number of auxiliary pixels.
23. The two-dimensional code positioning device of claim 22, wherein the auxiliary width error limit is 0.5-0.75 times the unit width of the auxiliary block.
24. The two-dimensional code positioning device according to claim 17, the detection pattern determination module comprising:
a detection region determination unit configured to determine a candidate position detection region from the standard pixel scanning region and the auxiliary pixel scanning region, and determine a region center of the candidate position detection region;
a reference line determination unit configured to select a plurality of area size reference lines passing through the area center within the candidate position detection area;
a standard size determination unit configured to acquire lengths of the respective area size reference lines and determine a standard area size difference value according to the lengths;
a detection pattern determination unit configured to determine the candidate position detection region as a position detection pattern for positioning a two-dimensional code when the length of each of the region size reference lines satisfies the standard region size difference.
25. The two-dimensional code positioning device according to claim 24, the detection pattern determination unit, comprising:
a central block determination subunit configured to determine a central pixel block located at the center of the candidate position detection area according to the position and the pixel value of the area center;
a detection pattern determination subunit configured to determine the candidate position detection region as a position detection pattern for positioning the two-dimensional code when the center pixel patch is a closed patch having a plurality of boundary lines.
26. The two-dimensional code positioning device of claim 25, the detection pattern determining subunit, comprising:
a boundary line determining subunit configured to determine a plurality of boundary lines of the central pixel block and acquire a vertical distance between the region center and each of the boundary lines;
a closed block determination subunit configured to determine the candidate position detection region as a position detection pattern for positioning the two-dimensional code when each of the boundary lines forms a closed block and the vertical distance is within a standard distance range.
27. The two-dimensional code positioning device of claim 17, the device further comprising:
a graph set composition module configured to compose position detection graphs in the binarized image into a position detection graph set;
the ternary graph combination module is configured to cluster the position detection graph set according to the size information and the position information of each position detection graph to obtain a ternary graph combination consisting of three position detection graphs;
and the two-dimensional code position determining module is configured to determine the position of the two-dimensional code in the binary image according to the ternary graph combination.
28. The two-dimensional code positioning device of claim 27, the ternary pattern combination module, comprising:
the binary pattern combination unit is configured to select two position detection patterns with similar sizes from the position detection pattern set to form a binary pattern combination according to the size information of each position detection pattern;
a candidate pattern selecting unit configured to select a position detection pattern having a size similar to the binary pattern combination size from the position detection pattern set as a third candidate pattern;
a position relation judging unit configured to judge whether the binary pattern combination and the third candidate pattern meet a standard position relation according to position information of each of the position detection patterns;
a first graph combination unit configured to combine the binary graph combination and the third candidate graph into a ternary graph combination when the binary graph combination and the third candidate graph meet the standard positional relationship;
and the second graph combination unit is configured to select a new third candidate graph from the position detection graph set when the binary graph combination and the third candidate graph do not accord with the standard position relation, and continuously judge whether the newly selected third candidate graph can form a ternary graph combination with the binary graph.
29. The two-dimensional code positioning device of claim 28, the binary pattern combining unit, comprising:
the figure sequence subunit is configured to perform size sequencing on each position detection figure in the position detection figure set according to the size information of each position detection figure to obtain a figure sequence;
a candidate pattern combination subunit configured to combine each two adjacent position detection patterns in the pattern sequence into one candidate pattern combination, and determine a size difference value of the two position detection patterns in the candidate pattern combination;
the combined sequence subunit is configured to perform difference sorting on each candidate graph combination according to the size difference to obtain a combined sequence;
and the binary graph combination subunit is configured to sequentially select candidate graph combinations from the combination sequence as the binary graph combinations.
30. The two-dimensional code positioning device according to claim 28, the positional relationship determination unit comprising:
a central connecting line determining subunit configured to determine, according to the position information of each of the position detection patterns, a central connecting line between two position detection patterns in the binary pattern combination and the third candidate pattern;
a connecting line length acquiring unit configured to acquire a connecting line length of each of the center connecting lines and determine two short side connecting lines and one long side connecting line according to the connecting line length;
a first position relation judging subunit, configured to judge that the binary pattern combination and the third candidate pattern meet a standard position relation when a length difference between the two short edge connecting lines is smaller than a length error limit and neither of the two short edge connecting lines passes through a defect region of the position detection pattern;
and the second position relation judging subunit is configured to judge that the binary pattern combination and the third candidate pattern do not accord with a standard position relation when the length difference value of the two short edge connecting lines is greater than or equal to a length error limit or the short edge connecting line passes through a defect area of the position detection pattern.
31. The two-dimensional code positioning device according to claim 30, wherein the position relation determining unit further comprises:
a length error limit determination subunit configured to determine a length error limit according to the length of the two short side connecting lines.
32. A computing device, comprising: a processor and a memory, the memory storing executable instructions, the processor to invoke the memory stored executable instructions to perform the method of any of claims 1 to 15.
CN201910775253.9A 2019-08-21 2019-08-21 Two-dimensional code positioning method, medium, device and computing equipment Active CN110490021B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910775253.9A CN110490021B (en) 2019-08-21 2019-08-21 Two-dimensional code positioning method, medium, device and computing equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910775253.9A CN110490021B (en) 2019-08-21 2019-08-21 Two-dimensional code positioning method, medium, device and computing equipment

Publications (2)

Publication Number Publication Date
CN110490021A CN110490021A (en) 2019-11-22
CN110490021B true CN110490021B (en) 2023-02-24

Family

ID=68552701

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910775253.9A Active CN110490021B (en) 2019-08-21 2019-08-21 Two-dimensional code positioning method, medium, device and computing equipment

Country Status (1)

Country Link
CN (1) CN110490021B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113378595B (en) * 2020-03-10 2023-09-22 顺丰科技有限公司 Two-dimensional code positioning method, device, equipment and storage medium
CN111523341B (en) * 2020-04-03 2023-07-11 青岛进化者小胖机器人科技有限公司 Binarization method and device for two-dimensional code image

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5515447A (en) * 1994-06-07 1996-05-07 United Parcel Service Of America, Inc. Method and apparatus for locating an acquisition target in two-dimensional images by detecting symmetry in two different directions
CN104794421B (en) * 2015-04-29 2017-09-26 华中科技大学 A kind of positioning of QR codes and recognition methods
CN112861560B (en) * 2017-09-27 2023-12-22 创新先进技术有限公司 Two-dimensional code positioning method and device
CN109522769A (en) * 2018-11-21 2019-03-26 上海双视智能科技有限公司 The position sensing pattern recognition method of QR code, graphic code recognition methods
CN109902527B (en) * 2019-02-26 2022-06-07 凌云光技术股份有限公司 Automatic QR code recognizing and reading method and device
CN109934036B (en) * 2019-03-22 2022-01-04 福州符号信息科技有限公司 Method and system for recognizing and reading QR (quick response) code through single-position detection graph

Also Published As

Publication number Publication date
CN110490021A (en) 2019-11-22

Similar Documents

Publication Publication Date Title
Ok et al. Circular oil tank detection from panchromatic satellite images: A new automated approach
CN109343920B (en) Image processing method and device, equipment and storage medium thereof
WO2014160433A2 (en) Systems and methods for classifying objects in digital images captured using mobile devices
Lin et al. Reconstruction of shredded document based on image feature matching
US20140023278A1 (en) Feature Extraction And Use With A Probability Density Function (PDF) Divergence Metric
CN108021837B (en) Bar code detection method, bar code detection device and electronic equipment
US20140169678A1 (en) Method and system for text-image orientation
CN110490021B (en) Two-dimensional code positioning method, medium, device and computing equipment
US11816946B2 (en) Image based novelty detection of material samples
US20150213330A1 (en) Methods and systems for efficient automated symbol recognition
Rebelo et al. Staff line detection and removal in the grayscale domain
CN112949476A (en) Text relation detection method and device based on graph convolution neural network and storage medium
He et al. Aggregating local context for accurate scene text detection
US7922087B2 (en) Image processing apparatus, image processing method, and computer program stored in storage medium
CN110533017B (en) Authenticity identification method, device, terminal and storage medium
CA3035387C (en) Digitization of industrial inspection sheets by inferring visual relations
CN111626145A (en) Simple and effective incomplete form identification and page-crossing splicing method
US9922263B2 (en) System and method for detection and segmentation of touching characters for OCR
CN113643274A (en) Method and device for screening two-dimensional code candidate area
CN110084117B (en) Document table line detection method and system based on binary image segmentation projection
Vidhyalakshmi et al. Text detection in natural images with hybrid stroke feature transform and high performance deep Convnet computing
Oh et al. Low-complexity and robust comic fingerprint method for comic identification
US20180225508A1 (en) Detecting document objects
US20150169973A1 (en) Incomplete patterns
CN113591657B (en) OCR layout recognition method and device, electronic equipment and 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
GR01 Patent grant
GR01 Patent grant