A method, device, storage medium and electronic device for detecting a cylindrical axis
By performing voting statistics and rotation processing on angle combinations of points in the point cloud data, the problem of low efficiency and instability in cylinder axis detection in the existing technology is solved, and more efficient and accurate detection results are achieved.
Patent Information
- Application Number
- CN202410621102.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-20
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2044-05-20
AI Technical Summary
The existing technology has low efficiency and instability when detecting the axis of a cylinder in a point cloud. Especially in the presence of planes and noise, the voting of randomly selected points is invalid, resulting in an inefficient detection process.
By conducting the first voting statistics on the angle combinations of the points in the point cloud data, rotating the initial circle based on the rotation vector, and conducting the second voting statistics, it is judged whether the number of angle combinations of the target type is less than the preset number, so as to Confirm that the cylinder axis is detected, avoid randomly selecting points for voting, and eliminate noise interference.
It improves the efficiency and accuracy of cylinder axis detection, reduces noise interference, and ensures the stability of detection.
Smart Images

Figure CN118196172B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image data processing, and in particular to a method, device, storage medium and electronic device for detecting the axis of a cylinder. Background Art
[0002] Shape detection from point clouds refers to detecting some specific geometric shapes in point clouds, including planes, cylinders, etc. Currently, the RHT (random Hough transform) algorithm is usually used to detect cylindrical surfaces in point clouds.
[0003] The basic process of the RHT algorithm to detect cylindrical surfaces in point clouds is as follows: first, detect the cylinder axis, randomly select 2 points from the point cloud data, then calculate the cross product vector of the normal vectors of the 2 randomly selected points, and vote at the corresponding position of the voting accumulator. When a certain position in the voting accumulator accumulates a sufficient number of voting values, it means that a cylinder axis has been detected, and a projection plane perpendicular to the cylinder axis is determined based on the direction vector of the cylinder axis, and then the points in the point cloud that meet the conditions are projected onto the projection plane for cylindrical surface detection.
[0004] In the process of detecting the axis of the cylinder, it is necessary to randomly select two points from the point cloud data. When there are planes, cylindrical surfaces and noise in the point cloud data, the voting of the two randomly selected points may be invalid, making the process of detecting the axis of the cylinder inefficient and prone to unstable detection of the axis of the cylinder. Summary of the invention
[0005] The object of the present invention is to provide a method, device, storage medium and electronic device for detecting the axis of a cylinder, so as to at least partially improve the above-mentioned problem.
[0006] In order to achieve the above purpose, the technical solution adopted by the embodiment of the present invention is as follows:
[0007] In a first aspect, an embodiment of the present invention provides a method for detecting an axis of a cylinder, the method comprising:
[0008] Perform a first voting statistics on the angle combination corresponding to the point in the point cloud data, wherein the angle combination includes a first angle and a second angle corresponding to the point, the first angle is the angle between the normal vector of the point and the z-axis, and the second angle is the angle between the projection of the normal vector of the point on the xy plane and the x-axis;
[0009] The initial circle is rotated based on the rotation vector to obtain a rotated circle, and a second voting statistics is performed on the angle combination corresponding to each sampling point on the rotated circle, wherein the rotation vector is a normal vector corresponding to any type of the angle combination in the first voting statistics;
[0010] Determine whether the statistical number of angle combinations of the target type is less than a first preset number, wherein the target type is the type corresponding to the angle combination with the largest statistical number in the second voting statistics;
[0011] If not, it is confirmed that the cylinder axis is detected, the direction vector of the cylinder axis is the target vector, the target vector is the vector between the origin and the target position, and the target position is the coordinate position of the sampling point corresponding to the angle combination of the target type.
[0012] In a second aspect, an embodiment of the present invention provides a cylindrical axis detection device, the device comprising:
[0013] A first processing unit is used to perform a first voting statistics on the angle combination corresponding to the point in the point cloud data, wherein the angle combination includes a first angle and a second angle corresponding to the point, the first angle is the angle between the normal vector of the point and the z-axis, and the second angle is the angle between the projection of the normal vector of the point on the xy plane and the x-axis;
[0014] The first processing unit is further used to rotate the initial circle based on the rotation vector to obtain a rotated circle, and perform a second voting statistics on the angle combination corresponding to each sampling point on the rotated circle, wherein the rotation vector is a normal vector corresponding to any type of the angle combination in the first voting statistics;
[0015] The first processing unit is further used to determine whether the statistical number of angle combinations of the target type is less than a first preset number, wherein the target type is the type corresponding to the angle combination with the largest statistical number in the second voting statistics;
[0016] The second processing unit is used to confirm that the axis of the cylinder is detected if not, the direction vector of the axis of the cylinder is the target vector, the target vector is the vector between the origin and the target position, and the target position is the coordinate position of the sampling point corresponding to the angle combination of the target type.
[0017] In a third aspect, an embodiment of the present invention provides a storage medium having a computer program stored thereon, and the computer program implements the above method when executed by a processor.
[0018] In a fourth aspect, an embodiment of the present invention provides an electronic device, comprising: a processor and a memory, wherein the memory is used to store one or more programs; when the one or more programs are executed by the processor, the above method is implemented.
[0019] Compared with the prior art, the embodiments of the present invention provide a method, device, storage medium and electronic device for detecting the axis of a cylinder, including: performing a first voting statistics on the angle combination corresponding to the point in the point cloud data, wherein the angle combination includes a first angle and a second angle corresponding to the point, the first angle is the angle between the normal vector of the point and the z-axis, and the second angle is the angle between the projection of the normal vector of the point on the xy plane and the x-axis; rotating the initial circle based on the rotation vector to obtain the rotated circle, and performing a second voting statistics on the angle combination corresponding to each sampling point on the rotated circle, wherein the rotation vector is the normal vector corresponding to any type of angle combination in the first voting statistics; judging whether the statistical number of angle combinations of the target type is less than a first preset number, wherein the target type is the type corresponding to the angle combination with the largest number of statistics in the second voting statistics; if not, confirming that the axis of the cylinder is detected, the direction vector of the axis of the cylinder is the target vector, the target vector is the vector between the origin and the target position, and the target position is the coordinate position of the sampling point corresponding to the angle combination of the target type. During the detection process, there is no need to randomly select points for voting, which can greatly eliminate noise interference, improve the efficiency of cylindrical axis detection, and ensure the accuracy of detection.
[0020] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, 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 invention 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.
[0022] Figure 1 A schematic diagram of the structure of an electronic device provided by the present invention;
[0023] Figure 2 One of the flow charts of the cylindrical axis detection method provided by the present invention;
[0024] FIG3 (a) is a schematic diagram of a cylinder provided by the present invention;
[0025] FIG3( b ) is a schematic diagram of voting results of the normal vector of each point on the cylindrical surface in FIG3( a ) provided by the present invention;
[0026] FIG3 (c) is a schematic diagram of voting results for each point on the rotated circle corresponding to the normal vector of each point in FIG3 (b) provided by the present invention;
[0027] Figure 4The second flow chart of the cylindrical axis detection method provided by the present invention;
[0028] Figure 5 The third flow chart of the cylindrical axis detection method provided by the present invention;
[0029] Figure 6 A unit schematic diagram of the cylindrical axis detection device provided by the present invention.
[0030] In the figure: 10 - processor; 11 - memory; 12 - bus; 13 - communication interface; 201 - first processing unit; 202 - second processing unit. DETAILED DESCRIPTION
[0031] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.
[0032] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0033] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings. At the same time, in the description of the present invention, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0034] 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.
[0035] Some embodiments of the present invention are described in detail below in conjunction with the accompanying drawings. In the absence of conflict, the following embodiments and features in the embodiments can be combined with each other.
[0036] When the RHT algorithm detects cylindrical surfaces in point clouds, it is first necessary to detect the axis of the cylinder. In the process of detecting the axis of the cylinder, it is necessary to randomly select two points from the point cloud data. When there are planes, cylindrical surfaces, and noise in the point cloud data, the votes of the two randomly selected points may be invalid, making the process of detecting the axis of the cylinder inefficient and prone to unstable detection of the axis of the cylinder. In order to overcome this problem, an embodiment of the present invention provides a method for detecting the axis of a cylinder, which is applied to the electronic device described below to improve detection efficiency and ensure detection accuracy.
[0037] The embodiment of the present invention provides an electronic device, which may be a mobile phone device, a computer device, a server device, a central control device of a radar system, etc. Figure 1 , a schematic diagram of the structure of an electronic device. The electronic device includes a processor 10, a memory 11, and a bus 12. The processor 10 and the memory 11 are connected via the bus 12, and the processor 10 is used to execute an executable module stored in the memory 11, such as a computer program.
[0038] The processor 10 may be an integrated circuit chip having the ability to process signals. In the implementation process, each step of the cylindrical axis detection method may be completed by an integrated logic circuit of hardware in the processor 10 or by instructions in the form of software. The above-mentioned processor 10 may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA), or other programmable logic devices, discrete gates or transistor logic devices, or discrete hardware components.
[0039] The memory 11 may include a high-speed random access memory (RAM), and may also include a non-volatile memory, such as at least one disk memory.
[0040] The bus 12 may be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus, or an EISA (Extended Industry Standard Architecture) bus. Figure 1 Although only one bidirectional arrow is used in the figure, it does not mean that there is only one bus 12 or only one type of bus 12 .
[0041] The memory 11 is used to store programs, such as programs corresponding to the cylindrical axis detection device. The cylindrical axis detection device includes at least one software function module that can be stored in the memory 11 in the form of software or firmware or solidified in the operating system (OS) of the electronic device. After receiving the execution instruction, the processor 10 executes the program to implement the cylindrical axis detection method.
[0042] Possibly, the electronic device provided in the embodiment of the present invention further includes a communication interface 13. The communication interface 13 is connected to the processor 10 via a bus. The electronic device can receive point cloud data collected by a radar device (including but not limited to a laser radar) via the communication interface 13. Of course, the electronic device can also transmit the point cloud data corresponding to the detected cylindrical surface or cylindrical axis to other terminals via the communication interface 13.
[0043] It should be understood that Figure 1 The structure shown is only a schematic diagram of a portion of the electronic device. The electronic device 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.
[0044] The cylindrical axis detection method provided by the embodiment of the present invention can be applied to but not limited to Figure 1 For detailed procedures, please refer to the electronic equipment shown in Figure 2 The cylindrical axis detection method includes: S110, S140, S160 and S170, which are described in detail as follows.
[0045] S110, performing a first voting statistics on the angle combinations corresponding to the midpoints of the point cloud data.
[0046] The angle combination includes a first angle and a second angle corresponding to the point, the first angle is the angle between the normal vector of the point and the z-axis, and the second angle is the angle between the projection of the normal vector of the point on the xy plane and the x-axis.
[0047] It should be noted that the xyz coordinate system here is the coordinate system corresponding to the point cloud.
[0048] Optionally, the formula for calculating the first angle and the second angle is:
[0049]
[0050]
[0051] in, represents the first angle of the i-th point, represents the second angle of the i-th point, Represents the normal vector of the i-th point The x-component of Represents the normal vector of the i-th point The y component of Represents the normal vector of the i-th point The z component of .
[0052] Regarding the content in S110, the normal vector of the i-th point in the point cloud data can be obtained one by one by traversal, and then the first angle and the second angle of the i-th point can be obtained, and statistics can be performed; the normal vector of each point in the point cloud data can also be obtained by traversal, and after obtaining the normal vectors of all points, the first angle and the second angle of each point can be obtained, and comprehensive statistics can be performed.
[0053] It should be noted that the neighborhood of the i-th point can be determined from the point cloud data, and all points in the neighborhood of the i-th point can be fitted to obtain the neighborhood plane, and the normal vector of the neighborhood plane is used as the normal vector of the i-th point. .
[0054] For example, the point cloud data includes 6 points, and the angle combination is in the form of ( , ), the corresponding angle combinations are (37,45), (37,48), (42,45), (37,45), (37,45) and (37,48); then there are 3 types of angle combinations, namely (37,45), (37,48) and (42,45). The number of angle combinations of each type is counted. The number of angle combinations of (37,45) is 3, the number of angle combinations of (37,48) is 2, and the number of angle combinations of (42,45) is 1. This example is only used to illustrate the relationship between the types of angle combinations and angle combinations, and is not a specific limitation.
[0055] S140, rotating the initial circle based on the rotation vector to obtain a rotated circle, and performing a second voting statistics on the angle combination corresponding to each sampling point on the rotated circle.
[0056] The rotation vector is the normal vector corresponding to any type of angle combination in the first voting statistics.
[0057] For a point on the cylindrical surface, its normal forms a great circle on a unit circle, and the normal vector of the great circle is the direction vector of the axis of the cylinder. Please refer to Figures 3 (a), 3 (b) and 3 (c), Figure 3 (a) is a schematic diagram of a cylinder provided by the present invention, Figure 3 (b) is a schematic diagram of the voting results of the normal vector of each point on the cylindrical surface in Figure 3 (a) provided by the present invention, and Figure 3 (c) is a schematic diagram of the voting results of each point on the rotated circle corresponding to the normal vector of each point in Figure 3 (b) provided by the present invention.
[0058] Each point on the great circle shown in Figure 3 (b) corresponds to a series of points on the cylindrical surface with the same normal. The great circle shown in Figure 3 (b) can be called the first great circle. After obtaining the first great circle, it is necessary to perform voting statistics again to obtain the normal vector of the plane passing through the first great circle, so as to determine the direction of the axis of the cylinder. The principle of determining the direction vector of the axis of the cylinder is that for the normal of a certain point on the cylindrical surface, there is a series of direction vectors perpendicular to the normal vector. For different points on the cylindrical surface, the coincidence direction of this series of direction vectors perpendicular to the normal vector is the direction of the axis of the cylinder. The direction vector of the axis of the cylinder is also the normal vector of the plane passing through the first great circle.
[0059] S160, determining whether the statistical number of angle combinations of target types is less than a first preset number. If not, executing S170; if yes, ending.
[0060] The target type is the type corresponding to the angle combination with the largest number of statistics in the second voting statistics, and the first preset number is 50, for example.
[0061] If the statistical number of angle combinations of the target type is less than the first preset number, it means that there is no cylinder in the point cloud data, and the detection ends.
[0062] S170, confirming that the axis of the cylinder is detected.
[0063] The direction vector of the cylinder axis is the target vector, the target vector is the vector between the origin and the target position, and the target position is the coordinate position of the sampling point corresponding to the angle combination of the target type.
[0064] In the present invention, the angle combination corresponding to each sampling point on the rotated circle is voted and counted, and the detection of the cylinder axis is completed based on the voting and counting results, and the target vector corresponding to the angle combination of the target type is determined as the direction vector of the cylinder axis. In the detection process, there is no need to randomly select points for voting, which can greatly eliminate noise interference, improve the efficiency of cylinder axis detection, and ensure the accuracy of detection.
[0065] In summary, an embodiment of the present invention provides a method for detecting the axis of a cylinder, including: performing a first voting statistics on the angle combination corresponding to the point in the point cloud data, wherein the angle combination includes a first angle and a second angle corresponding to the point, the first angle is the angle between the normal vector of the point and the z-axis, and the second angle is the angle between the projection of the normal vector of the point on the xy plane and the x-axis; rotating the initial circle based on the rotation vector to obtain a rotated circle, and performing a second voting statistics on the angle combination corresponding to each sampling point on the rotated circle, wherein the rotation vector is the normal vector corresponding to any type of angle combination in the first voting statistics; judging whether the statistical number of angle combinations of the target type is less than a first preset number, wherein the target type is the type corresponding to the angle combination with the largest number of statistics in the second voting statistics; if not, confirming that the axis of the cylinder is detected, the direction vector of the axis of the cylinder is the target vector, the target vector is the vector between the origin and the target position, and the target position is the coordinate position of the sampling point corresponding to the angle combination of the target type. During the detection process, there is no need to randomly select points for voting, which can greatly eliminate noise interference, improve the efficiency of cylindrical axis detection, and ensure the accuracy of detection.
[0066] exist Figure 2 Based on the content in S110, the embodiment of the present invention further provides an optional implementation, please refer to the following. S110, the step of performing a first voting and counting of the angle combinations corresponding to the midpoints of the point cloud data includes: S111, S112, S113, S114, S115 and S116, which are specifically described as follows.
[0067] S111, let i=1.
[0068] S112, obtaining the normal vector corresponding to the i-th point in the point cloud data.
[0069] Among them, the normal vector corresponding to the i-th point can be expressed as .
[0070] S113, determining a first angle and a second angle of the ith point based on the normal vector corresponding to the ith point.
[0071] Optionally, the formula for calculating the first angle and the second angle is:
[0072]
[0073]
[0074] in, represents the first angle of the i-th point, represents the second angle of the i-th point, Represents the normal vector of the i-th point The x-component of Represents the normal vector of the i-th point The y component of Represents the normal vector of the i-th point The z component of .
[0075] In an optional implementation, S114 may be directly executed after S113. It is also possible to perform quantization step processing on the first angle and the second angle of the i-th point after S113, and when S114 is executed, the statistical number of angle combinations corresponding to the first angle and the second angle of the i-th point after the quantization step processing is increased by 1.
[0076] The quantization step size can be processed according to the quantization interval of 1°. The value range of θ and φ is [0, 180). This interval is divided into 180 small intervals. After determining the first angle and the second angle of the ith point based on the normal vector corresponding to the ith point, the first angle and the second angle are rounded down to obtain the corresponding quantization result. By performing quantization step size processing, efficiency can be improved while ensuring accuracy.
[0077] S114, adding 1 to the statistical number of angle combinations corresponding to the first angle and the second angle of the i-th point in the first voting device.
[0078] S115, let i=i+1.
[0079] S116, determining whether i is less than or equal to the total number of points. If so, repeatedly executing S112 to obtain the normal vector corresponding to the i-th point in the point cloud data until i is greater than the total number of points.
[0080] The total number of points is the total number of points in the point cloud data. If i is greater than the total number of points, it means that the angle combinations corresponding to all points in the point cloud data have been obtained, and the subsequent steps can be performed.
[0081] The vectors corresponding to the angle combination obtained by the first voting statistics performed by the first voting device constitute the first great circle mentioned above.
[0082] In order to further improve the detection efficiency, the present invention also provides an optional implementation method, please refer to Figure 4, after performing the first voting statistics on the angle combinations corresponding to the midpoints of the point cloud data in S110, the cylinder axis detection method further includes: S120, which is specifically described as follows.
[0083] S120, deleting the angle combination of the interference type in the first voting statistics.
[0084] The interference type is a type corresponding to an angle combination whose statistical quantity in the first voting statistics is less than a second preset quantity.
[0085] It should be noted that the type corresponding to the angle combination whose statistical quantity in the first voting statistics is less than the second preset quantity can be determined as a noise point on the non-cylindrical surface. By deleting it, interference with subsequent steps can be avoided and detection efficiency can be improved.
[0086] exist Figure 2 On the basis of, for the content in S140, the embodiment of the present invention further provides an optional implementation method, please refer to the following, S140, rotating the initial circle based on the rotation vector to obtain a rotated circle, and performing a second voting and counting step on the angle combination corresponding to each sampling point on the rotated circle, including: S140-1, S140-2, S140-3, S140-4, S140-5, S140-6, S140-7, S140-8, S140-9 and S140-10, which are specifically described as follows.
[0087] S140-1, let h=1.
[0088] S140-2, determine the rotation matrix based on the hth normal vector.
[0089] The h-th normal vector is the normal vector corresponding to the h-th type of angle combination in the first voting statistics.
[0090] Optionally, the rotation matrix is calculated as:
[0091] ;
[0092] ;
[0093] where z = (0, 0, 1), represents the hth normal vector, represents the identity matrix, Represents a rotation matrix.
[0094] S140-3, rotating the initial circle based on the rotation matrix to obtain a rotated circle.
[0095] Optionally, the rotation process can be completed by multiplying the initial circle by the rotation matrix to obtain the rotated circle. After the rotation, the great circle facing the z-axis normal vector is rotated to face The circle after the normal vector is rotated is also called the second great circle. , and get the corresponding second largest circle.
[0096] S140-4, let j=1.
[0097] S140-5, obtaining the coordinate position corresponding to the j-th sampling point on the rotated circle, and determining the third angle and the fourth angle of the j-th sampling point.
[0098] In an optional implementation, the rotated circle takes points according to a preset sampling interval, and the number of points on the rotated circle (indicating the total number of sampling points on the rotated circle) corresponds to the sampling interval. For example, if the sampling interval is 30°, the rotated circle is sampled and taken at 30°, 360°÷30°=12, and 12 sampling points can be obtained, and the number of points on the rotated circle is 12. The sampling interval can be configured according to the accuracy requirements of the detection.
[0099] By rotating the coordinate position of each sampling point on the circle, we can obtain the hth normal vector passing through the first great circle. The normal vectors of all planes corresponding to the position and the origin are used to calculate the voting statistics.
[0100] S140-6, increment the statistical number of angle combinations corresponding to the third angle and the fourth angle of the j-th sampling point in the second voting device by 1.
[0101] It should be noted that the angle combination in the second voting device includes the third angle and the fourth angle, and the formulas for the third angle and the fourth angle of the j-th sampling point are:
[0102]
[0103]
[0104] in, represents the third angle of the jth sampling point, represents the fourth angle of the jth sampling point, Indicates the coordinate position of the jth sampling point The x-component of Indicates the coordinate position of the jth sampling point The y component of Indicates the coordinate position of the jth sampling point The z component of .
[0105] The third angle is the angle between the line connecting the origin and the j-th sampling point and the z-axis, and the fourth angle is the angle between the projection of the line connecting the origin and the j-th sampling point on the xy plane and the x-axis.
[0106] In an optional implementation, before executing S140-6, the third angle and the fourth angle of the j-th sampling point obtained by executing S140-5 may be quantized step-wise. The quantization step-wise processing may be performed according to a quantization interval of 1°, and the value range of θ and φ is [0, 180). This interval is divided into 180 small intervals. After the third angle and the fourth angle of the j-th sampling point are determined based on the coordinate position corresponding to the j-th sampling point, the third angle and the fourth angle are rounded down to obtain the corresponding quantization result.
[0107] S140-7, let j=j+1.
[0108] S140-8, determine whether j is less than or equal to the number of dots after rotation. If so, repeat S140-5 to obtain the coordinate position corresponding to the j-th sampling point on the rotated circle, and determine the third angle and the fourth angle of the j-th sampling point until j is greater than the number of dots after rotation. If not, that is, when j is greater than the number of dots after rotation, execute S140-9.
[0109] S140-9, let h=h+1.
[0110] S140-10, determine whether h is less than or equal to the total number of angle combination types in the first voting statistics. If so, repeat S140-2 to determine the rotation matrix based on the hth normal vector until h is greater than the total number of angle combination types. If not, that is, when h is greater than the total number of angle combination types, it means that all the rotated circles have been obtained, and the angle combination corresponding to each sampling point on all the rotated circles has been completed for the second voting statistics, and the subsequent steps can be executed.
[0111] Please continue to refer to Figure 4 In S140, the initial circle is rotated based on the rotation vector to obtain a rotated circle, and after a second voting statistics is performed on the angle combination corresponding to each sampling point on the rotated circle, the cylinder axis detection method also includes: S150, which is specifically described as follows.
[0112] S150, determining an angle combination of target types.
[0113] The angle combination with the largest number of statistics is determined from the results of the second voting statistics, and the type corresponding to the angle combination with the largest number of statistics in the second voting statistics is used as the target type.
[0114] Optionally, the step of determining the angle combination of the target type includes: S151, S152, S153, S154, S155, S156, S157 and S158, which are specifically described as follows.
[0115] S151, let k=1, K=1, M≤0;
[0116] S152, obtaining the statistical number of the k-th type of angle combination in the second voting statistics.
[0117] It should be noted that the classification method of angle combinations in the second voting statistics is the same as the classification method corresponding to the angle combinations in the first voting statistics, and will not be elaborated here.
[0118] S1513, determine whether m is greater than M. If m is greater than M, execute S154, if m is less than or equal to M, execute S156.
[0119] Wherein, m represents the statistical number of the k-th type of angle combination in the second voting statistics.
[0120] S154, let M=m.
[0121] S155, let K=k.
[0122] S156, let k=k+1.
[0123] It should be noted that after executing S154, it is also necessary to execute S155 and S156.
[0124] After executing S156 and setting k=k+1, execute S157.
[0125] S157, determine whether k is less than or equal to the total number of angle combination types in the second voting statistics. If yes, repeat S152; if no, execute S158.
[0126] If k is less than or equal to the total number of angle combination types in the second voting statistics, then repeatedly obtain the statistical number of the kth type of angle combination in the second voting statistics, and determine whether m is greater than M, until k is greater than the total number of angle combination types in the second voting machine.
[0127] S158, determining the Kth type of angle combination in the second voting statistics as the target type of angle combination.
[0128] Please refer to Figure 5 In an optional embodiment, at S140, the initial circle is rotated based on the rotation vector to obtain a rotated circle, and before a second voting statistics is performed on the angle combination corresponding to each sampling point on the rotated circle, the cylinder axis detection method also includes: S130, which is specifically described as follows.
[0129] S130, creating an initial circle.
[0130] Among them, the formula for the initial circle is: , , z=0, 0≤t≤2π, the initial circle is a circle with the z-axis as the normal vector and the origin as the center.
[0131] In an optional implementation, the point cloud data used for detecting the axis of a cylinder in the present invention may be processed point cloud data for which plane detection has been completed and points belonging to the plane have been deleted.
[0132] See also Figure 6 , Figure 6 An embodiment of the present invention provides a cylindrical axis detection device. Optionally, the cylindrical axis detection device is applied to the electronic device described above.
[0133] The cylindrical axis detection device includes: a first processing unit 201 and a second processing unit 202 .
[0134] The first processing unit 201 is used to perform a first voting statistics on the angle combination corresponding to the point in the point cloud data, wherein the angle combination includes a first angle and a second angle corresponding to the point, the first angle is the angle between the normal vector of the point and the z-axis, and the second angle is the angle between the projection of the normal vector of the point on the xy plane and the x-axis;
[0135] The first processing unit 201 is further used to rotate the initial circle based on the rotation vector to obtain a rotated circle, and perform a second voting statistics on the angle combination corresponding to each sampling point on the rotated circle, wherein the rotation vector is a normal vector corresponding to any type of the angle combination in the first voting statistics;
[0136] The first processing unit 201 is further configured to determine whether the statistical number of angle combinations of the target type is less than a first preset number, wherein the target type is the type corresponding to the angle combination with the largest statistical number in the second voting statistics;
[0137] The second processing unit 202 is used to confirm that the cylinder axis is detected if not, the direction vector of the cylinder axis is the target vector, the vector between the target vector origin and the target position, and the target position is the coordinate position of the sampling point corresponding to the angle combination of the target type.
[0138] Optionally, the first processing unit 201 may execute the above-mentioned S110 to S160 , and the second processing unit 202 may execute the above-mentioned S170 .
[0139] It should be noted that the cylindrical axis detection device provided in this embodiment can execute the method flow shown in the above method flow embodiment to achieve the corresponding technical effect. For the sake of brief description, for parts not mentioned in this embodiment, reference can be made to the corresponding contents in the above embodiment.
[0140] The embodiment of the present invention further provides a storage medium, which stores computer instructions and programs, and when the computer instructions and programs are read and run, the cylinder axis detection method of the above embodiment is executed. The storage medium may include a memory, a flash memory, a register, or a combination thereof.
[0141] An electronic device is provided below, which may be a mobile phone device, a computer device, a server device, a central control device of a radar system, etc. Figure 1 As shown, the above-mentioned cylindrical axis detection method can be implemented; specifically, the electronic device includes: a processor 10, a memory 11, and a bus 12. The processor 10 can be a CPU. The memory 11 is used to store one or more programs. When the one or more programs are executed by the processor 10, the cylindrical axis detection method of the above-mentioned embodiment is executed.
[0142] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
[0143] It will be apparent to those skilled in the art that the invention is not limited to the details of the exemplary embodiments described above and that the invention can be implemented in other specific forms without departing from the spirit or essential features of the invention. Therefore, the embodiments should be considered exemplary and non-limiting in all respects, and the scope of the invention is defined by the appended claims rather than the foregoing description, and it is intended that all variations falling within the meaning and scope of the equivalent elements of the claims be included in the invention. Any reference numeral in a claim should not be considered as limiting the claim to which it relates.
Claims
1. A method for detecting the axis of a cylinder, characterized in that: The method comprises: Perform a first voting statistics on the angle combination corresponding to the point in the point cloud data, wherein the angle combination includes a first angle and a second angle corresponding to the point, the first angle is the angle between the normal vector of the point and the z-axis, and the second angle is the angle between the projection of the normal vector of the point on the xy plane and the x-axis; Create an initial circle, the formula of the initial circle is: , , z = 0, 0 ≤ t ≤ 2π; The initial circle is rotated based on the rotation vector to obtain a rotated circle, and a second voting statistics is performed on the angle combination corresponding to each sampling point on the rotated circle, wherein the rotation vector is a normal vector corresponding to any type of the angle combination in the first voting statistics; Determine whether the statistical number of angle combinations of the target type is less than a first preset number, wherein the target type is the type corresponding to the angle combination with the largest statistical number in the second voting statistics; If not, it is confirmed that the cylinder axis is detected, the direction vector of the cylinder axis is the target vector, the target vector is the vector between the origin and the target position, and the target position is the coordinate position of the sampling point corresponding to the angle combination of the target type.
2. The cylindrical axis detection method according to claim 1, characterized in that: The step of performing a first voting and counting on the angle combinations corresponding to the midpoints of the point cloud data includes: Let i=1; Obtaining the normal vector corresponding to the i-th point in the point cloud data; Determine a first angle and a second angle of the i-th point based on a normal vector corresponding to the i-th point; Add 1 to the statistical number of angle combinations corresponding to the first angle and the second angle of the i-th point in the first voting device; Let i=i+1; Determine whether i is less than or equal to the total number of points, wherein the total number of points is the total number of points in the point cloud data; If so, repeatedly obtain the normal vector corresponding to the i-th point in the point cloud data until i is greater than the total number of points.
3. The cylindrical axis detection method according to claim 1, characterized in that: After performing a first voting and counting on the angle combinations corresponding to the midpoints of the point cloud data, the method further includes: The angle combination of the interference type in the first voting statistics is deleted, wherein the interference type is a type corresponding to the angle combination whose statistical quantity in the first voting statistics is less than a second preset quantity.
4. The cylindrical axis detection method according to claim 1, characterized in that: The step of rotating the initial circle based on the rotation vector to obtain a rotated circle, and performing a second voting and counting on the angle combination corresponding to each sampling point on the rotated circle comprises: Let h = 1, Determine a rotation matrix based on an h-th normal vector, wherein the h-th normal vector is a normal vector corresponding to the h-th type of angle combination in the first voting statistics; Rotating the initial circle based on the rotation matrix to obtain the rotated circle; Let j = 1; Obtaining the coordinate position corresponding to the j-th sampling point on the rotated circle, and determining the third angle and the fourth angle of the j-th sampling point; Add 1 to the statistical number of angle combinations corresponding to the third angle and the fourth angle of the j-th sampling point in the second voting device; Let j=j+1; Determine whether j is less than or equal to the number of dots after rotation; If j is less than or equal to the number of points on the circle after rotation, repeatedly obtain the coordinate position corresponding to the j-th sampling point on the circle after rotation, and determine the third angle and the fourth angle of the j-th sampling point; If j is greater than the number of dots after rotation, set h=h+1; Determine whether h is less than or equal to the total number of angle combination types in the first voting statistics; If h is less than or equal to the total number of angle combination types, the rotation matrix is repeatedly determined based on the hth normal vector until h is greater than the total number of angle combination types.
5. The method for detecting the axis of a cylinder according to claim 1, characterized in that: After rotating the initial circle based on the rotation vector to obtain a rotated circle, and performing a second voting statistics on the angle combination corresponding to each sampling point on the rotated circle, the method further includes: Determine the angle combination for the target type.
6. The method for detecting the axis of a cylinder according to claim 5, characterized in that: The step of determining the angle combination of the target type comprises: Let k=1, K=1, M≤0; Obtaining the statistical number of angle combinations of the kth type in the second voting statistics; Determine whether m is greater than M, where m represents the statistical number of angle combinations of the kth type in the second voting statistics; If m is greater than M, then let M=m, let K=k, let k=k+1; If m is less than or equal to M, let k=k+1; After setting k=k+1, determine whether k is less than or equal to the total number of angle combination types in the second voting statistics; If k is less than or equal to the total number of angle combination types in the second voting statistics, repeatedly obtain the statistical number of the kth type of angle combination in the second voting statistics, determine whether m is greater than M, until k is greater than the total number of angle combination types in the second voting device, and determine the Kth type of angle combination in the second voting statistics as the target type of angle combination.
7. A cylindrical axis detection device, characterized in that: The device comprises: A first processing unit is used to perform a first voting statistics on the angle combination corresponding to the point in the point cloud data, wherein the angle combination includes a first angle and a second angle corresponding to the point, the first angle is the angle between the normal vector of the point and the z-axis, and the second angle is the angle between the projection of the normal vector of the point on the xy plane and the x-axis; The first processing unit is further used to create an initial circle, and the formula of the initial circle is: , , z = 0, 0 ≤ t ≤ 2π; The first processing unit is further used to rotate the initial circle based on the rotation vector to obtain a rotated circle, and perform a second voting statistics on the angle combination corresponding to each sampling point on the rotated circle, wherein the rotation vector is a normal vector corresponding to any type of the angle combination in the first voting statistics; The first processing unit is further used to determine whether the statistical number of angle combinations of the target type is less than a first preset number, wherein the target type is the type corresponding to the angle combination with the largest statistical number in the second voting statistics; The second processing unit is used to confirm that the axis of the cylinder is detected if not, the direction vector of the axis of the cylinder is the target vector, the target vector is the vector between the origin and the target position, and the target position is the coordinate position of the sampling point corresponding to the angle combination of the target type.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
9. An electronic device, characterized in that: include: A processor and a memory, the memory being used to store one or more programs; When the one or more programs are executed by the processor, the method according to any one of claims 1 to 6 is implemented.
