Cylinder axis detection method and device, electronic equipment and storage medium

By voting and updating the normal in point clouds and updating the fit plane, the problems of low cylindrical axis detection efficiency and misremoval of points in the prior art are solved, and a more efficient and stable detection process is achieved.

CN119850567AActive Publication Date: 2025-04-18FAIR INNOVATION (SUZHOU) ROBOTIC SYSTEM CO LTD

Patent Information

Application Number
CN202411945991.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-27
Publication Date
2025-04-18
Estimated Expiration
2044-12-27

AI Technical Summary

Technical Problem

The existing cylindrical axis detection algorithm needs to detect planes in point clouds and remove points on planes before detection, resulting in some cylindrical surface points being accidentally removed, and the voting process is complicated, the calculation is large, and the efficiency is low.

Method used

By determining the point cloud to be detected, traversing the points in the point cloud, voting on the normal of each point based on the preset rules, building a fitting plane, updating the normal until the number of iterations is reached, and a cylindrical axis is obtained.

Benefits of technology

The calculation amount and time are reduced, the phenomenon of accidentally removing cylindrical surfaces is avoided, and the detection efficiency and stability are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119850567A_ABST
    Figure CN119850567A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a cylinder axis detection method and device, electronic equipment and a storage medium, and relates to the field of point cloud processing, and the method comprises the steps: traversing each point in a point cloud to be detected, voting the normal direction of each point based on a preset rule, obtaining a first voting list, constructing a first array based on each element in the first voting list, and obtaining a second array; based on the voting number, sorting the first array to obtain a second array, constructing a first fitting plane, determining a first plane vector of the first fitting plane, and updating the first array to obtain a new first array, constructing a new first fitting plane based on the new first array and determining a new first plane vector of the new first fitting plane, and when the new first plane vector is unstable, updating the first array and obtaining the new first fitting plane and the new first plane vector of the new first fitting plane until the number of iterations is reached, and the latest first plane vector is obtained as the cylindrical axis, so that the calculation efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of point cloud processing technology, and in particular to a cylindrical axis detection method, device, electronic device and storage medium. Background Art

[0002] The principle of the existing cylinder axis detection algorithm in point cloud is as follows: first detect the plane in the point cloud, then remove the points on the plane, and vote for the axis for the remaining points. The axis voting process is as follows: first perform normal voting, that is, traverse each point in the point cloud to obtain the normal of the point, and calculate the angle combination for the normal Where θ represents the angle between the projection of the normal on the xy plane and the x-axis, Represents the angle between the normal and the z-axis. Voting is performed in the first voting accumulator according to the angle combination. Normals with the same angle combination correspond to the same voting position in the first voting accumulator. Then the first voting accumulator is traversed, and for each normal, a rotation circle is calculated. The rotation circle is obtained by rotating the unit circle on the xy plane. The rotation circle is located on a plane whose normal is the same as the current normal. Then each point on the rotation circle is traversed and voted again. Each point on the rotation circle is a unit vector and also corresponds to an angle combination. Voting is still performed for this angle combination, and the voting result is recorded in the second voting accumulator. Then the extreme value point in the second voting accumulator is found, and the angle combination corresponding to the extreme value point is the direction of the cylinder axis.

[0003] The existing cylinder axis detection algorithm has the following two main problems. (1) Before performing cylinder axis detection, it is necessary to first detect the plane in the point cloud and then remove the points on the plane. For a point cloud with a cylinder, when performing plane detection, the points on the cylindrical surface are sometimes detected as points on the plane. At this time, if the points on the plane are removed, the points on the cylindrical surface will also be removed, resulting in a decrease in the number of points on the cylindrical surface. (2) The voting process is complex and the amount of calculation is large. From the above detection process, a total of two votes are required. The first is to vote for the normal of each point in the point cloud, and the second is to vote for each point on the rotating circle. Since each normal in the first voting accumulator corresponds to a rotating circle, and the rotating circle itself has 360 points, the number of votes required by the second voting accumulator is 360n, where n represents the number of voting positions in the first voting accumulator. Therefore, the number of votes in the second voting accumulator is large, and the calculation time is long, which makes the existing cylinder detection algorithm computationally inefficient. Summary of the invention

[0004] The purpose of this application is to provide a cylindrical axis detection method, device, electronic device and storage medium, which can improve the detection efficiency of the cylindrical axis.

[0005] In order to achieve the above purpose, the technical solution adopted in the embodiment of the present application is as follows:

[0006] In a first aspect, an embodiment of the present application provides a method for detecting a cylindrical axis, the method comprising:

[0007] Determine a point cloud to be detected, wherein the point cloud to be detected contains only one cylinder;

[0008] Traversing each point in the point cloud to be detected, voting on the normal of each point based on a preset rule, and obtaining a first voting list, wherein the first voting list includes each voting position and the number of votes corresponding to each voting position;

[0009] Based on each element in the first voting list, construct a first array, wherein the first array includes a normal direction and a number of votes for each element;

[0010] Based on the number of votes, sorting the first array to obtain a second array;

[0011] constructing a first fitting plane based on the second array and determining a first plane vector of the first fitting plane;

[0012] Update the first array based on the first plane vector to obtain a new first array;

[0013] constructing a new first fitting plane based on the new first array and determining a new first plane vector of the new first fitting plane;

[0014] When the new first plane vector is unstable, return to the step of updating the first array based on the first plane vector to obtain a new first array to construct a new first fitting plane based on the new first array and determine a new first plane vector of the new first fitting plane until the number of iterations is reached, and obtain the latest first plane vector as the cylinder axis.

[0015] In an optional implementation, the step of traversing each point in the point cloud to be detected and voting on the normal of each point based on a preset rule to obtain a first voting list includes:

[0016] Traversing each point in the point cloud to be detected, and determining the coordinates and normal of the point;

[0017] Calculate a first angle and a second angle based on the normal, wherein the first angle is the angle between the projection of the normal on the xy plane and the x-axis, and the second angle is the angle between the normal and the z-axis;

[0018] Calculating the voting position of the point based on the first angle and the second angle;

[0019] determining whether the first voting list contains the voting position of the point;

[0020] If so, increase the number of votes for the voting position at that point by one;

[0021] If not, the voting position of the point is stored in the first voting list, and the number of votes for the voting position of the point is set to 1.

[0022] In an optional implementation, the step of calculating the first angle and the second angle based on the normal direction includes:

[0023] Determining an x-axis component and a z-axis component of the normal;

[0024] Calculate a first angle based on the x-axis component and the z-axis component;

[0025] A second angle is calculated based on the z-axis component.

[0026] In an optional implementation manner, the step of constructing a first array based on each element in the first voting list includes:

[0027] Traversing each element in the first voting list to determine the voting position of the element and the number of votes for the voting position;

[0028] Based on the voting position, calculating a third angle and a fourth angle;

[0029] Based on the third angle and the fourth angle, obtaining a first normal direction of the voting position;

[0030] A first array is constructed based on the number of votes and the first normal.

[0031] In an optional implementation, the step of constructing a first fitting plane based on the second array and determining a first plane vector of the first fitting plane includes:

[0032] Acquire a preset number of target elements in the first order of the second array to construct a first fitting plane;

[0033] Calculate a covariance matrix based on the target element;

[0034] Based on the covariance matrix, an eigenvector of a minimum eigenvalue is determined as a first plane vector of the first fitting plane.

[0035] In an optional implementation, the step of updating the first array based on the first plane vector to obtain a new first array includes:

[0036] Calculating the distances between all normal directions in the first array and the first fitting plane;

[0037] Based on the distances, the first array is updated to obtain a third array;

[0038] The third array is sorted from small to large according to the distance to obtain a new first array.

[0039] In an optional embodiment, when the new first plane vector is unstable, returning to the step of updating the first array based on the first plane vector to obtain a new first array to the step of constructing a new first fitting plane based on the new first array and determining a new first plane vector of the new first fitting plane until the number of iterations is reached, and obtaining the latest first plane vector as the cylinder axis, includes:

[0040] Determine the second plane vector calculated in the last iteration;

[0041] Calculating a fifth angle between the second plane vector and the new first plane vector;

[0042] When the fifth angle is greater than a preset threshold, it is determined that the new first plane vector is unstable;

[0043] Return to the step of updating the first array based on the first plane vector to obtain a new first array to construct a new first fitting plane based on the new first array and determine a new first plane vector of the new first fitting plane, until the number of iterations is reached, and obtain the latest first plane vector as the cylinder axis.

[0044] In a second aspect, an embodiment of the present application provides a cylindrical axis detection device, the device comprising:

[0045] A determination module, used for determining a point cloud to be detected, wherein the point cloud to be detected contains only one cylinder;

[0046] A voting module, used for traversing each point in the point cloud to be detected, voting on the normal of each point based on a preset rule, and obtaining a first voting list, wherein the first voting list includes each voting position and the number of votes corresponding to each voting position;

[0047] A construction module, configured to construct a first array based on each element in the first voting list, wherein the first array includes a normal direction and a number of votes of each element;

[0048] The determination module is also used to sort the first array based on the number of votes to obtain a second array; construct a first fitting plane based on the second array and determine a first plane vector of the first fitting plane; update the first array based on the first plane vector to obtain a new first array; construct a new first fitting plane based on the new first array and determine a new first plane vector of the new first fitting plane; when the new first plane vector is unstable, return to execute the steps of updating the first array based on the first plane vector to obtain a new first array to constructing a new first fitting plane based on the new first array and determining a new first plane vector of the new first fitting plane, until the number of iterations is reached, and obtain the latest first plane vector as the axis of the cylinder.

[0049] In a third aspect, an embodiment of the present application provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the cylindrical axis detection method when executing the computer program.

[0050] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which implements the steps of the cylindrical axis detection method when executed by a processor.

[0051] This application has the following beneficial effects:

[0052] The present application determines a point cloud to be detected, traverses each point in the point cloud to be detected, and votes on the normal of each point based on a preset rule to obtain a first voting list, constructs a first array based on each element in the first voting list, sorts the first array based on the number of votes to obtain a second array, constructs a first fitting plane based on the second array and determines the first plane vector of the first fitting plane, updates the first array based on the first plane vector to obtain a new first array, constructs a new first fitting plane based on the new first array and determines a new first plane vector of the new first fitting plane, and when the new first plane vector is unstable, returns to execute the steps of updating the first array based on the first plane vector to obtain a new first array to constructing a new first fitting plane based on the new first array and determining a new first plane vector of the new first fitting plane, until the number of iterations is reached, and the latest first plane vector is obtained as the cylinder axis. No secondary voting is required, which reduces the amount of calculation and the calculation time, and the axial detection is very stable. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0054] Figure 1 A block diagram of an electronic device provided in an embodiment of the present application;

[0055] Figure 2 One of the flow charts of a cylindrical axis detection method provided in an embodiment of the present application;

[0056] Figure 3 A second flow chart of a cylindrical axis detection method provided in an embodiment of the present application;

[0057] Figure 4 A third flow chart of a cylindrical axis detection method provided in an embodiment of the present application;

[0058] Figure 5 A fourth flow chart of a cylindrical axis detection method provided in an embodiment of the present application;

[0059] Figure 6 A fifth flow chart of a cylindrical axis detection method provided in an embodiment of the present application;

[0060] Figure 7 A sixth flow chart of a cylindrical axis detection method provided in an embodiment of the present application;

[0061] Figure 8 This is a structural block diagram of a cylindrical axis detection device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0062] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various different configurations.

[0063] Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the present application for which protection is sought, but merely represents selected embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.

[0064] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.

[0065] In the description of the present application, it should be noted that if the terms "upper", "lower", "inside", "outside", etc. appear to indicate an orientation or position relationship, it is based on the orientation or position relationship shown in the drawings, or is the orientation or position relationship in which the product of the invention is usually placed when used. It is only for the convenience of describing the present application and simplifying the description, and does not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present application.

[0066] In addition, the terms “first”, “second”, etc., if used, are merely used to distinguish between the descriptions and should not be understood as indicating or implying relative importance.

[0067] In the description of this application, it should also be noted that, unless otherwise clearly specified and limited, the terms "set", "install", "connect", and "connect" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal communication of two elements. For ordinary technicians in this field, the specific meanings of the above terms in this application can be understood according to specific circumstances.

[0068] After extensive research, the inventors found that the existing method for determining the axis of a cylinder has low computational efficiency.

[0069] In view of the discovery of the above problems, the present embodiment provides a cylindrical axis detection method, device, electronic device and storage medium, which can determine the point cloud to be detected, traverse each point in the point cloud to be detected, vote on the normal of each point based on a preset rule to obtain a first voting list, construct a first array based on each element in the first voting list, sort the first array based on the number of votes to obtain a second array, construct a first fitting plane based on the second array and determine the first plane vector of the first fitting plane, update the first array based on the first plane vector to obtain a new first array, construct a new first fitting plane based on the new first array and determine a new first plane vector of the new first fitting plane, and when the new first plane vector is unstable, return to execute the steps of updating the first array based on the first plane vector to obtain a new first array to constructing a new first fitting plane based on the new first array and determining a new first plane vector of the new first fitting plane, until the number of iterations is reached, and the latest first plane vector is obtained as the cylindrical axis. No secondary voting is required, the amount of calculation is reduced, the calculation time is reduced, and the axial detection is very stable. The scheme provided by the present embodiment is described in detail below.

[0070] This embodiment provides an electronic device that can detect the axis of a cylinder. In a possible implementation, the electronic device can be a user terminal, for example, the electronic device can be, but is not limited to, a server, a smart phone, a personal computer (PC), a tablet computer, a personal digital assistant (PDA), a mobile Internet device (MID), and an image acquisition device.

[0071] Please refer to Figure 1 , Figure 1 1 is a schematic diagram of the structure of the electronic device 100 provided in the embodiment of the present application. The electronic device 100 may also include Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown. Figure 1 Each component shown in the figure can be implemented by hardware, software or a combination thereof.

[0072] The electronic device 100 includes a cylindrical axis detection device 110 , a memory 120 and a processor 130 .

[0073] The components of the memory 120 and the processor 130 are electrically connected to each other directly or indirectly to realize data transmission or interaction. For example, these components can be electrically connected to each other through one or more communication buses or signal lines. The cylindrical axis detection device 110 includes at least one software function module that can be stored in the memory 120 in the form of software or firmware or solidified in the operating system (OS) of the electronic device 100. The processor 130 is used to execute the executable modules stored in the memory 120, such as the software function modules and computer programs included in the cylindrical axis detection device 110.

[0074] The memory 120 may be, but is not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable read-only memory (EEPROM), etc. The memory 120 is used to store a program, and the processor 130 executes the program after receiving an execution instruction.

[0075] Please refer to Figure 2 , Figure 2 For application Figure 1 The flowchart of a cylindrical axis detection method of the electronic device 100 is shown in FIG. 1 , and each step of the method is described in detail below.

[0076] S201: Determine the point cloud to be detected.

[0077] Among them, the point cloud to be detected contains only one cylinder.

[0078] S202: traverse each point in the point cloud to be detected, and vote on the normal of each point based on a preset rule to obtain a first voting list.

[0079] The first voting list includes each voting position and the number of votes corresponding to each voting position.

[0080] S203: Construct a first array based on each element in the first voting list.

[0081] The first array includes the normal direction and the number of votes of each element.

[0082] S204: Sort the first array based on the number of votes to obtain a second array.

[0083] S205: construct a first fitting plane based on the second array and determine a first plane vector of the first fitting plane.

[0084] S206: Update the first array based on the first plane vector to obtain a new first array.

[0085] S207: construct a new first fitting plane based on the new first array and determine a new first plane vector of the new first fitting plane.

[0086] S208: When the new first plane vector is unstable, return to execute the steps of updating the first array based on the first plane vector to obtain a new first array, constructing a new first fitting plane based on the new first array and determining a new first plane vector of the new first fitting plane, until the number of iterations is reached, and obtain the latest first plane vector as the cylinder axis.

[0087] Traverse each point in the point cloud to be detected, determine the point cloud parameters of the point, and vote on the normal of the point based on the point cloud parameters. The point cloud parameters may include the coordinates of the point and the normal of the point.

[0088] For each element in the first voting list, a first array is constructed based on the parameters of each element, the elements in the first array are sorted according to the number of votes to obtain a second array, a preset number of elements are obtained from the second array, a first fitting plane is constructed, and a first plane vector of the first fitting plane is determined, where the first plane vector is the normal of the first fitting plane.

[0089] It should be noted that the first preset number can be specifically set according to actual conditions, and the embodiment of the present application does not impose any specific restrictions on this.

[0090] The distance between each normal in each first array and the first plane vector is determined, the first array is updated based on the distance between the normal and the first plane vector, and the updated first array is sorted based on the size of the distance to obtain a new first array.

[0091] A preset number of elements are obtained from the new first array, a new first fitting plane is constructed, and a new first plane vector of the new fitting plane is determined, and whether the new first plane vector is stable is judged. When the new first plane vector is unstable, the distance between each normal in the new first array and the new first plane vector is calculated, and the new first array is updated again to obtain a third array, and the third array is sorted based on the size of the distance to obtain a new third array, a preset number of elements are obtained from the new third array to construct a second fitting plane, and a second plane vector of the second fitting plane is determined, and the second plane vector is used as the new first plane vector. When the second plane vector is stable, the second plane vector is used as the cylinder axis. If the second plane vector is unstable, the first array is updated again based on the first plane vector to obtain a new first array to the steps of constructing a new first fitting plane based on the new first array and determining a new first plane vector of the new first fitting plane, until the number of iterations is reached, and the latest first plane vector is used as the cylinder axis.

[0092] It should be noted that the number of iterations can be set according to actual conditions.

[0093] There are many implementation methods for traversing each point in the point cloud to be detected, voting on the normal of each point based on a preset rule, and obtaining a first voting list. In one implementation method, for example Figure 3 As shown, the following steps are included:

[0094] S301: traverse each point in the point cloud to be detected, and determine the coordinates and normal of the point.

[0095] S302: Calculate a first angle and a second angle based on the normal.

[0096] The first angle is the angle between the projection of the normal on the xy plane and the x-axis, and the second angle is the angle between the normal and the z-axis.

[0097] S303: Calculate the voting position of the point based on the first angle and the second angle.

[0098] S304: Determine whether the first voting list contains the voting position of the point.

[0099] S305: If yes, then increase the number of votes for the voting position of the point by one.

[0100] S306: If not, the voting position of the point is stored in the first voting list, and the number of votes for the voting position of the point is set to 1.

[0101] Use variable i to traverse each point in the point cloud to be detected and determine the coordinates p of point i i and normal n i , according to ni Calculate the first angle θ i and the second angle The first angle θ i Indicates the angle between the projection of the normal on the xy plane and the x-axis, the second angle Represents the angle between the normal and the z-axis.

[0102] The first angle is calculated by the x-axis component and the z-axis component of the normal. The first angle θ i The calculation formula is as follows:

[0103] Among them, n i,x is the x-axis component of the normal, n i,z is the z-component of the normal direction.

[0104] The second angle is calculated by the z-axis component of the normal. The calculation formula is as follows:

[0105] Among them, n i,z is the z-component of the normal direction.

[0106] According to the first angle θ i and the second angle Calculate the voting position normal_index_i. The voting position normal_index_i is obtained by combining the first angle and the second angle after quantization. The voting position normal_index_i is composed of a pair of integers, namely (a i,1 ,a i,2 ), where a i,1 ,a i,2 are all integers, a i,1 and a i,2 Corresponding to the first angle θ i and the second angle The results after quantification.

[0107] The process of quantizing the angle is as follows: an angle resolution is defined. The angle resolution represents the number of quantized angles within a 180° angle range. For example, the resolution can be 180, that is, the quantization accuracy is 1°.

[0108] For the first angle θ i The quantitative formula is: i, = int(θ i / π·), where l is the angular resolution, and for the second angle The quantitative formula is:

[0109] Determine whether the first voting list contains the normal_index_i voting position. If so, vote at the normal_index_i voting position, that is, the number of votes is increased by 1, and the corresponding coordinate p is i Save it. If it is not included, create the normal_index_i voting position in the first voting list, set the number of votes to 1, and set the corresponding coordinate p i Save and repeat the above process until i is traversed and the first voting list is constructed.

[0110] There are multiple implementations for constructing the first array based on the elements in the first voting list. In one implementation, for example, Figure 4 As shown, the following steps are included:

[0111] S401: traverse each element in the first voting list to determine the voting position of the element and the number of votes for the voting position.

[0112] S402: Calculate a third angle and a fourth angle based on the voting positions.

[0113] S403: Based on the third angle and the fourth angle, a first normal direction of the voting position is obtained.

[0114] S404: Construct a first array based on the number of votes and the first normal.

[0115] Use variable i to traverse the first voting list, get the i-th voting position normal_index_i and the corresponding number of votes count_i, and calculate the third angle and θ based on the voting position normal_index_i i and the fourth angle Then the first normal direction normal_i is calculated. The voting position normal_index_i contains two integers (a i,1 ,a i,2 ), the formula to convert it into an angle is as follows:

[0116]

[0117] According to the third angle θ i and the fourth angle The formula for calculating the first normal normal_i is as follows:

[0118]

[0119] Combine the number of votes count_i and the first normal normal_i and store them in the first array normals.

[0120] The first array normals contains the normals normal_i and the vote counts count_i.

[0121] A first fitting plane is constructed based on the second array and a first plane vector of the first fitting plane is determined.

[0122] Based on the first array, the elements in the first array normals are sorted in descending order of the number of votes count of the elements therein to obtain the second array.

[0123] There are many implementations for constructing a first fitting plane based on the second array and determining a first plane vector of the first fitting plane. In one implementation, for example: Figure 5 As shown, the following steps are included:

[0124] S501: Acquire a preset number of target elements in the front order of the second array to construct a first fitting plane.

[0125] S502: Calculate a covariance matrix based on the target element.

[0126] S503: Based on the covariance matrix, determine the eigenvector of the minimum eigenvalue as the first plane vector of the first fitting plane.

[0127] In one example, the first 10% of the elements in the second array are taken as target elements, and a plane is fitted based on the target elements to obtain a first fitting plane. Since the plane must pass through the origin of the coordinate system, only the normal of the plane, i.e., the first plane vector, needs to be calculated during fitting.

[0128] The first plane vector of the first fitting plane may be calculated as follows:

[0129] A covariance matrix is ​​calculated based on the target element, and an eigenvector of a minimum eigenvalue of the covariance matrix is ​​determined as a first plane vector of a first fitting plane.

[0130] The formula for calculating the covariance matrix is ​​as follows:

[0131] in m i Indicates n i The number of votes, n i represents the i-th normal in the target element, and C represents the covariance matrix.

[0132] The covariance matrix is ​​a symmetric matrix, so it can be diagonalized. The eigenvalues ​​and eigenvectors of the covariance matrix can be solved by solving the following eigenvalue problem: Σv=λv where λ is the eigenvalue and v) is the corresponding eigenvector. Arrange all eigenvalues ​​in ascending order and find the smallest eigenvalue (λ_(min)). The corresponding eigenvector is the eigenvector of the smallest eigenvalue, which is the first plane vector of the first fitting plane.

[0133] There are multiple implementations of updating the first array based on the first plane vector to obtain a new first array. In one implementation, Figure 6 As shown, the following steps are included:

[0134] S601: Calculate the distances between all normals in the first array and the first fitting plane.

[0135] S602: Based on each distance, update the first array to obtain a third array.

[0136] S603: Sort the third array in ascending order of distance to obtain a new first array.

[0137] Use i to traverse the first array normals and get the normal n i , calculate the distance from the normal to the first fitting plane:

[0138] d i =|n i ·t c |, where t c is the current cylinder axis, i.e. the first plane vector, d i is the distance from the normal to the first fitting plane.

[0139] D i Assign the normals in the first array to obtain the third array, sort the third array in ascending order of distance, and obtain a new first array.

[0140] There are many ways to determine whether the new first plane vector is stable. In one implementation, Figure 7 As shown, the following steps are included:

[0141] S701: Determine the second plane vector after the last iterative calculation.

[0142] S702: Calculate the fifth angle between the second plane vector and the new first plane vector.

[0143] S703: When the fifth angle is greater than a preset threshold, it is determined that the new first plane vector is unstable.

[0144] When the new first plane vector is unstable, return to execute the steps of updating the first array based on the first plane vector to obtain a new first array, constructing a new first fitting plane based on the new first array and determining a new first plane vector of the new first fitting plane, until the number of iterations is reached, and obtain the latest first plane vector as the cylinder axis.

[0145] S704: When the fifth angle is less than or equal to a preset threshold, it is determined that the new first plane vector is stable.

[0146] It should be noted that the preset threshold can be determined based on actual conditions, and the embodiments of the present application do not impose specific limitations on this.

[0147] When the fifth angle is less than or equal to the preset threshold, the new first plane vector is used as the cylinder axis.

[0148] Please refer to Figure 8 The present application embodiment also provides an application Figure 1 The cylindrical axis detection device 110 of the electronic device 100 includes:

[0149] A determination module 111 is used to determine a point cloud to be detected, wherein the point cloud to be detected only includes one cylinder;

[0150] A voting module 112 is used to traverse each point in the point cloud to be detected, and vote on the normal of each point based on a preset rule to obtain a first voting list, wherein the first voting list includes each voting position and the number of votes corresponding to each voting position;

[0151] A construction module 113, configured to construct a first array based on each element in the first voting list, wherein the first array includes a normal direction and a number of votes of each element;

[0152] The determination module 111 is also used to sort the first array based on the number of votes to obtain a second array; construct a first fitting plane based on the second array and determine a first plane vector of the first fitting plane; update the first array based on the first plane vector to obtain a new first array; construct a new first fitting plane based on the new first array and determine a new first plane vector of the new first fitting plane; when the new first plane vector is unstable, return to execute the steps of updating the first array based on the first plane vector to obtain a new first array to constructing a new first fitting plane based on the new first array and determining a new first plane vector of the new first fitting plane, until the number of iterations is reached, and obtain the latest first plane vector as the axis of the cylinder.

[0153] The present application also provides an electronic device 100, which includes a processor 130 and a memory 120. The memory 120 stores computer executable instructions, and when the computer executable instructions are executed by the processor 130, the cylindrical axis detection method is implemented.

[0154] The embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by the processor 130, the cylindrical axis detection method is implemented.

[0155] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to the multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or the flowchart, and the combination of boxes in the block diagram and / or the flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.

[0156] In addition, each functional module in each embodiment of the present application can be integrated together to form an independent part, or each module can exist separately, or two or more modules can be integrated to form an independent part. If the function is implemented in the form of a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a disk or an optical disk.

[0157] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0158] The above are only various implementations of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A cylindrical axis detection method, characterized in that: The method comprises: Determine a point cloud to be detected, wherein the point cloud to be detected contains only one cylinder; Traversing each point in the point cloud to be detected, voting on the normal of each point based on a preset rule, and obtaining a first voting list, wherein the first voting list includes each voting position and the number of votes corresponding to each voting position; Based on each element in the first voting list, construct a first array, wherein the first array includes a normal direction and a number of votes for each element; Based on the number of votes, sorting the first array to obtain a second array; constructing a first fitting plane based on the second array and determining a first plane vector of the first fitting plane; Update the first array based on the first plane vector to obtain a new first array; constructing a new first fitting plane based on the new first array and determining a new first plane vector of the new first fitting plane; When the new first plane vector is unstable, return to the step of updating the first array based on the first plane vector to obtain a new first array to construct a new first fitting plane based on the new first array and determine a new first plane vector of the new first fitting plane until the number of iterations is reached, and obtain the latest first plane vector as the cylinder axis.

2. The method according to claim 1, characterized in that: The step of traversing each point in the point cloud to be detected and voting on the normal of each point based on a preset rule to obtain a first voting list includes: Traversing each point in the point cloud to be detected, and determining the coordinates and normal of the point; Calculate a first angle and a second angle based on the normal, wherein the first angle is the angle between the projection of the normal on the xy plane and the x-axis, and the second angle is the angle between the normal and the z-axis; Calculating the voting position of the point based on the first angle and the second angle; determining whether the first voting list contains the voting position of the point; If so, increase the number of votes for the voting position at that point by one; If not, the voting position of the point is stored in the first voting list, and the number of votes for the voting position of the point is set to 1.

3. The method according to claim 2, characterized in that The step of calculating the first angle and the second angle based on the normal direction comprises: Determining an x-axis component and a z-axis component of the normal; Calculate a first angle based on the x-axis component and the z-axis component; A second angle is calculated based on the z-axis component.

4. The method according to claim 1, characterized in that: The step of constructing a first array based on each element in the first voting list includes: Traversing each element in the first voting list to determine the voting position of the element and the number of votes for the voting position; Based on the voting position, calculating a third angle and a fourth angle; Based on the third angle and the fourth angle, obtaining a first normal direction of the voting position; A first array is constructed based on the number of votes and the first normal.

5. The method according to claim 1, characterized in that The step of constructing a first fitting plane based on the second array and determining a first plane vector of the first fitting plane comprises: Acquire a preset number of target elements in the first order of the second array to construct a first fitting plane; Calculate a covariance matrix based on the target element; Based on the covariance matrix, an eigenvector of a minimum eigenvalue is determined as a first plane vector of the first fitting plane.

6. The method according to claim 1, characterized in that The step of updating the first array based on the first plane vector to obtain a new first array includes: Calculating the distances between all normal directions in the first array and the first fitting plane; Based on the distances, the first array is updated to obtain a third array; The third array is sorted from small to large according to the distance to obtain a new first array.

7. The method according to claim 1, characterized in that The step of returning to the step of updating the first array based on the first plane vector to obtain a new first array and constructing a new first fitting plane based on the new first array and determining a new first plane vector of the new first fitting plane when the new first plane vector is unstable, until the number of iterations is reached, and obtaining the latest first plane vector as the cylinder axis, comprises: Determine the second plane vector calculated in the last iteration; Calculating a fifth angle between the second plane vector and the new first plane vector; When the fifth angle is greater than a preset threshold, it is determined that the new first plane vector is unstable; Return to the step of updating the first array based on the first plane vector to obtain a new first array to construct a new first fitting plane based on the new first array and determine a new first plane vector of the new first fitting plane, until the number of iterations is reached, and obtain the latest first plane vector as the cylinder axis.

8. A cylindrical axis detection device, characterized in that: The device comprises: A determination module, used for determining a point cloud to be detected, wherein the point cloud to be detected contains only one cylinder; A voting module, used for traversing each point in the point cloud to be detected, voting on the normal of each point based on a preset rule, and obtaining a first voting list, wherein the first voting list includes each voting position and the number of votes corresponding to each voting position; A construction module, configured to construct a first array based on each element in the first voting list, wherein the first array includes a normal direction and a number of votes of each element; The determination module is also used to sort the first array based on the number of votes to obtain a second array; construct a first fitting plane based on the second array and determine a first plane vector of the first fitting plane; update the first array based on the first plane vector to obtain a new first array; construct a new first fitting plane based on the new first array and determine a new first plane vector of the new first fitting plane; when the new first plane vector is unstable, return to execute the steps of updating the first array based on the first plane vector to obtain a new first array to constructing a new first fitting plane based on the new first array and determining a new first plane vector of the new first fitting plane, until the number of iterations is reached, and obtain the latest first plane vector as the axis of the cylinder.

9. An electronic device, characterized in that: The method comprises a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the method according to any one of claims 1 to 7 when executing the computer program.

10. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Visual inspection method, device and system based on point cloud data

    CN111899302A

  • Point cloud registration method and device based on cylinder detection

    CN117876446A

  • Pose recognition method and device of cylindrical workpiece, electronic equipment and storage medium

    CN118762155A

  • Development preparing device and development preparing method for cylindrical component

    JP2010086515A

  • Three-dimensional point processing and model generation

    US20140192050A1

Cited By

  • Method for detecting cylinder in point cloud and related equipment

    CN122434933A