Two-dimensional code positioning method, two-dimensional code positioning device and computer storage medium

By extracting and screening QR code candidate points in complex backgrounds, generating positioning lines and performing grid score statistics, and combining caliper precision positioning and outward expansion line judgment, the positioning accuracy problem of Aztec codes in high-noise environments was solved, and high-precision QR code positioning was achieved.

CN120633688AActive Publication Date: 2025-09-12ZHEJIANG HUARAY TECH CO LTD

Patent Information

Application Number
CN202510451097.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-10
Publication Date
2025-09-12
Estimated Expiration
2045-04-10

AI Technical Summary

Technical Problem

In complex backgrounds, the positioning accuracy of Aztec code is low, especially in high-noise environments, where it is difficult to accurately locate and there are problems with type judgment errors.

Method used

By acquiring the QR code positioning image, extracting candidate points, screening out the second candidate points that meet the conditions, generating the positioning line, counting the grid score, determining the positioning score, obtaining the target candidate points above the threshold, determining the position of the QR code based on the target candidate points, and judging the QR code type through caliper precise positioning and outward expansion lines.

Benefits of technology

It achieves accurate QR code positioning in complex industrial environments, improves the applicability and positioning accuracy of Aztec codes, and solves the positioning problem in high-noise environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120633688A_ABST
    Figure CN120633688A_ABST
Patent Text Reader

Abstract

The invention provides a two-dimensional code positioning method, a two-dimensional code positioning device and a computer storage medium. The two-dimensional code positioning method comprises the following steps: acquiring a two-dimensional code positioning image; extracting a plurality of first candidate points from the binary image of the two-dimensional code positioning image; screening the plurality of first candidate points according to a preset condition, and determining a plurality of second candidate points; generating a first positioning straight line based on the edge point and the rotation angle of each second candidate point; acquiring an interval sampling graph based on the first positioning straight line; counting grid scores of the interval sampling graph, and determining a positioning score of each second candidate point; obtaining target candidate points of which the positioning scores are higher than a preset threshold value; and determining the position of the two-dimensional code based on the target candidate point. Through the two-dimensional code positioning method, the calculation complexity is low, the problem of two-dimensional code positioning in a complex industrial environment is solved, and accurate two-dimensional code contour positioning is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] With the development of information technology and Industry 4.0 in my country, QR codes have been widely used in information transmission, marketing promotion, payment functions, etc., and the application scenarios are still expanding. For example, in industry, products can be identified and their production process, assembly management, life cycle, etc. can be tracked. Among them, Aztec code (Aztec Code, matrix QR code) uses less space than other codes, can store a large amount of information, and has strong error correction capabilities. Therefore, it is widely used in air tickets and other travel documents as well as car registration documents. It can also be used for patient identification, drug identification, samples and other items related to specific patients in hospitals. Due to the diversity and complexity of application scenarios, the contour positioning of Aztec code has low positioning accuracy under complex backgrounds. Summary of the Invention

[0003] To solve the above technical problems, the present application proposes a two-dimensional code positioning method, a two-dimensional code positioning device and a computer storage medium.

[0004] To solve the above technical problems, the present application proposes a QR code positioning method, which includes:

[0005] Get the QR code positioning image;

[0006] Extracting a plurality of first candidate points from the binary image of the two-dimensional code positioning image;

[0007] Screening the plurality of first candidate points according to preset conditions to determine a plurality of second candidate points;

[0008] Generate a first positioning line based on the edge point and the rotation angle of each second candidate point;

[0009] Acquire an interval sampling diagram based on the first positioning straight line;

[0010] Counting the grid scores of the interval sampling map to determine the positioning score of each second candidate point;

[0011] Obtaining target candidate points whose positioning scores are higher than a preset threshold;

[0012] The position of the two-dimensional code is determined based on the target candidate point.

[0013] Wherein, determining the position of the QR code based on the target candidate point includes:

[0014] Generate a candidate frame based on the target candidate point;

[0015] Selecting a point to be located on a candidate edge of the candidate frame;

[0016] Performing caliper precision positioning on the point to be positioned to determine the precise positioning point;

[0017] Determine a first QR code vertex based on the precisely positioned point fitting straight line;

[0018] According to the first two-dimensional code vertex, the two-dimensional code positioning position is determined.

[0019] Wherein, after performing caliper precise positioning on the point to be positioned and determining the precise positioning point, the QR code positioning method further comprises:

[0020] Fitting a positioning line and an expansion line based on the precise positioning points;

[0021] Obtaining the projection points of the positioning line and the expansion line of the target candidate point;

[0022] Get the histogram of the projection line segment where each projection point is located;

[0023] The type of the QR code is determined based on changes in the histogram.

[0024] The step of extracting a plurality of first candidate points from the binary image of the two-dimensional code positioning image includes:

[0025] Obtaining a binary image of the QR code positioning image;

[0026] Performing a horizontal scan on the binary image to determine a horizontal line segment that meets a preset horizontal black and white module ratio, and obtaining a center point of the horizontal line segment as a third candidate point;

[0027] Performing a longitudinal scan on the binary image based on the third candidate points to obtain a longitudinal line segment corresponding to each third candidate point;

[0028] A third candidate point corresponding to a vertical line segment that meets a preset vertical black-white module ratio is determined as the first candidate point.

[0029] The step of screening the plurality of first candidate points according to preset conditions to determine a plurality of second candidate points includes:

[0030] Obtaining the horizontal black and white module boundary point on the horizontal line segment of each first candidate point, and the vertical black and white module boundary point on the vertical line segment;

[0031] Based on the horizontal black and white module boundary point, obtaining the horizontal rotation angle of the horizontal line segment;

[0032] Based on the vertical black and white module boundary points, obtaining the vertical rotation angle of the vertical line segment;

[0033] Obtaining a rotation angle difference between the horizontal rotation angle and the vertical rotation angle;

[0034] The first candidate points whose absolute value of the rotation angle difference is less than or equal to a preset angle difference threshold are eliminated, and the second candidate point is determined based on the remaining first candidate points.

[0035] The step of obtaining the horizontal rotation angle of the horizontal line segment based on the horizontal black and white module boundary point includes:

[0036] Get the eight neighborhood points of each horizontal black and white module boundary point;

[0037] Based on the rotation angle of the horizontal black and white module boundary point and each of the eight neighborhood points;

[0038] Mapping the rotation angle of each point to a preset angle interval, and obtaining the cumulative angle sum and the cumulative weight sum of each index number in the preset angle interval;

[0039] Get the target index number of the maximum weighted cumulative sum;

[0040] The horizontal rotation angle of the horizontal line segment is determined based on the cumulative sum of the angles and the cumulative sum of the weights of the target index numbers.

[0041] The step of mapping the rotation angle of each point to a preset angle interval and obtaining the cumulative angle sum and the cumulative weight sum of each index number in the preset angle interval includes:

[0042] Mapping the rotation angle of each point to a preset angle interval, and determining a first index number and a second index number of the target angle interval;

[0043] Determining a first weight based on a difference between the rotation angle and the first index number;

[0044] Determining a second weight based on a difference between the rotation angle and the second index number;

[0045] Determine the cumulative weight value of the first index number using the first weight;

[0046] Determine the cumulative weight value of the second index number using the second weight;

[0047] Determine an angle accumulation value of the first index number based on the first weight and the rotation angle;

[0048] Determine an angle accumulation value of the second index number based on the second weight and the rotation angle;

[0049] After traversing the rotation angles of all points, the cumulative angle sum and the cumulative weight sum of each index number in the preset angle interval are determined.

[0050] The step of acquiring an interval sampling diagram based on the first positioning straight line includes:

[0051] Determine a second inward positioning straight line and a third outward positioning straight line based on the first positioning straight line;

[0052] Interval sampling is performed in a plurality of module areas formed by the first positioning straight line, the second positioning straight line, the third positioning straight line and their intersections to obtain the interval sampling map.

[0053] The counting of grid scores of the interval sampling graph to determine the positioning score of each second candidate point includes:

[0054] Converting the interval sampling graph into a block sampling graph;

[0055] Performing color inversion on the block sampling image to obtain a color sampling image;

[0056] Obtain a white module grid in the color sampling map;

[0057] Determining a positioning score of each white module grid based on a grayscale difference between a neighborhood module grid of each white module grid and the white module grid;

[0058] The positioning scores of all white module grids are counted to determine the positioning score of the second candidate point.

[0059] The determining of the positioning score of each white module grid based on the grayscale difference between the neighboring module grid of each white module grid and the white module grid includes:

[0060] When the grayscale difference between the white module grid and the neighborhood module grid is greater than the contrast threshold, the positioning score of the white module grid is increased by 1;

[0061] Traversing all neighboring module grids of the white module grid, and determining the positioning score of the white module grid;

[0062] The contrast threshold is determined by the number of grids and the grayscale value of the white module grid and the number of grids and the grayscale value of the black module grid.

[0063] To solve the above technical problems, the present application also proposes a QR code positioning device, which includes a memory and a processor coupled to the memory; wherein the memory is used to store program data, and the processor is used to execute the program data to implement the QR code positioning method as described above.

[0064] In order to solve the above technical problems, the present application also proposes a computer storage medium, which is used to store program data. When the program data is executed by a computer, it is used to implement the above-mentioned QR code positioning method.

[0065] Compared with the prior art, the beneficial effects of the present application are as follows: a two-dimensional code positioning device obtains a two-dimensional code positioning image; extracts a plurality of first candidate points from the binary image of the two-dimensional code positioning image; screens the plurality of first candidate points according to preset conditions to determine a plurality of second candidate points; generates a first positioning straight line based on the edge points and rotation angles of each second candidate point; obtains an interval sampling diagram based on the first positioning straight line; counts the grid scores of the interval sampling diagram to determine the positioning score of each second candidate point; obtains a target candidate point whose positioning score is higher than a preset threshold; and determines the position of the two-dimensional code based on the target candidate point. Through the above-mentioned two-dimensional code positioning method, the computational complexity is low, the problem of two-dimensional code positioning in complex industrial environments is solved, and accurate two-dimensional code contour positioning is achieved. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0067] in:

[0068] Figure 1 This is a flow chart of an embodiment of a QR code positioning method provided by this application;

[0069] Figure 2 This is a schematic diagram of the overall process of the QR code positioning method provided by this application;

[0070] Figure 3 yes Figure 1 The specific flow diagram of step S12 of the QR code positioning method shown;

[0071] Figure 4 This is a schematic diagram of the angle interval classification provided by this application;

[0072] Figure 5 This is an enlarged view of the "bull's eye" locator provided by this application;

[0073] Figure 6 This is the sampling result diagram provided by this application;

[0074] Figure 7 It is a schematic diagram of 49 equally divided "bull's eye" locator provided by this application;

[0075] Figure 8 is a schematic diagram of the color inversion of the "bull's eye" locator provided by this application;

[0076] Figure 9 yes Figure 1 The specific flow diagram of step S18 of the QR code positioning method shown;

[0077] Figure 10 This is a flow chart of another embodiment of the QR code positioning method provided by this application;

[0078] Figure 11 This is a structural diagram of an embodiment of a QR code positioning device provided by this application;

[0079] Figure 12 It is a structural diagram of an embodiment of a computer storage medium provided by this application. DETAILED DESCRIPTION

[0080] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0081] The terms "first," "second," "third," "fourth," etc. (if any) in the specification and claims of the present application and in the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential sequence. It should be understood that the numbers used in this way are interchangeable where appropriate, so that the embodiments of the present application described herein can, for example, be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having," and any variations thereof, are intended to cover non-exclusive inclusions, for example, a process, method, system, product, or apparatus comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products, or apparatus.

[0082] The QR codes targeted by this application include, but are not limited to, Aztec codes. The following uses Aztec codes as an example, but is not limited to Aztec codes. Aztec codes have a central "bull's eye" pattern, which is used for QR code location. Data is encoded in concentric square rings around this central pattern, typically 9×9 or 13×13 pixels. The surrounding data layers gradually expand to form different versions, such as 15×15, 19×19, and 23×23.

[0083] Aztec codes have two different structures: compact and full-range. The bull's-eye symbol in the middle is similar to the QR (Quick Response Code) symbol, but not identical.

[0084] With the development of machine vision and code reading algorithms, this application proposes an Aztec code positioning method and designs a precise positioning method for Aztec codes in complex backgrounds, thereby improving the positioning accuracy of Aztec codes.

[0085] The two-dimensional code positioning method of the present application overcomes the problems of low Aztec code positioning accuracy and incorrect Aztec code type judgment in the prior art, especially the positioning problem in complex scenes such as high noise. By utilizing the "bull's eye" locator feature of the Aztec code, a positioning method for Aztec codes adapted to high-noise environments is proposed, and a method that can automatically determine the type of Aztec code is designed. The vertex coordinates of the compact "bull's eye" locator are first calculated, and then a caliper is used to determine whether it is a full-range type. If so, the vertex coordinates are updated. Using this method, the positioning accuracy problem of Aztec codes in complex scenes is effectively solved, thereby improving the applicability of Aztec codes and enhancing the efficiency of enterprises.

[0086] Please continue to read for details Figure 1 and Figure 2 , Figure 1 This is a flow chart of an embodiment of the QR code positioning method provided by this application. Figure 2 This is a schematic diagram of the overall process of the QR code positioning method provided by this application.

[0087] The QR code positioning method of the present application is applied to a QR code positioning device, wherein the QR code positioning device of the present application can be a server, a terminal device, or a system composed of a server and a terminal device. Accordingly, the various components of the QR code positioning device, such as the various units, subunits, modules, and submodules, can be all provided in the server, all provided in the terminal device, or separately provided in the server and the terminal device.

[0088] Furthermore, the server described above may be either hardware or software. When the server is hardware, it may be implemented as a distributed server cluster consisting of multiple servers, or as a single server. When the server is software, it may be implemented as multiple software programs or software modules, such as software or software modules for providing a distributed server, or as a single software program or software module, without further limitation.

[0089] The main feature of the Aztec code locator is a "bull's eye" locator module with a white-to-black module ratio of 1:1:1:1:1:1:1.

[0090] The main process of the "bull's eye" locator search method is: binarize the entire image, scan the image pixel by pixel in the horizontal and vertical directions, determine the center position of the locator based on the line segment proportional characteristics, and then calculate the positions of the four vertices of the locator.

[0091] like Figure 1 As shown, the specific steps are as follows:

[0092] Step S11: Acquire a QR code positioning image.

[0093] Step S12: extracting a plurality of first candidate points from the binary image of the two-dimensional code positioning image.

[0094] In an embodiment of the present application, the QR code positioning device performs adaptive threshold segmentation on the QR code positioning image to obtain a binary image, fills the image hole areas, scans the entire image to obtain candidate point positions, and extracts several first candidate points.

[0095] Please refer to the specific process of extracting the first candidate point by the QR code positioning device for details. Figure 4 , Figure 3 yes Figure 1 The specific flow chart of step S12 of the QR code positioning method is shown.

[0096] like Figure 3 As shown, the specific steps are as follows:

[0097] Step S121: Acquire a binary image of the two-dimensional code positioning image.

[0098] In the embodiment of the present application, the QR code positioning device performs mean filtering on the QR code positioning image to reduce noise interference. Then, the QR code positioning device uses adaptive threshold segmentation on the QR code positioning image to generate a binary image.

[0099] Specifically, adaptive threshold segmentation is a general image processing algorithm, and its implementation principle can be expressed as:

[0100]

[0101] in,

[0102] For each pixel srcPixel(x, y), the average pixel value AvePixel(x, y) in its neighborhood N*M is calculated, and the resulting pixel value dstPixel(x, y) at that location is output based on the size relationship between srcPixel(x, y) and AvePixle(x, y). By processing each pixel in turn, a binary image result can be obtained.

[0103] Furthermore, in some cases of high noise or damaged locators, the result of the binary image is not ideal. Hole filling is to fill the white holes in the black module of the entire image through the floodfill algorithm, and finally obtain a complete black module.

[0104] The principle of floodFill is to traverse and find all white closed contours in the binary image, and make the following judgments for each closed contour:

[0105]

[0106] Among them, HoleArea represents the hole area, and HoleAreaThre is the preset hole area threshold.

[0107] Step S122: performing horizontal scanning on the binary image to determine a horizontal line segment that meets a preset horizontal black and white module ratio, and obtaining a center point of the horizontal line segment as a third candidate point.

[0108] In this embodiment, the entire binary image after hole filling is scanned line by line to find all seven line segments whose black and white modules have a ratio of 1:1:1:1:1:1:1. The coordinates of the center point of each line segment are recorded as {lPt1, lPt2, ..., lPtn}. The center point is the third candidate point.

[0109] Step S123: performing a longitudinal scan on the binary image based on the third candidate points to obtain a longitudinal line segment corresponding to each third candidate point.

[0110] In the embodiment of the present application, the midpoint of the line segment obtained by the horizontal scan in step S122 is used as the starting point, and upward and downward scans are performed respectively. Taking the upward scan as an example, the coordinates of the change points from white to black, black to white, and white to black are recorded in sequence as {Pt3, Pt2, Pt1}. Similarly, the coordinates of the black and white change points obtained by the downward scan are recorded as {Pt4, Pt5, Pt6}. Based on the positions of each black and white point, the black and white module ratio of the vertical scan line segment is calculated. The calculation formula is:

[0111] {Pt6y -Pt5 y :Pt5 y -Pt4 y :Pt4 y -Pt3 y :Pt3 y -Pt2 y :Pt2 y -Pt1 y}

[0112] The QR code positioning device eliminates candidate points corresponding to longitudinal line segments that do not meet the ratio of 1:1:3:1:1.

[0113] Step S124: determining a third candidate point corresponding to a vertical line segment that meets a preset vertical black-white module ratio as the first candidate point.

[0114] Step S13: screening the plurality of first candidate points according to preset conditions to determine a plurality of second candidate points.

[0115] In the embodiment of the present application, the QR code positioning device selects candidate points that meet the angle requirements, that is, traverses the candidate box composed of each candidate point and selects candidate points that meet the angle requirements.

[0116] Specifically, the QR code positioning device obtains eight neighboring points of the caliper point in the X direction. Taking point p1 in the horizontal caliper as an example, with p1 as the center, eight neighboring points are obtained. Similarly, the eight neighboring points of each point are taken to form a total of 54 points (6*9) to calculate the angle in the X direction.

[0117] The QR code positioning device calculates the X-direction angle. The Sobel X-direction edge amplitude calculation formula is:

[0118]

[0119] The formula for calculating the edge angle is:

[0120]

[0121] This method is used to calculate the rotation angles of 54 pixels in the X direction.

[0122] Then, the QR code positioning device follows the Figure 4 The 22 angle intervals shown are classified, with an interval of 8°.

[0123] Assuming that the angle of an edge point nAngle = 20°, it belongs to the interval 16 to 24 and has the first weight of 16°. The second weight attributed to 24° is V2 = 1 - V1.

[0124] The QR code positioning device recalculates the angle and weight cumulative sum under the corresponding index number according to the current weight:

[0125]

[0126] The QR code positioning device performs special processing on the ending brightness angle. When nAngle is within 0 to 8 degrees, the weight is expressed as:

[0127]

[0128] When nAngle is between 176 and 180 degrees, the weight is expressed as:

[0129]

[0130] After obtaining the weights of the 54 points, sort them and select the index with the largest cumulative weight value:

[0131]

[0132] The final candidate point angle calculation formula is:

[0133]

[0134] Similarly, the QR code positioning device obtains 54 points in the Y direction and calculates the rotation angle in the Y direction as nResultAngle Y .

[0135] In summary, the QR code positioning device eliminates candidate points that do not meet the requirements based on the X-direction rotation angle and Y-direction rotation angle of the candidate points. The judgment rules are as follows:

[0136] |nResultAngle X -nResultAngle Y |≤30

[0137] Specifically, if the absolute value of the difference between the X-direction rotation angle and the Y-direction rotation angle calculated by the two-dimensional code positioning device is less than 30, the current candidate point is eliminated; otherwise, the current candidate point is retained.

[0138] Step S14: generating a first positioning line based on the edge point and the rotation angle of each second candidate point.

[0139] In an embodiment of the present application, the QR code positioning device selects candidate points that meet the "bull's eye" locator score threshold: that is, on the remaining candidate points, adjust the four edge straight lines of the candidate box composed of the candidate points, calculate the score value of the candidate box surrounded by the four straight lines, and again select candidate points that meet the requirements.

[0140] Specifically, the QR code positioning device calculates the precise position of the caliper on the QR code positioning image, maps the pyramid image to the QR code positioning image, and then uses the caliper to calculate the precise edge point position. The result is as follows: Figure 5 An enlarged view of the "bull's eye" locator is shown.

[0141] The way the QR code positioning device uses a caliper to calculate the precise edge point position is as follows: during the mapping process, points p2 and p5 may not fall exactly on the boundary of the black and white module, so the caliper is used to adjust points p2 and p5 to the boundary of the black and white module.

[0142] Step S15: obtaining an interval sampling diagram based on the first positioning straight line.

[0143] In the embodiment of the present application, the QR code positioning device calculates the vertex position of the "bull's eye" locator. Figure 5 The calculated four precise edge point positions and the rotation angle nResultAngle calculated in step S13 x ,nResultAngle Y , calculate the equations of the four straight lines as Figure 5 As shown, the four straight lines A are translated inward and outward by one module to form new straight lines, such as the green straight line B and the blue straight line C. Then, the four blue straight lines C are intersected in pairs, the positions of the four vertices are calculated, and a rectangular frame is formed.

[0144] The QR code positioning device obtains the interval sampling diagram of the "bull's eye" locator, obtains the black and white module boundary diagram, and then finds the intersection points of the straight lines to obtain 36 X-direction intersection points {pEdgePtX1, pEdgePtX2, ... pEdgePtXn} and 36 Y-direction intersection points {pEdgePtY1, pEdgePtY2, ... pEdgePtYn}. Then, interval sampling is performed between different modules. The interval sampling result diagram is shown as follows: Figure 6 shown.

[0145] Step S16: Counting the grid scores of the interval sampling graph to determine the positioning score of each second candidate point.

[0146] In the embodiment of the present application, the QR code positioning device calculates the score of the interval sampling image, specifically dividing the interval sampling image 14*14 size into 2*2 size blocks, and converting it into a 7*7 size image, such as Figure 7 As shown, then Figure 6 , the color of the 49-equal sampling image is reversed as follows Figure 8 As shown, different blocks are marked with different colors according to the following rules:

[0147]

[0148] The QR code positioning device counts the pixel values ​​and black and white marks of 49 modules, and calculates the sum of the grayscale values ​​of the 16 white modules, nSumLightPixel, and the sum of the grayscale values ​​of the 33 black modules, nSumDarkPixel, to obtain the light / dark contrast threshold:

[0149]

[0150] right Figure 8 Calculate the grid scores of the 16 white modules in the image. For example, take white module number 8 as an example, and count whether the grayscale difference between all black modules in its 8 neighborhoods and the current white module is greater than nContrastThre:

[0151]

[0152] Following the same method, the grid scores of the remaining white modules are counted. Assuming that all modules meet the requirements, the total score is 88.

[0153] Step S17: Obtain target candidate points whose positioning scores are higher than a preset threshold.

[0154] In this embodiment of the present application, the QR code positioning device eliminates candidate points that do not meet the score requirements. Assuming the score threshold is nMinJudgeScore, if nSumScore <= nMinJudgeScore, then the current candidate point is eliminated. The target candidate point is the candidate point with the largest nSumScore among the remaining candidate points.

[0155] Step S18: determining the position of the QR code based on the target candidate point.

[0156] In this embodiment of the present application, the QR code positioning device calculates the vertex coordinates of the "bull's eye" locator. Using a caliper, three precise caliper points are calculated on each line. The caliper points are used to fit the lines using the least squares method. The intersection of the four lines is calculated as the vertex position of the "bull's eye" locator.

[0157] Please refer to the specific process of the QR code positioning device to extract the vertex position of the "bull's eye" locator for details. Figure 9 , Figure 9 yes Figure 1 The specific flow chart of step S18 of the QR code positioning method is shown.

[0158] like Figure 9 As shown, the specific steps are as follows:

[0159] Step S181: Generate a candidate frame based on the target candidate point.

[0160] In the embodiment of the present application, the two-dimensional code positioning device generates a candidate frame according to the positioning points p1 to p6 corresponding to the target candidate point.

[0161] Step S182: Select a point to be located on a candidate edge of the candidate frame.

[0162] In this embodiment, the QR code positioning device selects three points {Pt1, Pt2, Pt3} on each edge of the candidate box for caliper precision positioning. After precision positioning, the device then uses the least squares method to fit a straight line: Line 1. The caliper precision positioning function moves the three selected points to the boundary of the black and white blocks in the image, which serve as precision positioning points.

[0163] Step S183: performing caliper fine positioning on the point to be positioned to determine the fine positioning point.

[0164] Step S184: fitting a straight line based on the precise positioning points to determine the first two-dimensional code vertex.

[0165] In the embodiment of the present application, similarly, the other three edges are precisely positioned with a caliper and then fitted with straight lines. The four fitted straight lines are then intersected in pairs, and the coordinates of the four vertices are {verPt1, verPt2, verPt3, verPt4}.

[0166] Step S185: Determine the positioning position of the QR code according to the first QR code vertex.

[0167] In an embodiment of the present application, the QR code positioning device determines the QR code positioning position in the QR code positioning image based on the four QR code vertices.

[0168] In the present application, a two-dimensional code positioning device obtains a two-dimensional code positioning image; extracts a plurality of first candidate points from the binary image of the two-dimensional code positioning image; screens the plurality of first candidate points according to preset conditions to determine a plurality of second candidate points; generates a first positioning straight line based on the edge points and rotation angles of each second candidate point; obtains an interval sampling diagram based on the first positioning straight line; counts the grid scores of the interval sampling diagram to determine the positioning score of each second candidate point; obtains a target candidate point whose positioning score is higher than a preset threshold; and determines the position of the two-dimensional code based on the target candidate point. Through the above-mentioned two-dimensional code positioning method, the computational complexity is low, the problem of two-dimensional code positioning in complex industrial environments is solved, and accurate two-dimensional code contour positioning is achieved.

[0169] Further, in Figure 1Building on the QR code positioning method shown above, the QR code positioning device can also determine the code type, update vertex coordinates, and fit the four edges of the entire code area. Based on the calculated vertex positions, the midpoints of each pair of vertex positions are expanded outward by two modules to determine whether a white-black-white process has been performed. If all four points meet the requirements, the code type is full-range, and the vertex positions of the "bull's eye" locator are updated. Based on the rules of the Aztec code storage mode message, the code version is parsed to calculate the four vertex coordinates of the entire code area, and then the four edges of the Aztec code are fitted.

[0170] Please continue to read for details Figure 10 , Figure 10 This is a flow chart of another embodiment of the QR code positioning method provided by this application.

[0171] like Figure 10 As shown, the specific steps are as follows:

[0172] Step S21: fitting a positioning line and an expansion line based on the precise positioning points.

[0173] Step S22: obtaining the projection points of the positioning line and the expansion line of the target candidate point.

[0174] In an embodiment of the present application, the QR code positioning device calculates and fits the full-range Aztec code according to the previous steps to obtain four straight lines, and then expands the straight lines outward by one module, such as the green straight line D, and expands the straight lines outward by two modules, such as the red straight line E, and then projects the center point centerPt onto the four green straight lines D to obtain four projection points {proPt1, proPt2, proPt3, proPt4}.

[0175] Step S23: Obtain a histogram of the projection line segment where each projection point is located.

[0176] In the embodiment of the present application, the QR code positioning device calculates the histogram of the caliper data points. Taking point proPt3 as an example, a data segment is intercepted with 2 modules above and below and 0.5 modules left and right, with point proPt3 as the center, and the histogram is made based on this data segment.

[0177] Step S24: Determine the type of the QR code based on the change of the histogram.

[0178] In this embodiment, a QR code positioning device determines the Aztec code type by traversing the histogram from right to left to see if it passes through three transitions: white to black, black to white, and white to black. Similarly, a histogram is calculated for the other three projection points to see if they pass through the three transitions. If all four points meet the requirements, the Aztec code is considered full-range; otherwise, it is considered compact.

[0179] If the two-dimensional code type is determined to be a full-range Aztec code in step S24, the vertex coordinates of the "bull's eye" locator can be directly calculated and updated according to step S18.

[0180] Finally, the QR code positioning device fits the four edges of the entire Aztec code area. Based on the four vertex coordinates of the "bull's eye" locator and the rules of the Aztec code storage mode information, the Aztec code version number information is parsed, and the coordinates of the four vertices of the entire code area are calculated. The four edges of the code are then fitted.

[0181] The QR code positioning method of this application proposes a method for positioning the Aztec code "bull's eye" locator in complex backgrounds, which realizes Aztec outline positioning in complex scenes such as high background noise and damaged "bull's eye" locator.

[0182] The QR code positioning method of the present application proposes an Aztec code "bull's eye" locator positioning method, which uses the characteristics of the locator to calculate candidate points, and then filters out candidate points that do not meet the requirements through angle screening of the candidate frame and the score value of the locator. Based on the calculated compact candidate frame, it is determined whether it is a full-range type. The calculation complexity is low, and it solves the Aztec code positioning problem in complex industrial environments.

[0183] Those skilled in the art will understand that in the above-mentioned method of the specific implementation method, the writing order of each step does not mean a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of each step should be determined by its function and possible internal logic.

[0184] In order to implement the above-mentioned QR code positioning method, this application also proposes a QR code positioning device, please refer to Figure 11 , Figure 11 It is a structural diagram of an embodiment of a QR code positioning device provided by this application.

[0185] The two-dimensional code positioning device 400 of this embodiment includes a processor 41 , a memory 42 , an input / output device 43 , and a bus 44 .

[0186] The processor 41 , the memory 42 , and the input / output device 43 are respectively connected to the bus 44 . The memory 42 stores program data, and the processor 41 is used to execute the program data to implement the two-dimensional code positioning method described in the above embodiment.

[0187] In the embodiment of the present application, the processor 41 may also be referred to as a CPU (Central Processing Unit). The processor 41 may be an integrated circuit chip having signal processing capabilities. The processor 41 may also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. A general-purpose processor may be a microprocessor, or the processor 41 may be any conventional processor.

[0188] This application also provides a computer storage medium, please continue to refer to Figure 12 , Figure 12 It is a structural diagram of an embodiment of a computer storage medium provided in the present application. The computer storage medium 600 stores a computer program 61. When the computer program 61 is executed by the processor, it is used to implement the two-dimensional code positioning method of the above embodiment.

[0189] When the embodiments of the present application are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0190] The above description is only an implementation method of the present application and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the description and drawings of this application, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.

Claims

1. A two-dimensional code positioning method, characterized in that: The two-dimensional code positioning method includes: Get the QR code positioning image; Extracting a plurality of first candidate points from the binary image of the two-dimensional code positioning image; Screening the plurality of first candidate points according to preset conditions to determine a plurality of second candidate points; Generate a first positioning line based on the edge point and the rotation angle of each second candidate point; Acquire an interval sampling diagram based on the first positioning straight line; Counting the grid scores of the interval sampling map to determine the positioning score of each second candidate point; Obtaining target candidate points whose positioning scores are higher than a preset threshold; The position of the two-dimensional code is determined based on the target candidate point.

2. The two-dimensional code positioning method according to claim 1, characterized in that: The determining the position of the two-dimensional code based on the target candidate point includes: Generate a candidate frame based on the target candidate point; Selecting a point to be located on a candidate edge of the candidate frame; Performing caliper precision positioning on the point to be positioned to determine the precise positioning point; Determine a first QR code vertex based on the precisely positioned point fitting straight line; According to the first two-dimensional code vertex, the two-dimensional code positioning position is determined.

3. The two-dimensional code positioning method according to claim 2, characterized in that: After the point to be positioned is precisely positioned using a caliper and the precise positioning point is determined, the QR code positioning method further comprises: Fitting a positioning line and an expansion line based on the precise positioning points; Obtaining the projection points of the positioning line and the expansion line of the target candidate point; Get the histogram of the projection line segment where each projection point is located; The type of the QR code is determined based on changes in the histogram.

4. The two-dimensional code positioning method according to claim 1, characterized in that: The extracting a plurality of first candidate points from the binary image of the two-dimensional code positioning image includes: Obtaining a binary image of the QR code positioning image; Performing a horizontal scan on the binary image to determine a horizontal line segment that meets a preset horizontal black and white module ratio, and obtaining a center point of the horizontal line segment as a third candidate point; Performing a longitudinal scan on the binary image based on the third candidate points to obtain a longitudinal line segment corresponding to each third candidate point; A third candidate point corresponding to a vertical line segment that meets a preset vertical black-white module ratio is determined as the first candidate point.

5. The two-dimensional code positioning method according to claim 4, characterized in that: The screening of the plurality of first candidate points according to the preset conditions to determine a plurality of second candidate points includes: Obtaining the horizontal black and white module boundary point on the horizontal line segment of each first candidate point, and the vertical black and white module boundary point on the vertical line segment; Based on the horizontal black and white module boundary point, obtaining the horizontal rotation angle of the horizontal line segment; Based on the vertical black and white module boundary points, obtaining the vertical rotation angle of the vertical line segment; Obtaining a rotation angle difference between the horizontal rotation angle and the vertical rotation angle; The first candidate points whose absolute value of the rotation angle difference is less than or equal to a preset angle difference threshold are eliminated, and the second candidate point is determined based on the remaining first candidate points.

6. The two-dimensional code positioning method according to claim 5, characterized in that: The acquiring the horizontal rotation angle of the horizontal line segment based on the horizontal black and white module boundary point includes: Get the eight neighborhood points of each horizontal black and white module boundary point; Based on the rotation angle of the horizontal black and white module boundary point and each of the eight neighborhood points; Mapping the rotation angle of each point to a preset angle interval, and obtaining the cumulative angle sum and the cumulative weight sum of each index number in the preset angle interval; Get the target index number of the maximum weighted cumulative sum; The horizontal rotation angle of the horizontal line segment is determined based on the cumulative sum of the angles and the cumulative sum of the weights of the target index numbers.

7. The two-dimensional code positioning method according to claim 6, characterized in that: Mapping the rotation angle of each point to a preset angle interval, and obtaining the cumulative angle sum and the cumulative weight sum of each index number in the preset angle interval, includes: Mapping the rotation angle of each point to a preset angle interval, and determining a first index number and a second index number of the target angle interval; Determining a first weight based on a difference between the rotation angle and the first index number; Determining a second weight based on a difference between the rotation angle and the second index number; Determine the cumulative weight value of the first index number using the first weight; Determine the cumulative weight value of the second index number using the second weight; Determine an angle accumulation value of the first index number based on the first weight and the rotation angle; Determine an angle accumulation value of the second index number based on the second weight and the rotation angle; After traversing the rotation angles of all points, the cumulative angle sum and the cumulative weight sum of each index number in the preset angle interval are determined.

8. The two-dimensional code positioning method according to claim 1, characterized in that: The acquiring of an interval sampling diagram based on the first positioning straight line includes: Determine a second inward positioning straight line and a third outward positioning straight line based on the first positioning straight line; Interval sampling is performed in a plurality of module areas formed by the first positioning straight line, the second positioning straight line, the third positioning straight line and their intersections to obtain the interval sampling map.

9. The two-dimensional code positioning method according to claim 8, characterized in that: The counting of the grid scores of the interval sampling graph to determine the positioning score of each second candidate point includes: Converting the interval sampling graph into a block sampling graph; Performing color inversion on the block sampling image to obtain a color sampling image; Obtain a white module grid in the color sampling map; Determining a positioning score of each white module grid based on a grayscale difference between a neighborhood module grid of each white module grid and the white module grid; The positioning scores of all white module grids are counted to determine the positioning score of the second candidate point.

10. The two-dimensional code positioning method according to claim 9, characterized in that: The determining of the positioning score of the white module grid based on the grayscale difference between the neighborhood module grid of each white module grid and the white module grid includes: When the grayscale difference between the white module grid and the neighborhood module grid is greater than the contrast threshold, the positioning score of the white module grid is increased by 1; Traversing all neighboring module grids of the white module grid, and determining the positioning score of the white module grid; The contrast threshold is determined by the number of grids and the grayscale value of the white module grid and the number of grids and the grayscale value of the black module grid.

11. A two-dimensional code positioning device, characterized in that: The two-dimensional code positioning device includes a memory and a processor coupled to the memory; The memory is used to store program data, and the processor is used to execute the program data to implement the two-dimensional code positioning method according to any one of claims 1 to 10.

12. A computer storage medium, characterized in that The computer storage medium is used to store program data, and when the program data is executed by a computer, it is used to implement the two-dimensional code positioning method according to any one of claims 1 to 10.

Citation Information

Patent Citations

  • Defective two-dimensional code positioning method

    CN113095104A

  • Two-dimensional code positioning method and device

    CN117787311A

  • Barcode recognition and positioning method, electronic device and computer-readable storage medium

    CN119783706A

  • Composite code pattern, generating device, reading device, method, and program

    US20210103786A1

  • Methods and systems for localizing aztec codes

    US9396422B1

Cited By

  • Two-dimensional code positioning graph and method

    CN121328589A