Specific embodiment
The following will be combined with the accompanying drawings in the embodiment of the present invention, the technical solution in the embodiment of the present invention is clearly and completely described, obviously, the described embodiment is only a partial embodiment of the present invention, not all embodiments. Based on embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without performing inventive work fall within the scope of protection of the present invention.
The present specification provides a method operation steps as described in embodiments or flowcharts, but based on routine or uncreative labor may include more or fewer operation steps. In the actual system or server product execution, may be executed sequentially or in parallel according to the method shown in the embodiment or the accompanying figure (e.g., parallel processor or multithreaded environment).
FIG. 1 is a flow chart of the step of the linear fitting method of the first point cloud data provided by an embodiment of the present invention. The method can include the following steps:
Step 101: Obtain the end point data of the first line segment point cluster to be connected and the start data of the second line segment point cluster to obtain the first point data and the second point data.
For point cloud data with a large number of points or complex linear features, in order to improve the accuracy of linear fitting, the point cloud data is segmented first, and then each sub-segment is fitted separately to obtain multiple line segment point clusters. In order to comprehensively express the geometry of the surface of the object, it is also necessary to further connect multiple line segment point clusters.
The first segment point cluster and the second segment point cluster are two subsegments of multiple subsegments divided into the original point cloud data, and it is currently necessary to smoothly connect the first segment point cluster and the second segment point cluster by linear fitting.
The position of the first segment cluster is in front of the second segment point cluster. Get the coordinates of the point data located at the end of the first segment point cluster, that is, the end point data, and get the coordinates of the point data located at the beginning of the second segment point cluster, that is, the start point data. Use the endpoint data as the first point of data and the starting point data as the second point data.
FIG. 2 is a schematic diagram of the first line segment point cluster and the second line segment point cluster provided by an embodiment of the present invention.
As shown in Figure 2, L1 is the first segment point cluster and L2 is the second segment point cluster. The three-dimensional points P1(x1,y1,z1) and P2(x2,y2,z2) correspond to the plane points A(x1,y1) and B(x2,y2), respectively. Among them, point A is the end point of L1, point B is the starting point of L2, that is, point A(x1,y1) is the first point data, and point B(x2, y2) is the second point data.
Step 102, respectively, obtain the direction vector of the first line segment point cluster at the first point data, the direction vector of the second line segment point cluster at the second point data, the direction vector of the target vector composed of the first point data and the second point data, respectively, to obtain the first direction vector, the second direction vector and the third party vector.
The direction of a line in space is represented by a non-zero vector parallel to the line, which is called a direction vector of the line. The position of a line in space is fully determined by the point in space it passes through and one of its direction vectors.
Here you also need to verify that the first point data and the second point data are the same point, and that both the first point data and the second point data have valid direction vectors. If the first point data and the second point data are the same point, or the first point data or the second point data do not have a valid direction vector, they will exit the solution process.
After determining that neither of the above cases exists, obtain the first direction vector, the second direction vector, and the third direction vector.
Referring to Figure 2, the direction vector of L1 at point A is , the direction vector of L2 at point B is , and the direction vector of the vector
formed by point A and point B is .![]()
![]()
![]()
Among them, x5, y5 are calculated as follows:
(1)
(2)
In this way, the first direction vector, the second direction vector, and the third direction vector![]()
![]()
are obtained.
Step 103, according to the first direction vector, the second direction vector, the third party vector, determine the straightness of the connection segment between the first line segment point cluster and the second line segment point cluster.
Specifically, if the direction of the first direction vector, the second direction vector, and the third-party vector are consistent, the connection segment between the first segment point cluster and the second line segment point cluster is a straight line, and if the direction of the first direction vector, the second direction vector, and the third direction vector are inconsistent, the connecting line segment is a curve.
Step 104, if the coupling segment is a curve, the parametric curve fitting model is used to fit the coupling segment, and the first direction vector and the second direction vector are used as the fitting constraints to obtain the first target connection segment.
If the coupling segment is a curve, the coupling segment needs to be fitted using a curve fitting model. The curve fitting model includes quadratic polynomial function, cubic polynomial function, semi-logarithmic function, Log-Log fitting function, etc., and the most suitable function can be selected as the curve fitting model in this scheme according to the linear characteristics of the point cloud data.
In order to enhance the fitting effect and improve the smoothness of the connection section, the first direction vector and the second direction vector can be used as the fitting constraints, so that the direction change of the connection section is more compatible with the first direction vector and the second direction vector.
Compared with the prior art that only uses the coordinates of the first point data and the second point data to fit the connection section, the first direction vector and the second direction vector are also used as the fitting constraints in this scheme, so that the effect of smooth connection can be achieved in a continuous linear connection.
Step 105, using the first target connection segment to connect the first line segment point cluster and the second line segment point cluster.
After fitting the first target connection segment, the first target connection segment is used to connect the first line segment point cluster and the second line segment point cluster, and the first line segment point cluster, the first target connection segment and the second line segment point cluster form a smooth line segment, which can truly and accurately represent the geometry of the object surface.
In summary, in the embodiment of the present invention, the endpoint data of the first line segment point cluster to be connected and the starting point data of the second line segment point cluster are obtained, and the first point data and the second point data are obtained; The direction vector of the first line segment point cluster at the first point of data, the direction vector of the second line segment point cluster at the second point data, the direction vector of the target vector composed of the first point data and the second point data were obtained respectively, and the first direction vector, the second direction vector and the third direction vector were obtained. According to the first direction vector, the second direction vector and the third direction vector, the curvature of the connection segment between the point cluster of the first line segment and the point cluster of the second line segment is determined. If the connection section is a curve, the parametric curve fitting model is used to fit the connection section, and the first direction vector and the second direction vector are used as the fitting constraints to obtain the first target connection section. Use the first target segment to connect the first segment point cluster and the second segment point cluster. By judging the straightness of the coupling section, this scheme enhances the adaptability of the scheme to linear scenes. Moreover, the proposed scheme adds directional constraints during curve fitting, so that the effect of smooth connection can be achieved in continuous linear connection, so that the fitted line segment can accurately express the geometry of the object surface.
FIG 3 is a flow chart of the steps of the linear fitting method of the second point cloud data provided in an embodiment of the present invention. The method can include the following steps:
Step 201: Obtain the endpoint data of the first line segment point cluster to be connected and the start data of the second line segment point cluster to obtain the first point data and the second point data.
In the embodiment of the present invention, step 201 may refer to step 101, which is not repeated herein.
Step 202, respectively, obtain the first point data, the second point data, the first point data and the second point data of the wiring direction vector, respectively, to obtain the first direction vector, the second direction vector and the third party vector; The first direction vector, the second direction vector, and the third direction vector are all unit vectors.
In the embodiment of the present invention, the unit vector refers to a vector with a modulus equal to 1. Since it is a non-zero vector, the unit vector has a definite orientation.
The first direction vector, the second direction vector, and the third direction vector are all unit vectors, which can facilitate subsequent determination of whether the three direction vectors are on the same straight line.
Step 203, if any two vectors in the first direction vector, the second direction vector, and the third party vector are not equal, the connection segment is determined to be a curve.
Since the first direction vector, the second direction vector, and the third party vector are all unit vectors, all only need to determine whether the three are equal to determine whether the three are on the same straight line, thereby determining whether the connection segment is a curve or a straight line.
If any two vectors of the three are not equal, it means that the three are not in a straight line, then the connection segment is a curve.
As shown in the example in Figure 2, the first direction vector at point A is
, the second direction vector at point B is , the third direction vector corresponding to the vector
is , V1≠ V2 ≠ V3, indicating that the connection section L3 is![]()
a curve.
Step 204, if the coupling segment is a curve, the parametric cubic polynomial is determined as a curve fitting model, the independent variable of the curve fitting model is the distance between the first point data and any point on the coupling segment, and the curve fitting model includes eight fitting parameters.
In the embodiment of the present invention, the parametric cubic polynomial may be expressed as:
(3)
Among them, A1, B1, C1, D1, A2, B2, C2, and D2 are the eight fitting parameters. The independent variable t is the distance between the first point and any point on the coupling section.
, where , that is,
T is the distance between the first point of data and the second point of data. At the first point of data, t=0, and at the second point of data, t=T.
Using a parametric cubic polynomial as a curve fitting model is sufficient for fitting between two points, and can solve the problem that one x coordinate corresponds to multiple y coordinates.
After step 204, you may choose to perform steps 205 - 208, or you may choose to perform steps 209 - 213.
Step 205, determine the first expression corresponding to the curve fitting model at the first point of data, and at the second point of data, the second expression corresponding to the curve fitting model.
Based on the scenario shown in FIG. 2, according to the curve fitting model selected in step 204, a parametric cubic polynomial model is required between points A and B for smooth fitting, so the fitted curve must pass through points A (x1,y1) and B (x2,y2), and the forward directions at points A and B are
respectively
.
Specifically, the coordinates of the first point data are substituted into the curve fitting model to obtain the first expression, and the coordinates of the second point data are substituted into the curve fitting model to obtain the second expression.
The first point data A(x1,y1) and t=0 are substituted into the curve fitting model to obtain the first expression:
(4)
Substituting the second point data B(x2,y2) and t=T into the curve fitting model to obtain the second expression:
(5)
Step 206, according to the curve at the first point of data to fit the partial derivative of the model is the first direction vector, the second point data at the curve fitting model of the partial derivative is the second direction vector, the first constraint and the second constraint are obtained.
The partial derivative of the curve-fitting model at the first point of data is the first direction vector, as follows:
(6)
The partial derivative of the curve-fitting model at the second point of data is the second direction vector, as follows:
(7)
Equations (6) and (7) above are the first and second constraints, respectively.
Step 207, according to the first expression, the second expression, the first constraint and the second constraint determine the values of the eight fitted parameters.
By combining the equations of the first expression, the second expression, the first constraint and the second constraint, the values of the eight fitted parameters A1, B1, C1, D1, A2, B2, C2, and D2 can be obtained.
Step 208, according to the values of the eight fitting parameters to determine the first target connection segment.
After obtaining the values of the eight fitted parameters, substitute them into equation (3) to obtain the expression of the first target connection segment.
Step 209, set the first length adjustment parameter for the first direction vector, and set the second length adjustment parameter for the second direction vector.
In order to enhance the generalization ability of the curve fitting model of this scheme to adapt to multi-scene fitting, the parameter adjustment coefficient is set to change the length of the direction vector at the first point of data and the second point of data. Specifically, the first length adjustment parameter is set for the first direction vector, and the second length adjustment parameter![]()
is set for the second direction vector.
Thus, the first adjustment vector of the direction vector at point A is , and the second adjustment vector of the direction vector at point B is
.![]()
Thus, according to the unit vector of the first direction, the first relationship between the first length adjustment parameter and the abscissa and ordinate of the first point data is obtained; According to the second direction vector as the unit vector, the second relationship between the second length adjustment parameter and the abscissa and ordinate of the second point data is obtained.
The first and second direction vectors are unit vectors, then there are:
(8)
According to Equation (8), the first and second relations can be obtained as follows:
(9)
It can be seen from the first and second relations that the first and second direction vectors are converted from constants to variables due to the addition of length adjustment parameters.
Step 210, according to the partial derivative of the curve fitting model at the first point of data, is the product of the first direction vector and the first length adjustment parameter, and the third constraint is obtained.
At the first point of data, t=0, the partial derivative of the curve fitting model at the first point of data is the product of the first direction vector and the first length adjustment parameter, and the third constraint is as follows:
(10)
Step 211, according to the partial derivative of the curve fitting model at the second point of data, is the product of the second direction vector and the second length adjustment parameter, and the fourth constraint is obtained.
At the second point of data, t=T, the partial derivative of the curve fitting model at the second point of data is the product of the second direction vector and the second length adjustment parameter, and the fourth constraint is as follows:
(11)
Step 212, according to the first expression, the second expression, the third constraint and the fourth constraint are fitted to the coupling segment.
By combining the first expression, the second expression, the third constraint and the fourth constraint, the values of the eight fitted parameters A1, B1, C1, D1, A2, B2, C2, and D2 can be obtained. Thereinto:
(12)
Step 213: Determine the first target connection segment according to the values of the eight fitting parameters.
Substituting these eight values into equation (5) yields the first target connection segment.
In one possible embodiment, the first length adjustment parameter is set for the first direction vector, and the second length adjustment parameter is set for the second direction vector, comprising:
According to the radius of curvature of the desired first target connection segment, the value of the first length adjustment parameter of the first direction vector and the value of the second length adjustment parameter of the second direction vector are set.
In an embodiment of the present invention, after a plurality of tests, the results show that the first length adjustment parameter and the second length adjustment parameter will have an impact on the curvature of the first coupling segment.
FIG 4 (a) is a schematic diagram of the effect of the length of an endpoint direction vector on curve fitting provided by an embodiment of the present invention. FIG 4(b) is a schematic diagram of the effect of the length of an endpoint direction vector on curve fitting provided for an embodiment of the present invention.
As shown in Fig. 4(a) and Fig. 4(b), when the first adjustment vector at point A is V4 and the second adjustment vector at point B is V2, the first target connection segment is curve L4; When the first adjustment vector at point A is V1 and the second adjustment vector at point B is also V2, the first target connection segment is curve L3, where V4 and V1 are parallel in the direction. When the length of V4 is greater than the length of V1, it can be seen from Figure 4(a) that curve L4 is more convex at endpoint A than curve L3; When the length of V4 is less than the length of V1, it can be seen from Figure 4(b) that curve L3 is more convex at endpoint A than curve L4. It follows that the curvature of the curve of the first target junction is proportional to the length of the first length adjustment parameter corresponding to the start endpoint. Through similar experiments, the influence of the second length adjustment parameter corresponding to the termination node on the curvature of the curve of the first target coupling section can also be obtained.
Therefore, as long as the appropriate first length adjustment parameters and second length adjustment parameters are calculated according to the feature extraction and solution of the fitted scene, the fitting curve with suitable curvature can be generated, so the linear fitting method with length adjustment parameters has stronger adaptability and generalization ability for multiple scenes.
Step 214, using the first target connection segment to connect the first line segment point cluster and the second line segment point cluster.
In the embodiment of the present invention, step 214 may refer to step 105, which is not repeated herein.
In summary, in the embodiment of the present invention, in the scenario of linear fitting between two points of endpoint coordinates and direction constraints, the comparison of the direction vector composed of two points and the direction vector of the two endpoints themselves determines whether the two points are straight lines or curves or abnormal exits, which provides a reference for the subsequent selection of the fitting model.
Moreover, on the basis of the curve fitting model, the constraints of the endpoint coordinates and direction vector are added, so that the curve fitting connection between the two points is smoother.
In addition, on the basis of the curve fitting model, a curve fitting method with length adjustment parameters based on endpoint and direction constraints is proposed, which enhances the adaptability and generalization ability of the scheme to multiple scenarios by increasing the length adjustment parameters.
FIG 5 is a step flow chart of a linear fitting method for the third point cloud data provided by an embodiment of the present invention. The method can include the following steps:
Step 301: Obtain the endpoint data of the first line segment point cluster to be connected and the start data of the second line segment point cluster, and obtain the first point data and the second point data.
In the embodiment of the present invention, step 301 may refer to step 101, which is not repeated herein.
Step 302, respectively, obtain the first point data, the second point data, the first point data and the second point data of the wiring direction vector, respectively, to obtain the first direction vector, the second direction vector and the third party vector; The first direction vector, the second direction vector, and the third direction vector are all unit vectors.
In the embodiment of the present invention, step 302 may refer to step 202, which will not be repeated herein.
Step 303, if the first direction vector, the second direction vector, and the third party vector are all equal, the connection segment is determined to be a straight line.
Since the first direction vector, the second direction vector, and the third party vector are all unit vectors, all only need to determine whether the three are equal to determine whether the three are on the same straight line, thereby determining whether the connection segment is a curve or a straight line.
If the three direction vectors are equal, it means that the three direction vectors are in a straight line, and the connection segment is a straight line.
Step 304, if the connection segment is a straight line, the linear equation containing three parameters is determined as a straight line fitting model.
When it is determined that the connection segment between the start point and the end point is a straight line, select the straight line equation as the straight line fitting model, and the straight line fitting model is as follows:
(13)
Among them, E, F, and G are the three fitting parameters.
Step 305, the linear fitting model is used to fit the connection segment, and the second target connection segment is obtained.
By fitting the straight line by fitting the coordinate values of the first point data and the second point data on the straight line fitting model, the values of the three fitting parameters can be obtained, and the values of the three fitted parameters are substituted into the equation (13) to obtain the second target connection segment.
In one possible embodiment, the fitting of the coupling segment using the straight line fitting model, comprising steps 3051-3054:
Step 3051, when determining that the abscissa of the first point data and the second point data is the same, the line fits the third expression of the model.
Substituting the first data A(x1,y1) and the second data B(x2,y2) into equation (13) yields:
(14)
Subtract the two equations in equation (14) to yield:
(15)
When the abscissa of the first point data is the same as the second point data,
the third expression is obtained from equation (15) as follows:
(16)
Step 3052, when determining that the ordinate of the first point data and the second point data are the same, the line fits the fourth expression of the model.
When the abscissa of the first point data is the same as the second point data,
the fourth expression is obtained from equation (15) as follows:
(17)
Step 3053, when determining that the abscissa and ordinate of the first point data and the second point data are different, the line fits the fifth expression of the model.
When determining that the abscissa and ordinate of the first point data and the second point data are different,
and
the fifth expression is obtained from equation (15) as follows:
(18)
Step 3054, according to the third expression, the fourth expression and the fifth expression, the coupling segment is fitted.
By combining the third expression, the fourth expression, and the fifth expression, the values of the three fitted parameters E, F, and G can be obtained.
Substituting these three values into equation (13) yields a second target coupling segment.
In summary, in an embodiment of the present invention, the first direction vector, the second direction vector, and the third party direction vector are used to determine whether the connection segment is a straight line or a curve, and the judgment method is simple and accurate, which is convenient to use different fitting methods to fit the connection segment later. In the case of determining that the connection segment is a straight line, the linear equation including three fitting parameters is used to fit the fitting efficiency and fitting accuracy.
FIG 6 is a structural block diagram of a linear fitting device for point cloud data provided by an embodiment of the present invention. The device 400 comprises:
Point data acquisition module 401, for obtaining the end point data of the first line segment point cluster to be connected and the start data of the second line segment point cluster, to obtain the first point data and the second point data;
The direction vector acquisition module 402 is configured to obtain the direction vector of the first line segment point cluster at the first point data, the direction vector of the second line segment point cluster at the second point data, the direction vector of the target vector composed of the first point data and the second point data, respectively, to obtain the first direction vector, the second direction vector and the third party vector;
the straightness determination module 403 is configured to determine the straightness of the connection segment between the first segment point cluster and the second line segment point cluster according to the first direction vector, the second direction vector, and the third party vector vector;
The curve fitting module 404 is configured for fitting the coupling segment by using a parametric curve fitting model if the connecting segment is a curve, and the first direction vector and the second direction vector are used as the fitting constraints to obtain the first target connection segment;
The connection module 405 is configured to connect the first segment point cluster and the second segment point cluster using the first target connection segment.
Those skilled in the art can clearly understand that for the convenience and conciseness of the description, the specific working process of the system, device and unit described above may refer to the corresponding process in the embodiment of the foregoing method, and will not be repeated herein.
In an embodiment of the present invention, the first direction vector, the second direction vector, and the third party vector are all unit vectors.
In an embodiment of the present invention, the straightness determination module is specifically used for:
If the first direction vector, the second direction vector, and the third direction vector are all equal, the connection segment is determined to be a straight line;
If any two vectors in the first direction vector, the second direction vector, and the third direction vector are not equal, the connection segment is determined to be a curve.
In an embodiment of the present invention, the curve fitting module is specifically used for:
The parametric cubic polynomial is determined as a curve fitting model, the independent variable of the curve fitting model is the distance between the first point data and any point on the connecting segment, and the curve fitting model includes eight fitting parameters;
determine the first expression corresponding to the curve-fitting model at the first point data, and at the second point data, the second expression corresponding to the curve-fitting model;
The partial derivative of the curve-fitting model according to the first point data is the first direction vector, and the partial derivative of the curve fitting model at the second point data is the second direction vector, and the first constraint and the second constraint are obtained;
determine the values of the eight fitted parameters according to the first expression, the second expression, the first constraint and the second constraint;
The first target connection segment is determined according to the values of the eight fitting parameters.
In an embodiment of the present invention, the apparatus further comprises:
The linear fitting model determination module is used to determine the linear equation containing three parameters as a linear fitting model if the connecting segment is a straight line;
The linear fitting module is used to fit the connecting segment using the linear fitting model to obtain the second target connecting segment.
In the embodiment of the present invention, the straight line fitting module is specifically used for:
When determining that the abscissa of the first point data and the second point data is the same, the third expression of the straight line fitting model;
When determining that the ordinate of the first point data and the second point data are the same, the fourth expression of the straight line fitting the model;
When determining that the abscissa and ordinate of the first point data and the second point data are different, the fifth expression of the straight line fitting model;
According to the third expression, the fourth expression, and the fifth expression, the coupling segment is fitted.
In an embodiment of the present invention, the curve fitting module is specifically used for:
The parametric cubic polynomial is determined as a curve fitting model, the independent variable of the curve fitting model is the distance between the first point data and any point on the connecting segment, and the curve fitting model includes eight fitting parameters;
set the first length adjustment parameter for the first direction vector and the second length adjustment parameter for the second direction vector;
According to the partial derivative of the curve fitting model at the first point data, the product of the first direction vector and the first length adjustment parameter is obtained;
According to the partial derivative of the curve fitting model at the second point data, the product of the second direction vector and the second length adjustment parameter is obtained;
determine the values of the eight fitted parameters according to the first expression, the second expression, the third constraint and the fourth constraint;
The first target connection segment is determined according to the values of the eight fitting parameters.
In an embodiment of the present invention, the curve fitting module is further used for:
According to the radius of curvature of the desired first target connection segment, the value of the first length adjustment parameter of the first direction vector and the value of the second length adjustment parameter of the second direction vector are set.
In yet another embodiment provided by the present invention, the device also provides a device comprising a processor and a memory, the memory type stores at least one instruction, at least one program, code set or instruction set, said at least one instruction, at least one piece of the program, the code set or instruction set is loaded and executed by the processor to achieve a linear fitting method of point cloud data described in the embodiment of the present invention.
In yet another embodiment provided by the present invention, a computer-readable storage medium is also provided in which at least one instruction, at least one program, code set or instruction set is stored, and at least one instruction, at least one program, said code set or instruction set is loaded and executed by the processor to achieve a linear fitting method of point cloud data described in embodiments of the present invention.
In the above embodiments, may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loading and executing the computer program instructions on the computer, the process or function described in accordance with the embodiment of the present invention is produced in whole or in part. The computer may be a general-purpose computer, a special computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website site, computer, server or data center via wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) to another website site, computer, server or data center. The computer-readable storage medium may be any usable medium that the computer can access or a server, data center and other data storage device containing one or more available media integration. The available media may be magnetic media, (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., DVDs), or semiconductor media (e.g., solid state disk (SSD)) and the like.
It is important to note that in this article, relational terms such as first and second, etc. are used only to distinguish one entity or operation from another, without necessarily requiring or implying any such actual relationship or order between these entities or operations. Further, the terms "comprise", "comprise" or any other variation thereof are intended to cover non-exclusive inclusions such that a process, method, article or apparatus comprising a range of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such processes, methods, articles or equipment. Without further limitation, the elements qualified by the statement "including a..." do not exclude the existence of other identical elements in the process, method, article or apparatus comprising said elements.
Each embodiment in this specification is described in a relevant manner, and the same similar parts between each embodiment can refer to each other, and each embodiment focuses on the difference from other embodiments. In particular, for system embodiments, because it is basically similar to the method embodiment, the description is relatively simple, and the relevant points can be referred to the partial description of the method embodiment.
The foregoing is only a preferred embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modification, equivalent substitution, improvement, etc. made within the spirit and principles of the present invention is included in the scope of protection of the present invention.