Free-form surface-oriented three-dimensional circle detection method
Technical Field
The invention belongs to the technical field of three-dimensional visual detection, and particularly relates to a free-form surface-oriented three-dimensional circle detection method.
Background
In the field of manufacturing high-end equipment such as aerospace, automobiles and the like, the identification and detection of round holes on free curved surfaces are widely applied to typical application scenes such as automatic hole making, drilling and riveting, stringer positioning and assembling and the like. The number of round holes in the typical application scene is numerous, for example, the number of rivet holes in an airplane can reach millions, and the rivet holes are distributed on various curved surfaces, so that the aircraft has various sizes. However, manual detection is inefficient, prone to missed detection, and costly. In contrast, the automatic detection has the advantages of modularization, intelligence, traceability and the like, and can further meet the requirements of the aviation manufacturing in the new era on high quality, high efficiency and low cost. Accurate curved surface round hole location is crucial to automated production, and it provides key data for equipment such as robot, arm, and the work piece is handled to suitable position to help its accurate discernment to improve production efficiency.
The round hole positioning method is mainly divided into two types of image round hole positioning and point cloud round hole positioning. Although the image circular hole positioning technology is mature, the normal vector and depth information in the three-dimensional space cannot be directly acquired due to limitation to two-dimensional image information, so that the applicability of the image processing technology in certain application scenes requiring the normal vector and the depth information is limited. In contrast, the point cloud circular hole positioning technology can provide richer spatial information and more spatial sensing and attitude control capability for the operation of the mechanical arm.
The round hole positioning technology can be further divided into a traditional algorithm and a deep learning method. While conventional algorithms rely on manually designed features and rules, deep learning algorithms are trained with a large amount of annotation data. However, it is relatively difficult to obtain large-scale annotation data in an industrial scene, and there are problems such as insufficient real-time performance. The existing traditional point cloud round hole positioning method is mainly aimed at point clouds on a plane, because the plane point clouds are relatively simple and dominant in many industrial scenes. However, in certain industrial scenarios, such as automotive manufacturing and aerospace, complex curved surfaces are often encountered that are not planar, and existing algorithms cannot be applied directly. These complex surfaces require more complex and flexible algorithms to process and analyze.
Based on the above, the invention provides a free-form surface-oriented three-dimensional circle detection method.
Disclosure of Invention
Aiming at the technical problems, the invention provides a free-form surface-oriented three-dimensional circle detection method.
The technical scheme adopted for solving the technical problems is as follows:
A free-form surface-oriented three-dimensional circle detection method, the method comprising the steps of:
S100: qu Miandian cloud data are obtained, and a normal vector-guided rolling ball method is applied to the point cloud data so as to extract the point cloud boundary outline of the curved circular hole;
s200: performing European clustering-based boundary segmentation on the point cloud boundary profiles to obtain clustering results of all the boundary point clouds, wherein the clustering results are a plurality of round hole profiles;
s300: carrying out a density-based weighted iterative algorithm on each circular hole contour to obtain a curved surface circular hole normal vector;
S400: and projecting the curved circular hole to a plane along the normal vector of the curved circular hole, and performing circular hole iterative fitting based on the solution of an overdetermined equation on the projected circular hole point cloud to obtain final positioning information.
Preferably, S100 includes:
s110: for finite point clouds By the following constitutionIndividual points, from a set of pointsAny point in (3)Beginning, search andNearest neighborAdjacent points are calculated, and local planes in the least square sense of the points are calculatedPlane, planeIs expressed as the normal vector of (2)HandleAs a means ofNormal vector of the point;
s120: at the same time Is preset as the center of a circleNeighbor point set for radiusIn, takeOne point outsideCalculated outAndTwo points and the center of a circle passes through the planeAt the same time have a radius ofIs a ball of (2)The calculated coordinates of the sphere center are;
S130: computing a neighborhood point setOther points inTo the center of sphereDistance of (2),If all ofAre all larger thanTherefore, if there is no other point in the ball, thenFor boundary points, save, otherwise repeat S120 to S130 untilAll the points in the model are judged to be completed;
s140: set of pairs of points Repeating S120-S140 until all the remaining points in (1)All the points in (a) are judged to be completed.
Preferably, set in S120The following should be satisfied: radius of radiusIs larger than the point cloud resolutionIs smaller than the radius of the round hole to be identifiedThe method comprises the following steps:。
Preferably, the sphere center obtained in S120 has two values, one inward and one outward, specifically:
;
Wherein, Is thatNormal vector of the point; vector quantity;Is thatAndThe distance between, i.eWhereinRepresenting the 2 norms of the vectors;。
preferably, S300 includes:
s310: and (3) density weighting: for a certain point cloud set ,The three-dimensional coordinate data isCalculate each pointAverage value of distances between adjacent points as one rowWeight vector of columnNormalizing the obtained weight vector, i.e.WhereinRepresenting vectorsNorm, making the sum of the norms 1;
S320: removing centroid: point cloud collection And weight vectorIs multiplied by the transpose of (2) to obtain the centroidFor a pair ofEach of which is subtractedTo remove centroid to obtain new product;
S330: calculating covariance matrixFor a pair ofSingular value decomposition is carried out, eigenvalues and eigenvectors of a covariance matrix are obtained, and eigenvectors corresponding to the minimum eigenvalues are extractedThen the normal vector isThe plane equation isWhereinThen calculate the distance between the data point and the plane to obtain the residual error;
S340: calculating the current total costI.e.And calculates the difference between the current cost and the last cost;
S350: parameter updating: will beCorresponding point reservations less than the scale parameter a, updating residualsAnd updating the weight W by using an SA-Cauchy weight function, wherein the calculation formula is as followsThen updating the scale parameters,WhereinScaling the value for the algorithm, preparing for the next iteration; if the iteration is the first iteration, taking the maximum value of the residual Re as a scale parameter a;
s360: repeating S310-S350 until the cost is poor Less than a preset first threshold orIs smaller than a preset second threshold value, outputsNamely, the normal vector of the curved circular hole.
Preferably, S400 includes:
S410: normal vector of curved round hole The plane equation isWherein the coordinates of the point to be projectedBarycenter coordinatesProjecting all points to the plane to obtain projection point coordinatesThe projection formula isOrigin cloud coordinates,WhereinRepresenting the 2 norms of the vectors;
s420: because the perpendicular bisector of any two point connecting lines on the circular arc is required to pass through the circle center, the circle center coordinate can be calculated by solving the linear equation set :
Wherein the method comprises the steps ofRefers to the vector distance of any two points,,Refers to the difference between the x-axis coordinates of the jth point and the ith point,Refers to the difference between the y-axis coordinates of the jth point and the ith point,Refers to the difference in z-axis coordinates between the jth point and the ith point,,,;
,;
S430: after the circle center coordinates are obtained, traversing the point cloud data, and calculating the distance from each point to the circle centerThe average distance obtained is taken as the radius of the circle, and the calculation formula is as follows: wherein the center coordinates Obtaining positioning information;
S440: in order to reduce fitting errors, iteration is carried out on the fitting circle, when a preset end condition is reached, iteration is stopped, and the final positioning information is the final fitting result.
Preferably, S440 is specifically:
Calculating the distance from each point to the fitting circle Judging when it isGreater than a set thresholdDeleting the point until all the point judgment is completed;
fitting the circle again with the remaining points until the difference between the two fitting radii Less than a set thresholdOr the number of iterationsLess than a set thresholdStopping iteration and finally positioning informationI.e., the final fitting result, wherein,Represent the firstThe resulting radius is fitted once.
The three-dimensional circle detection method for the free curved surface is not only suitable for plane point cloud data, but also can process non-plane complex curved surfaces, has strong universality and applicability, can cope with curved surfaces with different shapes, curvatures and surface characteristics, and is suitable for circular hole recognition and detection tasks in various industrial scenes; the convex hull of Qu Miandian cloud round holes is extracted by a normal vector-oriented rolling ball method, and meanwhile, the normal vector of a curved surface is considered, so that the point cloud boundary extracted by the normal vector-oriented rolling ball method is closer to the actual boundary of the round holes, a reliable basis is provided for the subsequent round hole positioning and fitting, and outliers at the detail positions can be filtered out by a density/distance-weighted curved surface round hole iterative fitting algorithm, so that the round hole positioning precision is further improved; in order to further reduce the influence of outliers on three-dimensional circle fitting, a density/distance weighted curved surface round hole iterative fitting algorithm is provided, and the anti-noise capability of the algorithm is improved in two aspects: firstly, when determining the normal vector of the round hole, adopting density weighting and distance iteration to filter the outlier, secondly, in order to further reduce the influence of the outlier on the circle fitting, carrying out iteration when fitting the round hole, and improving the positioning accuracy.
Drawings
FIG. 1 is a flow chart of a method for detecting a three-dimensional circle oriented to a free-form surface according to an embodiment of the invention;
FIG. 2 is a diagram of input point cloud data according to an embodiment of the present invention;
FIG. 3 is a graph showing the outline of a circular hole according to an embodiment of the present invention;
FIG. 4 is a graph showing the clustering segmentation result of circular holes according to an embodiment of the present invention;
FIG. 5 is a graph showing the result of positioning a circular hole according to an embodiment of the present invention;
FIG. 6 is a graph showing the error of the radius of the circular hole positioning in an embodiment of the present invention;
FIG. 7 is a diagram of a circular hole positioning vector error result according to an embodiment of the present invention.
Detailed Description
In order to make the technical scheme of the present invention better understood by those skilled in the art, the present invention will be further described in detail with reference to the accompanying drawings.
In one embodiment, as shown in fig. 1, a method for detecting a three-dimensional circle oriented to a free-form surface includes the following steps:
S100: qu Miandian cloud data are obtained, and a normal vector-guided rolling ball method is applied to the point cloud data so as to extract the point cloud boundary outline of the curved circular hole;
s200: performing European clustering-based boundary segmentation on the point cloud boundary profiles to obtain clustering results of all the boundary point clouds, wherein the clustering results are a plurality of round hole profiles;
s300: carrying out a density-based weighted iterative algorithm on each circular hole contour to obtain a curved surface circular hole normal vector;
S400: and projecting the curved circular hole to a plane along the normal vector of the curved circular hole, and performing circular hole iterative fitting based on the solution of an overdetermined equation on the projected circular hole point cloud to obtain final positioning information.
In one embodiment, S100 comprises:
s110: for finite point clouds By the following constitutionIndividual points, from a set of pointsAny point in (3)Beginning, search andNearest neighborAdjacent points are calculated, and local planes in the least square sense of the points are calculatedPlane, planeIs expressed as the normal vector of (2)HandleAs a means ofNormal vector of the point;
further, as shown in fig. 2, the input point cloud data in this embodiment is 199909 point cloud data, and the radius of the circular hole is the same as that of the input point cloud data 2.5Mm;
s120: at the same time Is preset as the center of a circleNeighbor point set for radiusIn, takeOne point outsideCalculated outAndTwo points and the center of a circle passes through the planeAt the same time have a radius ofIs a ball of (2)The calculated coordinates of the sphere center are;
S130: computing a neighborhood point setOther points inTo the center of sphereDistance of (2),If all ofAre all larger thanTherefore, if there is no other point in the ball, thenFor boundary points, save, otherwise repeat S120 to S130 untilAll the points in the model are judged to be completed;
s140: set of pairs of points Repeating S120-S140 until all the remaining points in (1)All the points in (a) are judged to be completed.
Specifically, in S130, since there are two solutions for the center of the sphere, and the point on the boundary only satisfies the condition that there are no other points in the outer sphere, only one of the centers satisfies the condition.
In one embodiment, set in S120The following should be satisfied: radius of radiusIs larger than the point cloud resolutionIs smaller than the radius of the round hole to be identifiedThe method comprises the following steps:。
specifically, the ball radius is set ,The larger the ball radius, the larger the number of identified boundary points; arranged in a way ofThe following should be satisfied: radius of radiusIs larger than the point cloud resolutionIs smaller than the radius of the round hole to be identifiedThe method comprises the following steps:。 the larger the value, the more points that need to be traversed, the longer the boundary recognition process will be, Too small a value may result in the ball radius not being able to connect two adjacent points and not being identifiable.
In this embodiment, the radius of the ball is selectedThe specific process of (2) is as follows: calculated in the example to obtain the point cloud resolutionIs 0.257, select1, And the boundary extraction result is shown in fig. 3. The boundary segmentation result in S200 is shown in fig. 4.
In one embodiment, due to the symmetry of this process, the sphere center found in S120 has two values, one inward and one outward, specifically:
;
Wherein, Is thatNormal vector of the point; vector quantity;Is thatAndThe distance between, i.eWhereinRepresenting the 2 norms of the vectors;。
in one embodiment, S300 includes:
s310: and (3) density weighting: for a certain point cloud set ,The three-dimensional coordinate data isCalculate each pointAverage value of distances between adjacent points as one rowWeight vector of columnNormalizing the obtained weight vector, i.e.WhereinRepresenting vectorsNorm, making the sum of the norms 1;
S320: removing centroid: point cloud collection And weight vectorIs multiplied by the transpose of (2) to obtain the centroidFor a pair ofEach of which is subtractedTo remove centroid to obtain new product;
S330: calculating covariance matrixFor a pair ofSingular value decomposition is carried out, eigenvalues and eigenvectors of a covariance matrix are obtained, and eigenvectors corresponding to the minimum eigenvalues are extractedThen the normal vector isThe plane equation isWhereinThen calculate the distance between the data point and the plane to obtain the residual error;
S340: calculating the current total costI.e.And calculates the difference between the current cost and the last cost;
S350: parameter updating: will beCorresponding point reservations less than the scale parameter a, updating residualsAnd updating the weight W by using an SA-Cauchy weight function, wherein the calculation formula is as followsThen updating the scale parameters,WhereinScaling the value for the algorithm, preparing for the next iteration; if the iteration is the first iteration, taking the maximum value of the residual Re as a scale parameter a;
s360: repeating S310-S350 until the cost is poor Less than a preset first threshold orIs smaller than a preset second threshold value, outputsNamely, the normal vector of the curved circular hole.
Specifically, S310 may reduce a normal vector shift phenomenon due to density unevenness; the purpose of S320 is to make the data mean zero, since the data mean will affect the next covariance matrix, the effect of the origin of the data can be eliminated by de-barycentering, and the data can be simplified; in S350, the algorithm scaling value is set to。
In one embodiment, S400 includes:
S410: normal vector of curved round hole The plane equation isWherein the coordinates of the point to be projectedBarycenter coordinatesProjecting all points to the plane to obtain projection point coordinatesThe projection formula isOrigin cloud coordinates,WhereinRepresenting the 2 norms of the vectors;
s420: because the perpendicular bisector of any two point connecting lines on the circular arc is required to pass through the circle center, the circle center coordinate can be calculated by solving the linear equation set :
Wherein the method comprises the steps ofRefers to the vector distance of any two points,,Refers to the difference between the x-axis coordinates of the jth point and the ith point,Refers to the difference between the y-axis coordinates of the jth point and the ith point,Refers to the difference in z-axis coordinates between the jth point and the ith point,,,;
,;
S430: after the circle center coordinates are obtained, traversing the point cloud data, and calculating the distance from each point to the circle centerThe average distance obtained is taken as the radius of the circle, and the calculation formula is as follows: wherein the center coordinates Obtaining positioning information;
S440: in order to reduce fitting errors, iteration is carried out on the fitting circle, when a preset end condition is reached, iteration is stopped, and the final positioning information is the final fitting result.
In one embodiment, S440 is specifically:
Calculating the distance from each point to the fitting circle Judging when it isGreater than a set thresholdDeleting the point until all the point judgment is completed;
fitting the circle again with the remaining points until the difference between the two fitting radii Less than a set thresholdOr the number of iterationsLess than a set thresholdStopping iteration and finally positioning informationI.e., the final fitting result, wherein,Represent the firstThe resulting radius is fitted once.
Specifically, finally, the original point cloud data and the fitted space circle are drawn, as shown in fig. 5; and the values of the center coordinates, the radius and the normal vector are displayed, the radius error is shown in figure 6, and the normal vector error is shown in figure 7.
Compared with the prior art, the technical scheme of the invention has the following beneficial effects:
1. versatility and applicability. The method is not only suitable for plane point cloud data, but also can process non-planar complex curved surfaces, and has strong universality and applicability. The method can cope with curved surfaces with different shapes, curvatures and surface features, and is suitable for circular hole recognition and detection tasks in various industrial scenes.
2. High precision. The convex hull of Qu Miandian cloud round holes is extracted by a normal vector-oriented rolling ball method, and meanwhile, the normal vector of a curved surface is considered, so that the point cloud boundary extracted by the normal vector-oriented rolling ball method is closer to the actual boundary of the round holes, and a reliable basis is provided for the subsequent round hole positioning and fitting. And meanwhile, the outlier at the detail position can be filtered out based on a density/distance weighted curved surface round hole iterative fitting algorithm, so that the round hole positioning accuracy is further improved.
3. The robustness is strong. In order to further reduce the influence of outliers on three-dimensional circle fitting, a density/distance weighted curved surface round hole iterative fitting algorithm is provided, and the anti-noise capability of the algorithm is improved in two aspects: firstly, when determining the normal vector of the round hole, adopting density weighting and distance iteration to filter the outlier, secondly, in order to further reduce the influence of the outlier on the circle fitting, carrying out iteration when fitting the round hole, and improving the positioning accuracy.
The three-dimensional circle detection method for the free curved surface provided by the invention is described in detail. The principles and embodiments of the present invention have been described herein with reference to specific examples, the description of which is intended only to facilitate an understanding of the core concepts of the invention. It should be noted that it will be apparent to those skilled in the art that various modifications and adaptations of the invention can be made without departing from the principles of the invention and these modifications and adaptations are intended to be within the scope of the invention as defined in the following claims.