Two-dimensional code corner positioning method

By combining local deconvolution and image enhancement preprocessing with multi-radius subpixel sampling and robust line fitting, the problem of balancing high accuracy and robustness in two-dimensional matrix code localization is solved, achieving high-precision corner point localization, which is suitable for visual measurement tasks.

CN121525718APending Publication Date: 2026-02-13ZHEJIANG MILEY ROBOT CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511717383.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-21
Publication Date
2026-02-13

AI Technical Summary

Technical Problem

Existing technologies struggle to balance high accuracy and robustness in two-dimensional matrix code localization. Traditional methods are sensitive to noise, and deep learning methods lack sufficient localization accuracy, failing to meet sub-pixel level accuracy requirements.

Method used

By employing local deconvolution and image enhancement preprocessing, combined with multi-radius subpixel sampling, gradient profile fitting, and robust line fitting, a progressive processing flow from local subpixel edge localization to global geometric constraints is used to achieve systematic optimization of corner coordinates.

Benefits of technology

Stable and reliable high-precision corner point positioning was achieved under complex imaging conditions, improving the robustness and accuracy of QR code recognition, and making it suitable for visual measurement tasks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121525718A_ABST
    Figure CN121525718A_ABST
Patent Text Reader

Abstract

The invention discloses a two-dimensional code corner positioning method, which belongs to the technical field of computer vision and comprises the following steps: acquiring an initial corner coordinate set in an original image; cutting the region of interest, and performing image enhancement to obtain an enhanced image; selecting a reference angular point, and carrying out multi-radius sub-pixel sampling on the enhanced image along the edge normal direction of the reference angular point; calculating a gradient profile along the sampling direction, and performing sub-pixel positioning to obtain a sub-pixel coordinate set of the edge points; performing linear fitting on the sub-pixel coordinate set of the edge points, and calculating intersection points of adjacent linear equations to update coordinates of the reference angular points; and projecting the non-reference angular points to a corresponding straight line for position correction, and generating a final angular point coordinate set. According to the method, local deconvolution deblurring and image enhancement are introduced as preprocessing steps, and a progressive processing flow from local sub-pixel edge positioning to global geometric constraint is combined, so that high-precision positioning and robustness of angular point coordinates are 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 computer vision, and in particular to a two-dimensional code corner point positioning method. BACKGROUND

[0002] As a kind of efficient information carrier, two-dimensional matrix code is widely used in industrial detection, object recognition, pose estimation and precision measurement. The traditional two-dimensional matrix code recognition process usually includes image acquisition, preprocessing, decoding and other steps, and the decoding stage will output the pixel-level four corner point coordinates of the code block. However, in the actual application process, due to the influence of imaging noise, motion blur, lens distortion and insufficient image contrast, these pixel-level corner point coordinates often have deviations, which leads to the decline of code block positioning accuracy, and further affects the accuracy of subsequent pose estimation and measurement results.

[0003] In order to improve the positioning accuracy, the prior art has proposed various sub-pixel level corner point detection methods. For example, based on Hough transform or Canny edge detection method, the position of the corner point is estimated by simple interpolation or edge response peak positioning. But this kind of method is sensitive to noise, uneven illumination and image blur and other interference factors, and its robustness is poor, and its accuracy is usually limited to pixel level, which is difficult to meet the demand of sub-pixel level positioning in high-precision industrial scene.

[0004] With the development of deep learning technology, the method based on convolutional neural network (CNN) is introduced into the corner point detection, such as directly regressing the corner point coordinates or outputting the heat map to improve the robustness. However, such methods are limited by the receptive field and down-sampling layer of the network structure, and the positioning accuracy of the output usually has an error of 1-2 pixels, which cannot be directly applied to precision measurement or positioning tasks requiring sub-pixel level accuracy.

[0005] Therefore, in the implementation of two-dimensional matrix code positioning, the prior art generally has the contradiction that robustness and high accuracy cannot be achieved. A new technical solution is needed to effectively integrate the robustness of deep learning and the accuracy of traditional algorithms to achieve fast, robust and sub-pixel level accurate positioning of two-dimensional code. SUMMARY

[0006] The purpose of the present application is to provide a two-dimensional code corner point positioning method to solve the problem that high-precision positioning and robustness cannot be achieved in the prior art.

[0007] To achieve the above purpose, the following technical solutions are adopted in the present application:

[0008] A two-dimensional code corner point positioning method of the present application comprises the following steps:

[0009] obtain an initial corner point coordinate set in the original image;

[0010] cropping a region of interest according to the initial corner point coordinate set and performing image enhancement on the region of interest to obtain an enhanced image;

[0011] selecting a reference corner point from the initial corner point coordinate set and performing multi-radius sub-pixel sampling along the edge normal direction of the reference corner point on the enhanced image;

[0012] calculating a gradient profile along the sampling direction based on the sampling points and performing sub-pixel positioning according to the gradient profile to obtain a sub-pixel coordinate set of the edge point;

[0013] performing straight line fitting on the sub-pixel coordinate set of the edge point to obtain a sub-pixel level straight line equation and calculating the intersection point of adjacent straight line equations to update the coordinate of the reference corner point;

[0014] projecting non-reference corner points onto the corresponding straight lines for position correction to generate a final corner point coordinate set.

[0015] Preferably, the method further comprises:

[0016] performing distortion correction on the region of interest using a camera distortion correction model.

[0017] Preferably, the image enhancement on the region of interest comprises:

[0018] performing image restoration processing on the region of interest using a deconvolution algorithm;

[0019] performing smoothing filtering processing on the restored image.

[0020] Preferably, the multi-radius sub-pixel sampling along the edge normal direction of the reference corner point comprises:

[0021] determining the adjacent edge direction vector of the reference corner point and the corresponding edge normal vector;

[0022] setting multiple sampling points along the adjacent edge direction vector;

[0023] for each sampling point, generating candidate points along the edge normal vector direction with different radii;

[0024] for each candidate point, performing equidistant sub-pixel sampling along the edge normal vector direction.

[0025] Preferably, the calculation of the gradient profile along the sampling direction based on the sampling points comprises:

[0026] calculating the sub-pixel gray value of each sampling point using an interpolation method;

[0027] Based on the sub-pixel gray value, a sub-pixel gradient component of the sampling point in the direction of the image coordinate axis is calculated by using a difference method;

[0028] The sub-pixel gradient component is projected onto a corresponding edge normal vector to obtain a normal gradient projection value thereof;

[0029] The normal gradient projection values of all sampling points are collected and sorted according to the sampling order to form a gradient profile.

[0030] As preferred, the sub-pixel coordinates set of the edge point obtained according to the gradient profile includes:

[0031] A Gaussian first derivative function is used to perform curve fitting on the gradient profile;

[0032] Based on the gradient profile, parameters of the Gaussian first derivative function are initialized, wherein an initial value of the sub-pixel edge center position is set as a position of an extreme value point of the gradient profile;

[0033] A nonlinear optimization algorithm is used to iteratively optimize the parameters of the function;

[0034] The sub-pixel edge center position obtained after optimization is taken as the sub-pixel coordinates of the edge point.

[0035] As preferred, the linear fitting on the sub-pixel coordinates set of the edge point to obtain a sub-pixel level linear equation includes:

[0036] Outliers are removed from the sub-pixel coordinates set of the edge point by using a robust estimation algorithm to obtain an optimal inner point set;

[0037] The optimal inner point set is subjected to least square linear fitting to obtain a sub-pixel level linear equation.

[0038] As preferred, the least square linear fitting on the optimal inner point set is realized by principal component analysis.

[0039] As preferred, the calculation of the intersection point of adjacent linear equations to update the coordinates of the reference corner point includes:

[0040] The cross product of adjacent linear normal vectors is calculated;

[0041] When the absolute value of the cross product is greater than a set threshold, the intersection point coordinates are calculated and taken as the sub-pixel coordinates of the reference corner point.

[0042] As preferred, the projection of the non-reference corner point onto the corresponding linear line for position correction includes:

[0043] For each non-reference corner point, an edge directly connected with the reference corner point is identified;

[0044] projecting the non-reference corner point to a straight line generated by the reference corner point and collinear with the connected edge as a projection path, to obtain a projection point of the non-reference corner point;

[0045] calculating a coordinate deviation between the non-reference corner point and the projection point;

[0046] updating the position of the corner point by using the coordinate of the projection point when the coordinate deviation meets a preset constraint condition.

[0047] As preferred, the preset constraint condition is:

[0048]

[0049] wherein, is a horizontal coordinate deviation, is a vertical coordinate deviation, is an absolute threshold value, is a relative threshold value, is a corresponding edge length.

[0050] As preferred, the method further comprises a position correction verification step:

[0051] judging whether the projection point is located within the original image;

[0052] rejecting the current position correction when the projection point is out of the range of the original image.

[0053] The present application has the following beneficial effects:

[0054] The present application realizes systematic optimization of the corner point coordinates by introducing local deconvolution defogging and image enhancement as a preprocessing step, and combining a progressive processing procedure from local sub-pixel edge positioning to global geometric constraint. Specifically, the blurred edges caused by the point spread function of the imaging system are effectively restored through the deconvolution operation, which significantly improves the image resolution and edge sharpness, providing high-quality input data for subsequent processing; the image enhancement processing further enhances the edge contrast and suppresses the noise, so that the normal multi-radius sampling can obtain clearer gradient profiles, laying a solid foundation for sub-pixel edge positioning; finally, through robust straight line fitting, intersection analytical calculation and adaptive projection correction mechanism, the local high-precision observation is integrated into a globally consistent and spatially effective corner point network, which can still obtain stable and reliable high-precision corner point coordinates under complex imaging conditions, providing strong technical support for visual measurement. BRIEF DESCRIPTION OF DRAWINGS

[0055] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the accompanying drawings needed to be used in the embodiments or prior art description will be briefly introduced. Obviously, the accompanying drawings in the following description only constitute some embodiments of the present application, and for those skilled in the art, other drawings can also be obtained without creative labor.

[0056] Figure 1 is a flowchart of a two-dimensional code corner point positioning method provided by an embodiment of the present application;

[0057] Figure 2 is a flowchart of a gradient profile along the sampling direction based on the sampling points provided by an embodiment of the present application;

[0058] Figure 3 is a flowchart of obtaining a sub-pixel coordinate set of an edge point according to sub-pixel positioning based on the gradient profile provided by an embodiment of the present application;

[0059] Figure 4 is a flowchart of a RANSAC random sample consensus algorithm provided by an embodiment of the present application;

[0060] Figure 5 is a flowchart of projecting a non-reference corner point to a corresponding straight line for position correction provided by an embodiment of the present application. DETAILED DESCRIPTION

[0061] In order to make the technical solutions of the present application clearer, the present application will be further described in detail below in combination with the accompanying drawings and specific embodiments.

[0062] The terms "first", "second", etc. in the claims and specification of the present application are used to distinguish similar objects, and do not necessarily describe a specific order or sequence. It should be understood that the terms used in this way can be interchanged under appropriate circumstances, which is only a way of distinguishing the objects with the same attributes in the description of the embodiments of the present application. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, so that the processes, methods, systems, products or equipment containing a series of units do not have to be limited to those units, but can include other units not clearly listed or inherent to these processes, methods, products or equipment.

[0063] The embodiments in the present application and the features in the embodiments can be combined with each other without conflict.

[0064] As shown in Figure 1 The present disclosure provides a two-dimensional code corner point positioning method, which includes steps S110-S160.

[0065] S110, obtaining an initial corner point coordinate set in an original image;

[0066] This step aims to quickly and robustly locate the approximate area of the two-dimensional code from the complex background.

[0067] Specifically, after obtaining the original gray image containing the two-dimensional code , instead of directly performing traditional image processing such as edge detection and contour search, a lightweight convolutional neural network (CNN) model optimized for key point detection is used to perform forward inference on the image. Through its deep feature abstraction capability, the model can effectively overcome interference such as illumination variation, partial occlusion, and perspective distortion, and realize pixel-level four-corner point regression. Finally, the model outputs a set of four two-dimensional coordinates , which is defined as the initial corner point coordinate set in the embodiments of the present disclosure. Although this set has not yet reached sub-pixel level accuracy, it has accurately indicated the approximate positions of the four corner points of the two-dimensional code, providing reliable initialization data for subsequent fine positioning.

[0068] S120, crop the region of interest according to the initial corner point coordinate set, and perform image enhancement on the region of interest to obtain an enhanced image;

[0069] This step aims to accurately extract the two-dimensional code region from the approximate area of the two-dimensional code to construct a high-quality, background-free processing area, thereby significantly improving the accuracy and robustness of subsequent fine corner point positioning.

[0070] Specifically, based on the detected four corner point coordinates, the minimum circumscribed rectangle is accurately calculated, and the rectangular boundary is uniformly expanded by p pixels (p is a preset parameter, usually in the range of 5-15 pixels) to the four sides to ensure that the rectangle contains the complete area of the two-dimensional code and avoids missing edge information. Then, image cropping is performed according to the expanded boundary to obtain the region of interest (ROI), and finally, image enhancement processing is performed on the ROI to lay a solid foundation for subsequent high-precision corner point positioning.

[0071] Further, the region of interest is corrected for distortion using a camera distortion correction model.

[0072] It should be noted that after obtaining the ROI, in order to eliminate the influence of camera lens distortion on the geometric accuracy of subsequent processing, the ROI also needs to be corrected for distortion. The embodiments of the present disclosure use a standard pinhole camera model combined with a radial distortion and tangential distortion correction algorithm to accurately map the ROI through pre-calibrated camera parameters. Based on the camera intrinsic matrix and distortion parameters, the distorted image is converted to a planar representation without distortion, effectively suppressing image distortion caused by lens curvature and safety errors, and providing geometrically consistent input data for subsequent fine corner point positioning, significantly improving the accuracy and robustness of the positioning result.

[0073] Furthermore, image enhancement is performed on the region of interest, including:

[0074] The deconvolution algorithm is used to perform image restoration processing on the region of interest;

[0075] The restored image is then subjected to a smoothing filter.

[0076] After completing the distortion correction of the ROI, in order to effectively restore the high-frequency details of the image and suppress the adverse effects of the image degradation process, the embodiments of this disclosure further perform image enhancement processing on the region of interest, specifically including two key steps: image restoration and smoothing filtering.

[0077] First, the Lucy–Richardson deconvolution algorithm is used to restore the corrected Region of Interest (ROI). As an iterative optimization restoration technique based on maximum likelihood estimation, the core of the Lucy–Richardson algorithm lies in reconstructing a clear image of the target region through deconvolution operations. In each iteration, the algorithm models the degradation characteristics of the system (such as lens blur or motion blur) using a predefined point spread function (PSF), and dynamically updates the intensity values ​​of individual pixels in the image by continuously comparing the differences between the observed image and the currently estimated image, thus gradually approximating the real scene. Simultaneously, operating within a Bayesian probabilistic framework, the algorithm effectively balances noise suppression and signal enhancement, avoiding image quality degradation due to noise amplification during iterative restoration, and significantly improving the fidelity of key high-frequency features such as texture and edges. Through this processing, the resolution and visual sharpness of the ROI region are significantly improved, making it particularly suitable for eliminating blurring caused by atmospheric turbulence or target motion, providing a high-precision, low-noise input image for subsequent fine corner localization and other processing steps.

[0078] In this embodiment of the disclosure, the iteration formula is as follows:

[0079] ,

[0080] in, Represents convolution. This indicates a flipped kernel convolution. for The flipped core, For a predefined point spread function, To keep it constant and prevent division by zero, Represents the current iteration image and the initial latent image. Number of iterations .

[0081] After the deconvolution image restoration is completed, in order to further improve the image quality and suppress the possible residual noise or artifacts, the embodiment also performs a smoothing filtering process on the restored ROI to obtain an enhanced image . This step can effectively filter out the high-frequency noise and local irregular disturbances that may be introduced in the deconvolution process, while preserving the main structure and edge information in the image. By selecting an appropriate smoothing filter (such as Gaussian filtering, median filtering or bilateral filtering), in the embodiment of the present disclosure, Gaussian filtering is selected. Through this operation, a good balance between preserving image details and achieving noise suppression can be achieved, thereby improving the overall quality and visual consistency of the image, and providing a cleaner and more stable image basis for subsequent analysis tasks, thereby significantly enhancing the robustness and accuracy of the entire recognition.

[0082] Through the above series of processing procedures, not only the interference of the complex background on the two-dimensional code recognition is effectively eliminated, but also the image quality is significantly improved, providing high-quality input data for the subsequent accurate positioning of the corner points.

[0083] It should be noted that after the image enhancement is completed, the enhanced RPI region can also be selected to be pasted back to the corresponding position of the original full image copy, and the entire image after pasting back can be used as the final input image.

[0084] S130, selecting a reference corner point from the initial corner point coordinate set, and performing multi-radius sub-pixel sampling along the edge normal direction of the reference corner point on the enhanced image;

[0085] This step breaks through the limitation of pixels along the direction (normal direction) that best reflects the edge features on the basis of an optimized image, using a reliable corner point as a reference, and collects a series of high-precision data that can completely describe the edge gray transition characteristics, laying a solid foundation for subsequent sub-pixel accurate positioning.

[0086] After the image enhancement processing of deconvolution and smoothing filtering, the embodiment of the present disclosure performs multi-radius sub-pixel sampling operation based on the reference corner point. First, an angle point is selected as a reference corner point from the initial corner point coordinate set that has been extracted, and the selection considers the position stability of each corner point in the image, the edge sharpness and its geometric importance in the target structure. In the embodiment of the present disclosure, the corner point is selected as the reference corner point, and the adjacent edges are → and → The selection is conducive to establishing a stable local coordinate system in subsequent processing and facilitating high-precision sampling analysis along the normal direction of the corner edge.

[0087] Further, the multi-radius sub-pixel sampling along the edge normal direction of the reference corner point includes:

[0088] determining a direction vector of the adjacent edge of the reference corner point and a corresponding edge normal vector;

[0089] setting a plurality of sampling points along the direction vector of the adjacent edge;

[0090] for each sampling point, generating candidate points along the direction of the edge normal vector at different radii;

[0091] for each candidate point, performing equidistant sub-pixel sampling along the direction of the edge normal vector.

[0092] After the reference corner point is selected, the direction vector of the adjacent edge of the reference corner point and the corresponding edge normal vector are determined. The edge normal vector is perpendicular to the edge and points to the outside of the image, which establishes a geometric reference for subsequent sampling. → For example, the direction vector is calculated, and the unitization of the adjacent edge direction is realized; then the corresponding edge normal vector is obtained according to the direction vector, which is perpendicular to the edge and points to the outside of the image, establishing a geometric reference for subsequent sampling.

[0093] Next, a plurality of sampling points are set along the direction vector of the adjacent edge. Taking the reference corner point as the starting point, sampling positions are set every s pixels along the direction , where k is the sampling serial number. This step systematically constructs a set of control points in the edge extension direction, providing a positioning basis for normal sampling.

[0094] Then, at each sampling point , candidate points are generated along the direction of the edge normal vector at a plurality of preset radii, and the radius set is r∈{2, 3, 4, 5} (unit: pixel). Through multi-radius design, different scale regions from edge near points to far points can be covered, enhancing the ability to capture changes in edge profile.

[0095] Finally, equidistant sub-pixel sampling is performed along the direction of the normal vector near each candidate point. By extracting the gray value at a fixed interval at the sub-pixel level, a high-precision gray distribution curve in the normal direction is obtained. This data comprehensively reflects the local variation intensity of the edge region, providing rich and accurate feature information for subsequent edge precise positioning, corner point coordinate optimization and geometric parameter estimation, thereby significantly improving the measurement accuracy and robustness of the entire recognition result.

[0096] S140, calculating a gradient profile along the sampling direction based on the sampling points, and performing sub-pixel positioning to obtain a set of sub-pixel coordinates of the edge points according to the gradient profile;

[0097] This step aims to optimize the initial coarse pixel-level edge / corner position to high-precision sub-pixel-level coordinates. By densely sampling along the edge normal, constructing a gray gradient profile, and locating the extreme points of the profile using mathematical fitting techniques, it overcomes the inherent error caused by digital image discretization, ultimately achieving positioning accuracy far exceeding a single pixel resolution.

[0098] Further, as shown in Figure 2 , based on the sampling points, the gradient profile along the sampling direction is calculated, including:

[0099] S210, using an interpolation method to calculate the sub-pixel gray value of each sampling point;

[0100] S220, based on the sub-pixel gray value, using a difference method to calculate the sub-pixel gradient component of the sampling point in the image coordinate axis direction;

[0101] S230, projecting the sub-pixel gradient component onto the corresponding edge normal vector to obtain its normal gradient projection value;

[0102] S240, collecting the normal gradient projection values of all sampling points, sorting them in the sampling order, and forming a gradient profile.

[0103] Specifically, for each sub-pixel coordinate point obtained by multi-radius sampling, first use a specified interpolation algorithm such as bicubic interpolation to calculate the gray value at the corresponding position on the enhanced image. In the embodiments of the present disclosure, the interpolation algorithm used is bicubic interpolation, which can provide higher-order smoother pixel value approximation results than bilinear interpolation, thereby effectively improving the reliability of the gradient peak position and the sub-pixel estimation accuracy. This process breaks through the limitations of discrete pixel networks and obtains continuous image gray information, providing high-precision input data for subsequent gradient calculation.

[0104] where the formula for one-dimensional cubic interpolation is as follows:

[0105] + ,

[0106] for adjacent four-point sampling, ∈[0,1], two-dimensional interpolation first row and then column or vice versa.

[0107] Next, by interpolating the gray values of the sampling points at their X-axis positive and negative offsets of a small step such as 0.5 pixels, and calculating their difference, the sub-pixel gradient component in the X direction is obtained ; Similarly, by calculating the difference of the gray values in the Y-axis direction, the sub-pixel gradient component in the Y direction is obtained . This step accurately describes the change trend of gray in different directions on the two-dimensional image plane, where , respectively correspond to the partial derivatives of the image in the X direction and the Y direction.

[0108] To achieve accurate positioning of the edge, it is also necessary to convert the gradient from the image coordinate axis direction to the normal direction of the edge. The gradient vector calculated by the embodiment of the disclosure is projected onto the edge unit normal vector (N) of the reference corner determined in advance. The projection calculation is completed by vector dot product, that is, the normal gradient projection value (G) is obtained. The operation effectively filters the tangent direction gradient information irrelevant to the edge positioning, and highlights the gray level change intensity in the normal direction. The projection calculation is completed by vector dot product, that is, the normal gradient projection value (G) is obtained. The operation effectively filters the tangent direction gradient information irrelevant to the edge positioning, and highlights the gray level change intensity in the normal direction.

[0109] Finally, all the sampling points corresponding to the current reference corner are sorted according to their sampling order along the normal direction of the edge (usually the radius order from inside to outside or from outside to inside), and the normal gradient projection value corresponding to each sampling point is collected in this order, and finally a continuous one-dimensional gradient profile is formed. The profile takes the sampling distance as the horizontal coordinate and the normal gradient projection value as the vertical coordinate, clearly describing the distribution of the gray level change rate at the edge, and laying a direct foundation for subsequent sub-pixel positioning through extreme value search or curve fitting.

[0110] Further, as shown in Figure 3 , the sub-pixel coordinates of the edge points obtained by sub-pixel positioning according to the gradient profile include:

[0111] S310, curve fitting of the gradient profile is performed using a Gaussian first derivative function;

[0112] S320, based on the gradient profile, the parameters of the Gaussian first derivative function are initialized, wherein the initial value of the sub-pixel edge center position is set as the extreme point position of the gradient profile;

[0113] S330, the parameters of the function are iteratively optimized using a nonlinear optimization algorithm;

[0114] S340, the sub-pixel edge center position obtained after optimization is taken as the sub-pixel coordinates of the edge point.

[0115] To accurately describe the edge characteristics represented by the gradient profile, the first derivative of the Gaussian function is used as the fitting model in the embodiment of the disclosure. The model can effectively represent the blurred edge caused by the point spread function of the imaging system in theory, and its mathematical form can well match the distribution rule of the edge gradient in the real image. By fitting the continuous function with the discrete gradient profile data, sub-pixel level interpolation of the edge position can be realized.

[0116] wherein the first derivative of the Gaussian function is: ​​

[0117] ,

[0118] is a sub-pixel edge center position parameter; is an edge spread scale; A is an amplitude.

[0119] Before starting the nonlinear optimization algorithm, the parameters of the Gaussian first derivative function are initialized to ensure the fast and convergence of the optimization process. In the embodiments of the present disclosure, the initial value of is set as the abscissa corresponding to the extreme point found on the gradient profile by the damped least squares method, i.e., the sampling point with the maximum absolute value of the gradient; the initial value of is set as 1.0 (corresponding to a typical edge width of 1 pixel), which is iteratively updated, and ≥ 0.1; the initial value of A is set as the difference between the maximum and minimum values of the gradient profile, and is adjusted in positive and negative according to the gradient sign.

[0120] Then, a nonlinear optimization algorithm such as the damped least squares method is used to iteratively optimize all parameters of the Gaussian first derivative function, aiming to minimize the residual error between the model prediction value and the actual gradient profile data, i.e. . This process continuously adjusts the function parameters to make the theoretical curve best fit the measured profile, thereby accurately determining the sub-pixel center position of the edge.

[0121] After the optimization process converges, the optimized sub-pixel edge center position parameter is extracted from the finally determined Gaussian first derivative function parameters. Then, the sub-pixel edge point position is calculated according to the parameter, which is the edge point coordinate positioned in the normal direction of the current edge with a precision of sub-pixel level. This process is repeated for all edge directions constituting a corner point, and finally all sub-pixel edge points in all directions are collected to form a sub-pixel coordinate set of the edge points corresponding to the reference corner point. This coordinate set provides the most direct data basis for subsequent corner point coordinate purification or high-precision geometric measurement.

[0122] S150, performing linear fitting on the sub-pixel coordinate set of the edge points to obtain a sub-pixel level linear equation, and calculating the intersection point of adjacent linear equations to update the coordinates of the reference corner point;

[0123] This step aims to check, correct and integrate the sub-pixel coordinates obtained based on local edge analysis previously, through global geometric constraints, so as to output a stable, accurate and globally geometrically consistent reference corner point coordinate.

[0124] Further, the sub-pixel coordinate set of the edge point is fitted with a straight line to obtain a sub-pixel level straight line equation, including:

[0125] Outliers are removed from the sub-pixel coordinate set of the edge point by a robust estimation algorithm to obtain an optimal inner point set;

[0126] The optimal inner point set is least square fitted with a straight line to obtain a sub-pixel level straight line equation.

[0127] Due to the influence of local image noise, complex texture or edge detail blur, direct fitting of the sub-pixel coordinate set of the edge point is easily disturbed by outliers, causing deviation of the straight line model. To solve this problem, as shown in Figure 4 The embodiment of the present disclosure first uses a robust estimation algorithm such as RANSAC random sample consensus algorithm to remove outliers.

[0128] Specifically, the straight line model is defined as wherein, and c is a constant. The distance of the sampling point to the straight line is calculated , and the residual threshold is set as the inner point determination criterion. The RANSAC algorithm iteratively finds the optimal inner point set by multiple random sampling, model assumption and consistency verification, thereby effectively filtering out outliers that do not conform to the mainstream straight line model.

[0129] After obtaining the optimal inner point set, accurate straight line fitting is performed to determine the final model parameters (a, b, c). The optimal straight line model can be obtained in two ways: one is to directly perform least square fitting on the optimal inner point set, and the closed-form solution can be obtained by calculating the covariance matrix of the point set and performing eigenvalue decomposition, taking the eigenvector corresponding to the minimum eigenvalue as the direction of the straight line; the second is to use the parameterized representation with the mean value of the point set as the center and the principal direction as the axis, and then convert it to the standard straight line equation form.

[0130] Through the strategy of "robust removal first and accurate fitting later", the embodiment of the present disclosure effectively guarantees that the final obtained sub-pixel level straight line equation has high precision and strong robustness, laying a solid geometric foundation for subsequent refinement of the corner point coordinates by calculating the intersection of straight lines.

[0131] Further, the intersection of adjacent straight line equations is calculated to update the coordinates of the reference corner point, including:

[0132] The cross product of the normal vectors of the adjacent straight lines is calculated;

[0133] When the absolute value of the cross product is greater than a set threshold, the intersection coordinates are calculated and taken as the sub-pixel coordinates of the reference corner point.

[0134] To determine the exact intersection point of the two adjacent straight lines constituting the corner point, the present embodiment first performs intersection stability determination. Let the straight line equations corresponding to the two adjacent edges be and , and the normal vectors thereof be and . The cross product of the two normal vectors is calculated, and the modulus thereof is equivalent to the coefficient determinant Δ composed of the straight line coefficients .

[0135] The modulus value geometrically represents the stability of the intersection of the two straight lines. If , is a positive threshold value approaching zero infinitely, it is determined that the two straight lines are approximately parallel, and there is no stable intersection point, and the current corner point update is abandoned. If , the intersection point coordinates are calculated , wherein , , and the coordinates are taken as the updated sub-pixel coordinates of the current reference corner point.

[0136] S160, projecting the non-reference corner point onto the corresponding straight line to correct the position and generate a final corner point coordinate set.

[0137] This step aims to use the refined reference corner point and the high-precision straight line fitted therefrom to correct the position of other non-reference corner points in the network under geometric constraints, thereby improving the overall accuracy and geometric consistency of the entire corner point network.

[0138] Further, as shown in Figure 5 , the position correction of the non-reference corner point by projecting it onto the corresponding straight line includes:

[0139] S410, for each non-reference corner point, identifying the edge directly connected to the reference corner point;

[0140] S420, projecting the non-reference corner point to the straight line generated by the reference corner point and collinear with the connected edge in the tangent direction parallel to the connected edge to obtain the projection point;

[0141] S430, calculating the coordinate deviation between the non-reference corner point and the projection point;

[0142] S440, when the coordinate deviation meets the preset constraint condition, updating the corner point position using the projection point coordinates.

[0143] For each non-reference corner point to be corrected, the present embodiment first identifies the adjacent corner point directly connected thereto and already precisely positioned as a reference corner point in the corner point network, and further determines the directly connected edge connecting the non-reference corner point and the reference corner point.

[0144] obtaining a sub-pixel straight line equation generated by the reference corner point and collinear with the connected edge and calculating a unit tangent vector of the straight line Taking the tangent direction as the projection path, the non-reference corner point is projected onto the straight line, and the projection point is calculated according to the formula , wherein represents the updated reference corner point coordinate. The operation ensures that the non-reference corner point is corrected to the correct position along the edge direction.

[0145] After obtaining the projection point of the non-reference corner point, the coordinate deviation of the projection point in the X-axis and Y-axis directions of the image coordinate system is calculated To intelligently determine whether updating is needed, the physical length of the connected edge is obtained , and an absolute threshold and a relative threshold are preset, wherein the value range of is 3 to 10 pixels, and the value range of is 2% to 8%. When , it is determined that there is a significant but reasonable deviation in the current position of the non-reference corner point, and the position of the non-reference corner point is updated using the projection point coordinate. If the constraint condition is not met, it indicates that the original position deviation of the corner point may be caused by abnormal factors such as noise, or the deviation is too large to be within the reasonable correction range, so the original coordinate is retained and is not updated.

[0146] For shorter edges (smaller) , the constraint is dominated by the relative term , which avoids allowing too large relative movement due to the shortness of the edge itself, and ensures the rigor of the correction; for longer edges (larger) , the constraint is dominated by the absolute term , which prevents too large correction calculated from a small percentage on a long edge, and enhances the stability of the algorithm.

[0147] Through the introduced adaptive threshold mechanism, the embodiments of the present disclosure improve the geometric consistency of the corner network while effectively avoiding over-correction or false correction, and significantly enhance the robustness and practicality of the algorithm.

[0148] Further, the method further includes a position correction verification step:

[0149] determining whether the projection point is located within the original image;

[0150] When the projection point is out of the range of the original image, the current position correction is rejected.

[0151] After the non-reference corner's theoretical projection point coordinate is calculated by the tangential projection, the embodiment of the present disclosure does not immediately update the corner position with the coordinate, but first performs image boundary check. Specifically, it is judged whether the coordinate of the projection point is within the pixel coordinate range of the original image. Assuming that the effective range of the original image is [0, width] x [0, height], wherein width and height are the width and height of the image (in pixels) respectively. When the calculated projection point coordinate satisfies 0 < x < width and 0 < y < height, it is determined that the projection point is within the range of the original image, and is regarded as a valid projection point, allowing subsequent position updating operation. On the contrary, when the x coordinate or y coordinate of the projection point exceeds the above range, it is determined that the projection point is invalid, and the current position correction request will be rejected by the system, and the coordinate of the non-reference corner will be maintained without updating.

[0152] The verification step effectively prevents the meaningless situation that the inverted and corrected corner coordinate appears outside the image due to projection calculation error, edge straight line extrapolation or serious deviation of the initial corner position, thereby ensuring the spatial validity of the entire corner data set and the stability of subsequent processing, and enhancing the robustness of the algorithm.

[0153] The above-described embodiments only express several embodiments of the present application, and the description is relatively specific and detailed, but it should not be understood as a limitation on the scope of the present patent. It should be noted that for ordinary skilled persons in the art, without departing from the concept of the present application, a number of modifications and improvements can be made, which are all within the protection scope of the present application. Therefore, the protection scope of the present patent should be subject to the appended claims.​​

Claims

1. A method for locating corner points of a QR code, characterized in that, Includes the following steps: Obtain the initial set of corner coordinates from the original image; The region of interest is cropped based on the initial set of corner coordinates, and the region of interest is then enhanced to obtain an enhanced image. A reference corner point is selected from the initial set of corner point coordinates, and multi-radius subpixel sampling is performed on the enhanced image along the edge normal direction of the reference corner point. The gradient profile along the sampling direction is calculated based on the sampling points, and the sub-pixel coordinate set of the edge points is obtained by sub-pixel localization based on the gradient profile. The subpixel coordinate set of the edge points is fitted with a straight line to obtain a subpixel-level straight line equation, and the intersection of adjacent straight line equations is calculated to update the coordinates of the reference corner point; The non-reference corner points are projected onto the corresponding lines for position correction, generating the final set of corner point coordinates.

2. The QR code corner point positioning method according to claim 1, characterized in that, The method further includes: The distortion correction of the region of interest is performed using a camera distortion correction model.

3. The QR code corner point positioning method according to claim 1, characterized in that, The image enhancement of the region of interest includes: The region of interest is image restored using a deconvolution algorithm. The restored image is then subjected to a smoothing filter.

4. The QR code corner point positioning method according to claim 1, characterized in that, The multi-radius sub-pixel sampling along the edge normal direction of the reference corner point includes: Determine the adjacent side direction vector and the corresponding edge normal vector of the reference corner point; Set multiple sampling points along the adjacent side direction vector; For each sampling point, candidate points are generated along the edge normal vector direction with different radii; For each candidate point, perform equidistant subpixel sampling along the edge normal vector direction.

5. A QR code corner point positioning method according to claim 4, characterized in that, The calculation of the gradient profile along the sampling direction based on sampling points includes: The sub-pixel grayscale value of each sampling point is calculated using an interpolation method; Based on the subpixel grayscale value, the subpixel gradient components of the sampling point in the image coordinate axis direction are calculated using the difference method; The sub-pixel gradient components are projected onto the corresponding edge normal vectors to obtain their normal gradient projection values. The normal gradient projection values ​​of all sampling points are collected, sorted according to the sampling order, and a gradient profile is formed.

6. The QR code corner point positioning method according to claim 1, characterized in that, The step of obtaining the sub-pixel coordinate set of edge points by sub-pixel localization based on the gradient profile includes: The gradient profile is curve-fitted using the first derivative function of Gaussian; Based on the gradient profile, the parameters of the first-order Gaussian derivative function are initialized, wherein the initial value of the sub-pixel edge center position is set as the position of the extreme point of the gradient profile. The parameters of the function are iteratively optimized using a nonlinear optimization algorithm; The optimized subpixel edge center position is used as the subpixel coordinate of the edge point.

7. A QR code corner point positioning method according to claim 1, characterized in that, The process of obtaining a sub-pixel-level straight line equation by performing a straight line fit on the sub-pixel coordinate set of the edge points includes: The optimal set of interior points is obtained by removing outliers from the sub-pixel coordinate set of the edge points using a robust estimation algorithm. The optimal set of interior points is fitted with a least-squares line to obtain a sub-pixel-level line equation.

8. A QR code corner point positioning method according to claim 7, characterized in that, The least-squares linear fitting of the optimal interior point set is achieved through principal component analysis.

9. A QR code corner point positioning method according to claim 7, characterized in that, The calculation of the intersection point of adjacent line equations to update the coordinates of the reference angle point includes: Calculate the cross product of the normal vectors of adjacent lines; When the absolute value of the cross product is greater than a set threshold, the coordinates of the intersection point are calculated and used as the sub-pixel coordinates of the reference corner point.

10. A QR code corner point positioning method according to claim 1, characterized in that, The step of projecting non-reference corner points onto the corresponding straight line for position correction includes: For each non-reference corner point, identify the edge that is directly connected to the reference corner point; The non-reference corner point is projected onto a straight line generated by the reference corner point and collinear with the connected edge, using the tangent direction parallel to the connected edge as the projection path, to obtain its projection point. Calculate the coordinate deviation between the non-reference corner point and the projected point; When the coordinate deviation meets the preset constraint conditions, the corner point position is updated using the projection point coordinates.

11. A QR code corner point positioning method according to claim 10, characterized in that, The preset constraint is as follows: , in, This represents the deviation of the horizontal axis. This represents the deviation of the ordinate. For absolute threshold, This is a relative threshold. This corresponds to the edge length.

12. A QR code corner point positioning method according to claim 11, characterized in that, The method further includes a position correction verification step: Determine whether the projection point is located within the original image; If the projected point is outside the range of the original image, the current position correction is rejected.