Target circle center extraction method based on K-means clustering
By adopting the K-mean clustering optimization method in camera calibration, the problem of inaccurate positioning of the center coordinates of the plane target target of the disc mode is solved and the calculation complexity is high, and real-time monitoring effect with high accuracy and low complexity is achieved.
Patent Information
- Application Number
- CN202411820988.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-11
- Publication Date
- 2025-04-08
- Estimated Expiration
- 2044-12-11
AI Technical Summary
In the prior art, in camera calibration, the target center coordinate positioning of the disc mode plane target is not accurate enough, and the commonly used methods have high computational complexity, making real-time detection difficult.
The target center extraction method based on K-mean clustering is used to fit the elliptical equation of the target circle through the least squares method, and the circle is constructed on the circumference of the ellipse to generate a data point set, and the center coordinates of the target circle are optimized using K-mean clustering.
It improves the extraction accuracy of the coordinates of the center point of the target circle, reduces the calculation complexity, and realizes real-time accurate monitoring, which is suitable for camera calibration and vehicle maintenance and maintenance.
Smart Images

Figure CN119785043A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of camera calibration and vehicle inspection and maintenance, and in particular to a target center extraction method based on K-means clustering. Background Art
[0002] In today's digital world, image acquisition and processing technology has become a core component of computer vision, image analysis, and many other fields. For camera-calibrated four-wheel alignment, the accurate extraction of the coordinate points of the image captured by the camera has become a challenging and crucial task. In this process, the coordinates of the feature points in the image need to be obtained from the target image and optimized through certain techniques to obtain more accurate results.
[0003] At present, the commonly used planar targets for image acquisition are disc mode and chessboard mode. However, because the chessboard mode targets are easily affected by the lighting environment, disc mode planar targets are more commonly used. For disc mode planar targets, the center of the target circle on the target is the feature point that needs to be extracted. The conventional method is to use elliptical Hough transform or least squares fitting to directly obtain the center coordinates of the target circle, but these two methods are not very accurate in positioning. Therefore, some researchers have developed further optimization methods, such as extracting the center coordinates through sliding clustering and caliper clustering methods. However, these methods often rely on a large amount of labeled image data for training, and the high computational complexity will affect the real-time detection of the target, resulting in these methods being unable to be applied in camera calibration and vehicle maintenance and inspection.
[0004] Therefore, there is an urgent need for a target center extraction method that requires little computation, can monitor in real time, and has accurate positioning. Summary of the invention
[0005] In order to solve the above technical problems, the present invention provides a target center extraction method based on K-means clustering. The method first fits the ellipse equation of the target circle by the least squares method, and constructs a circle on the circumference of the ellipse on this basis, and then uses the K-means clustering method to optimize the center coordinates of the target circle according to the distance between the intersection points between the circles on the circumference of the ellipse and the center of the target circle, thereby improving the accuracy of extracting the coordinates of the center point of the target circle.
[0006] In order to solve the above technical problems, the present invention adopts the following technical solutions:
[0007] A target center extraction method based on K-means clustering includes the following steps:
[0008] Step 1: Mark the center of each target circle on the target suitable for K-means clustering optimization;
[0009] Step 2: Determine the initial center coordinates of the target circle: Capture the target image, and after preprocessing, use the ellipse fitting method to preliminarily extract the center coordinates of each target circle on the target in the pixel coordinate system. and the major semiaxis ;
[0010] Step 3, constructing circles on the circumference of the fitted ellipse: starting from 0° on the circumference of the fitted ellipse of each target circle, construct circles with points at intervals of 10° as the center and b as the radius, and construct a total of 36 circles on the circumference of the ellipse;
[0011] Step 4: Construct data point set A: Take all the intersection points of the 36 circles in step 3 as data points, construct data point set A, and calculate the distance between each point in set A and the center of the target circle;
[0012] Step 5: Filter data points: If the distance in step 4 is greater than the preset threshold , then filter out the data point and use the eliminated data point as the new data point set B;
[0013] Step 6: Determine the optimized center coordinates: Use the K-means clustering algorithm to iteratively calculate the data points in set B. Each calculation will get the coordinates of the new cluster center. If the distance between the new cluster center and the previous cluster center is greater than the threshold , the next iteration is performed; otherwise, the updated cluster center is used as the center coordinate of the optimized target circle .
[0014] According to a further technical solution, the target in step one includes a rectangular calibration plate and eight target circles arranged on the calibration plate, four target circles of the same size are arranged symmetrically along the center of the calibration plate on the left and right sides of the calibration plate, and each four target circles are arranged in a regular rhombus shape.
[0015] According to a further technical solution, the distance between adjacent target circles of the eight target circles is greater than the diameter of the target circle.
[0016] In a further technical solution, in the step 2, after the image is collected, the edge of the detected target circle is fitted with an ellipse using the least squares method to obtain an ellipse equation, and it is determined whether the fitted ellipse meets the preset area range. If it does, the initial coordinates of the center of the target circle are determined. and the major semiaxis .
[0017] Further technical solution, in step 4, the calculation formula of the distance between each point in set A and the center of the circle is:
[0018] (Formula 1)
[0019] Where i=1,2,……,n; are the coordinates of the center of the fitted ellipse, Represents a column, Indicates the line; are the coordinates of the intersecting data points, Indicates that it is The column coordinates of the intersection points, Indicates that it is The column coordinates of the intersection points.
[0020] Further technical solution, the specific method of step six is:
[0021] (1) Determine the number of clusters and set the coordinates of the center point of the fitted ellipse As the initial cluster center coordinates;
[0022] (2) First, randomly assign the data points in set B to clusters, calculate the distance between the data points and the cluster center, and in the next iterative calculation, assign the data points to the cluster with the closest distance based on the distance value;
[0023] (3) Update cluster centers: Calculate the average coordinates of all data points in each cluster and use the average coordinates as the updated coordinates of the cluster center;
[0024] (4) Calculate the center moving distance of the cluster: Calculate the distance between the updated cluster center point and the previous cluster center point, which is the center moving distance of the cluster;
[0025] (5) Repeat the above steps (2) to (4) for iterative calculation until the center movement distance of the cluster is less than the threshold , use the updated cluster center coordinates as the optimized circle center coordinates .
[0026] In a further technical solution, in step (2), the distance between the data point and the cluster center is calculated as follows:
[0027] (Formula 2)
[0028] Where i=1,2,…,n; are the coordinates of the cluster center; are the data point coordinates.
[0029] In a further technical solution, the specific calculation method of the coordinates of the updated cluster center in step (3) is as follows:
[0030] For any cluster, suppose the coordinates of the n data points it contains are (P1 x,P1 y )、(P2 x ,P2 y ),……、(Pn x ,Pn y ), then the updated cluster center coordinates are:
[0031] (Formula 3)
[0032] In a further technical solution, the calculation formula for the center moving distance of the cluster in step (4) is:
[0033] (Formula 4)
[0034] in, represents the moving distance of the cluster center, is the updated cluster center coordinate, is the coordinate of the last cluster center point.
[0035] Beneficial Effects
[0036] Compared with the existing known technologies, the technical solution provided by the present invention has the following significant effects:
[0037] (1) The present invention designs a target suitable for K-means clustering optimization. Compared with the existing conventional disk target, when generating a set of data points for K-means clustering, the total number of data points generated by clustering on the improved target is significantly reduced compared with the traditional target, which greatly reduces the computational complexity caused by the huge amount of data in the optimization process, improves the extraction accuracy of the target center point coordinates, and ensures real-time and accurate monitoring. In addition, the target structure is simpler and more practical, and the special shape design can effectively reduce the generation of abnormal data points and further improve the extraction accuracy.
[0038] (2) The target center extraction method based on K-means clustering of the present invention generates a data point set by constructing a circle on the circumference of the target circle, and then establishes a connection between the geometric information of the edge and the coordinates of the center of the circle, thereby realizing the geometric constraints on the positioning of the coordinates of the center of the circle. At the same time, by introducing the K-means clustering optimization method, the purpose of adaptive iterative optimization of the coordinates of the center of the circle is achieved, so that the coordinates of the center point of the target circle finally extracted are more accurate. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1 It is a flow chart of a target center extraction method based on K-means clustering of the present invention;
[0040] Figure 2 Comparison diagrams of circle intersection points obtained using the existing target and the target of the present invention, a is the existing target, b is the target of the present invention;
[0041] Figure 3 Schematic diagram of the structure of the target of the present invention.
[0042] Markings in the figure: 1. Calibration plate, 2. Target circle. DETAILED DESCRIPTION
[0043] In order to further understand the content of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments.
[0044] Example
[0045] like Figure 1 As shown, a target center extraction method based on K-means clustering, firstly extracts the center coordinates and major semi-axis of each target circle in the pixel coordinate system by an ellipse fitting method on a target suitable for K-means clustering optimization; then, 36 circles are constructed on the circumference of the fitted ellipse of each target circle; then, according to the distance relationship between the intersection points between these circles and the center of the target circle, K-means clustering is used to optimize the center coordinates of the target circle, thereby improving the accuracy of extracting the center coordinates of the target circle. The present invention can ultimately determine more accurate center coordinates of the target circle through the optimization method of K-means clustering.
[0046] Specifically, the method comprises the following steps:
[0047] Step 1: Mark the center of each target circle on the target suitable for K-means clustering optimization;
[0048] Step 2: Determine the initial center coordinates of the target circle: Capture the target image, and after preprocessing, use the ellipse fitting method to preliminarily extract the center coordinates of each target circle on the target in the pixel coordinate system. and the major semiaxis ;
[0049] Step 3, constructing circles on the circumference of the fitted ellipse: starting from 0° on the circumference of the fitted ellipse of each target circle, construct circles with points at intervals of 10° as the center and b as the radius, and construct a total of 36 circles on the circumference of the ellipse;
[0050] Step 4: Construct data point set A: Take all the intersection points of the 36 circles in step 3 as data points, construct data point set A, and calculate the distance between each point in set A and the center of the target circle. The specific calculation formula is as follows:
[0051] (Formula 1)
[0052] Where, i=1,2,……,n; is the center coordinate of the fitted ellipse, that is, the center coordinate of the circle, Represents a column, Indicates the line; are the coordinates of the intersecting data points, Indicates that it is The column coordinates of the intersection points, Indicates that it is The column coordinates of the intersection points.
[0053] Step 5: Filter data points: If the distance in step 4 is greater than the preset threshold , then filter out the data point and use the eliminated data point as the new data point set B;
[0054] Step 6: Determine the optimized circle center coordinates: Use the K-means clustering algorithm to iteratively calculate the data points in set B. Each time, the coordinates of the new cluster center are calculated. If the distance between the new cluster center and the previous cluster center is greater than the threshold , the next iteration is performed; otherwise, the updated cluster center is used as the center coordinate of the optimized target circle , the specific steps are as follows:
[0055] (1) Determine the number of clusters and set the coordinates of the center point of the fitted ellipse As the initial cluster center coordinates;
[0056] In K-means clustering, the number of clusters is an important hyperparameter, which is usually determined in advance. This hyperparameter indicates how many clusters you want the algorithm to divide the data into. After determining the number of clusters, you need to determine the initial cluster center points, that is, the cluster center point coordinates. There are as many clusters as there are clusters, where K is the number of cluster centers. Because we want to get the center coordinates of the circle, we use the center point coordinates of the fitted ellipse obtained above as As the initial cluster center coordinates.
[0057] (2) First, randomly assign the data points in set B to clusters, calculate the distance between the data points and the cluster center, and in the next iterative calculation, assign the data points to the cluster with the closest distance based on the distance value; the calculation formula for the distance between the data point and the cluster center is as follows:
[0058] (Formula 2)
[0059] Where, i=1,2...n; are the coordinates of the cluster center; are the data point coordinates.
[0060] Because it is impossible to determine the cluster with the closest distance to the data points in set B at the beginning, a random allocation method is adopted. In subsequent iterative calculations, the nearest allocation is performed according to the calculated distance.
[0061] (3) Update cluster centers: Calculate the average coordinates of all data points in each cluster and use the average coordinates as the updated coordinates of the cluster center. The specific method is as follows:
[0062] For any cluster, assume that the coordinates of the n data points it contains are (P1 x ,P1 y )、(P2 x ,P2 y ),……、(Pn x ,Pn y ), then the updated cluster center coordinates are:
[0063] (Formula 3)
[0064] (4) Calculate the center moving distance of the cluster: Calculate the distance between the updated cluster center point and the previous cluster center point, which is the center moving distance of the cluster. The specific calculation formula is as follows:
[0065] (Formula 3)
[0066] in, represents the moving distance of the cluster center, is the updated cluster center coordinate, Indicates the coordinates of the last cluster center point.
[0067] (5) Repeat the above steps (2) to (4) for iterative calculation until the center movement distance of the cluster is less than the threshold , use the updated cluster center coordinates as the optimized circle center coordinates .
[0068] The target in step 1 includes a rectangular calibration plate 1 and 8 target circles 2 arranged on the calibration plate, and 4 target circles 2 of the same size are arranged symmetrically along the center of the calibration plate on the left and right sides of the calibration plate 1, and every 4 target circles 2 are arranged in a regular rhombus shape; among the 8 target circles, the distance between adjacent target circles is greater than the diameter of the target circle.
[0069] The target of the present invention and the conventional circular target in the prior art are used to collect data, image processing, etc., 36 circles are constructed on the circumference of each target circle of the two targets, and the intersection points of the obtained circles are compared. The results are as follows: Figure 2As shown in the figure, it can be clearly seen that the number of circle intersections in the existing target is greater. It can be seen that the target of the present invention can effectively reduce the number of data points, greatly reduce the calculation complexity caused by the huge amount of data in the optimization process, improve the extraction accuracy of the target circle center point coordinates, and ensure real-time and accurate monitoring. In addition, the target circles of conventional targets are arranged very densely. When constructing circles, the construction circles of adjacent target circles will intersect and generate intersection points. However, these intersection points are invalid and belong to abnormal data points. The special design of the target of the present invention greatly reduces the generation of abnormal data points and further improves the extraction accuracy. At the same time, the existing calibration method requires that after extracting the center coordinates of all target circles, 4 point pairs (the image coordinates of the target circle and the actual plane coordinates are one point pair) are randomly selected from them to perform homography matrix calculation. In the calculation, the 4 points should be avoided from being collinear to ensure linear independence. The special target circle arrangement method of the present invention can effectively avoid the collinearity problem in the linear calculation process, and improve the accuracy of subsequent calibration calculations.
[0070] In the second step, after the image is collected, the edge of the detected target circle is fitted with an ellipse using the least squares method to obtain an ellipse equation, and it is determined whether the fitted ellipse meets the preset area range. If it does, the initial coordinates of the center of the target circle are determined. and the major semiaxis .
[0071] The present invention calculates the average root mean square error and reprojection error of the center coordinates collected by the above method and the conventional least squares method in the joint calibration process of the camera and radar, and judges the accuracy of the target center extraction method based on K-means clustering by comparing the error sizes. The specific results are shown in Tables 1 and 2 below:
[0072] Table 1 Calibration results of the target left deflection
[0073] Method for extracting the center of target circle before calibration Average root mean square error (pixels*1cm / pixel) Average reprojection error (pixel) Least squares method for extracting the center of a circle 1. 74269 1.99738 Circle center extraction method based on K-means clustering 1. 38474 1. 64012
[0074] Table 2 Calibration results of the target right deflection
[0075] Method for extracting the center of target circle before calibration Root mean square error (pixels*1cm / pixel) Average reprojection error (pixel) Least squares method for extracting the center of a circle 1. 72324 1. 99844 Circle center extraction method based on K-means clustering 1.43004 1.65426
[0076] As can be seen from the above table, for the average root mean square error, the method based on K-means clustering of the present invention is lower than the conventional least squares method, and the error value can be reduced by about 17.01%~20.54%, indicating that the deviation between the measured value and the true value is reduced, and it is closer to the actual model. For the average reprojection error, the method based on K-means clustering of the present invention is lower than the conventional least squares method, and the error value can be reduced by about 17.22%~17.89%, indicating that the method of the present invention has high calibration accuracy and higher calibration quality, proving the feasibility and advantages of the present invention.
[0077] The present invention and its embodiments are described schematically above, and the description is not restrictive. The drawings show only one embodiment of the present invention, and the actual structure is not limited thereto. Therefore, if a person skilled in the art is inspired by it and designs a structural method and an embodiment similar to the technical solution without creativity without departing from the purpose of the invention, they shall all fall within the protection scope of the present invention.
Claims
1. A target center extraction method based on K-means clustering, characterized in that: The steps include: Step 1: Mark the center of each target circle on the target suitable for K-means clustering optimization; Step 2: Determine the initial center coordinates of the target circle: Capture the target image, and after preprocessing, use the ellipse fitting method to preliminarily extract the center coordinates of each target circle on the target in the pixel coordinate system. and the major semiaxis ; Step 3, constructing circles on the circumference of the fitted ellipse: starting from 0° on the circumference of the fitted ellipse of each target circle, construct circles with points at intervals of 10° as the center and b as the radius, and construct a total of 36 circles on the circumference of the ellipse; Step 4: Construct data point set A: Take all the intersection points of the 36 circles in step 3 as data points, construct data point set A, and calculate the distance between each point in set A and the center of the target circle; Step 5: Filter data points: If the distance in step 4 is greater than the preset threshold , then filter out the data point and use the eliminated data point as the new data point set B; Step 6: Determine the optimized circle center coordinates: Use the K-means clustering algorithm to iteratively calculate the data points in set B. Each time, the coordinates of the new cluster center are calculated. If the distance between the new cluster center and the previous cluster center is greater than the threshold , then the next iterative calculation is performed; Otherwise, the updated cluster center is used as the center coordinate of the optimized target circle. .
2. The target center extraction method based on K-means clustering according to claim 1, characterized in that: The target in step 1 includes a rectangular calibration plate and 8 target circles arranged on the calibration plate. Four target circles of the same size are arranged symmetrically along the center of the calibration plate on the left and right sides of the calibration plate, and each of the four target circles is arranged in a regular rhombus shape.
3. The target center extraction method based on K-means clustering according to claim 2, characterized in that: The distances between adjacent target circles of the eight target circles are greater than the diameters of the target circles.
4. The target center extraction method based on K-means clustering according to claim 1, characterized in that: In the second step, after the image is collected, the edge of the detected target circle is fitted with an ellipse using the least squares method to obtain an ellipse equation, and it is determined whether the fitted ellipse meets the preset area range. If it does, the initial coordinates of the center of the target circle are determined. and the major semiaxis .
5. The target center extraction method based on K-means clustering according to claim 1, characterized in that: In step 4, the distance between each point in set A and the center of the circle is calculated as follows: (Formula 1) Where i=1,2...n, are the coordinates of the center of the fitted ellipse, Represents a column, Indicates the line; are the coordinates of the intersecting data points, Indicates that it is The column coordinates of the intersection points, Indicates that it is The column coordinates of the intersection points.
6. The target center extraction method based on K-means clustering according to claim 1, characterized in that: The specific method of step six is: (1) Determine the number of clusters and set the coordinates of the center point of the fitted ellipse As the initial cluster center coordinates; (2) First, randomly assign the data points in set B to clusters, calculate the distance between the data points and the cluster center, and in the next iterative calculation, assign the data points to the cluster with the closest distance based on the distance value; (3) Update cluster centers: Calculate the average coordinates of all data points in each cluster and use the average coordinates as the updated coordinates of the cluster center; (4) Calculate the center moving distance of the cluster: Calculate the distance between the updated cluster center point and the previous cluster center point, which is the center moving distance of the cluster; (5) Repeat the above steps (2) to (4) for iterative calculation until the center movement distance of the cluster is less than the threshold , use the updated cluster center coordinates as the optimized circle center coordinates .
7. The target center extraction method based on K-means clustering according to claim 6, characterized in that: In step (2), the distance between the data point and the cluster center is calculated as follows: (Formula 2) Where, i=1,2...n; are the coordinates of the cluster center; are the data point coordinates.
8. The target center extraction method based on K-means clustering according to claim 6, characterized in that: The specific calculation method of the coordinates of the updated cluster center in step (3) is as follows: Any cluster, assuming that it contains The coordinates of the data points are (P1 x ,P1 y )、(P2 x ,P2 y ),……、(Pn x ,Pn y ), then the updated cluster center coordinates are: (Formula 3).
9. The target center extraction method based on K-means clustering according to claim 6, characterized in that: The calculation formula of the center moving distance of the cluster in step (4) is: (Formula 4) in, represents the moving distance of the cluster center, is the updated cluster center coordinate, is the coordinate of the last cluster center point.
Citation Information
Patent Citations
High-precision camera calibration and target attitude estimation method
CN109003309A
Target, information detection method and device, terminal and storage medium
CN115439554A
Four-wheel positioning method based on improved camera calibration
CN118334091A