Cylinder detection method and device, electronic equipment and storage medium
By slicing, projecting, simplifying and clustering the point cloud, the problem of difficulty in correctly detecting the dwarf cylinders in the point cloud in the prior art is solved, and the accurate detection of all dwarf cylinders in the point cloud is achieved.
Patent Information
- Application Number
- CN202510369870.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-27
- Publication Date
- 2025-04-25
- Estimated Expiration
- 2045-03-27
AI Technical Summary
The prior art is difficult to correctly detect the dwarf cylinder in the point cloud, especially when different projection parts contain circles, and it is impossible to accurately determine whether it contains circles, resulting in the inability to correctly detect all dwarf cylinders in the point cloud.
By slicing the point cloud to be detected, selecting the projection to project the slicing part, obtaining the projected point cloud, and simplifying it and clustering it. Finally, cylinder detection is performed on each clustered point cloud to determine all cylinders in the slicing part.
This method can detect all the dwarf cylinders in the point cloud more accurately, avoid detection errors caused by noise and complexity of the projection part, and improve the accuracy and completeness of the detection.
Smart Images

Figure CN119887767A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of point cloud processing, and in particular to a cylinder detection method, device, electronic equipment and storage medium. Background Art
[0002] When a welding robot welds a workpiece, it first needs to find the weld of the workpiece. The weld of the workpiece is often found by converting the workpiece into a workpiece point cloud and then finding the weld in the workpiece point cloud. To find the weld, it is necessary to first detect the cylinder in the workpiece point cloud and then find the weld through the tangent of the cylinder and the plane.
[0003] In the related art, to detect short cylinders in point clouds (for example, cylinders with a height of <= 30 mm), a cylinder detection method that is not based on point cloud registration can be used. First, all planes in the point cloud are detected, and then the planes are grouped according to the normal. Each group of planes corresponds to a point cloud segmentation scheme. After the point cloud is segmented using the plane, the segmented parts are projected onto the segmentation plane. Then, it is determined which segmented part's projected point cloud is most likely to correspond to a circle, and the circle is detected on the projected point cloud of that part, thereby detecting short cylinders in the point cloud.
[0004] However, this method may not be able to select the correct projection part, and when different projection parts all contain circles, it is also impossible to determine whether each part contains a circle. Therefore, this method may not be able to correctly detect the short cylinders in the point cloud, or may not be able to detect all the short cylinders in the point cloud. Summary of the invention
[0005] In view of this, an object of embodiments of the present invention is to provide a cylinder detection method, device, electronic device and storage medium 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: In a first aspect, an embodiment of the present invention provides a cylinder detection method, the method comprising: Segment the point cloud to be detected to obtain multiple segmented parts; For each of the cut parts, a projection plane is selected, and the cut part is projected to obtain a projection point cloud; Simplifying the projected point cloud to obtain a simplified projected point cloud; Clustering the simplified projection point cloud to obtain at least one clustered point cloud; Cylinder detection is performed on each of the clustered point clouds to determine all cylinders in the segmented parts.
[0007] Optionally, the point cloud to be detected is segmented to obtain multiple segmented parts, including: Using a plane detection algorithm to detect a plane in the point cloud to be detected; Grouping the planes according to the first normal of the planes to obtain at least one plane group; For each of the plane groups, the point cloud to be detected is segmented using the plane group to obtain a plurality of segmented parts.
[0008] Optionally, the simplifying the projected point cloud to obtain a simplified projected point cloud includes: For each point cloud point in the projected point cloud, determining whether the point cloud point has been processed; If not, in the projected point cloud, search for a point with the point cloud point as the center and a radius within a preset radius to obtain a first point to be processed; According to each of the first points to be processed, the center point of the points within the normal range of the point cloud is calculated, and the center point is stored in the simplified projected point cloud.
[0009] Optionally, calculating the center point of the points within the normal range of the point cloud points according to each of the first points to be processed includes: Obtain the second normal of the point cloud point, and initialize the center point set and the number of center points; For each of the first to-be-processed points, determining whether the first to-be-processed point has been processed; If not, calculating a vector from the point cloud point to the first point to be processed; Projecting the vector toward the second normal direction to obtain a vertical distance; When the vertical distance is less than the preset distance, the first to-be-processed point is added to the central point set, the number of central points is increased by 1, and the first to-be-processed point is marked as processed; Each of the first points to be processed is traversed to obtain the final set of center points and the number of center points, and the center points of the points within the normal range of the point cloud are calculated.
[0010] Optionally, clustering the simplified projection point cloud to obtain at least one clustered point cloud includes: Performing straight line detection on the simplified projected point cloud; For each detected straight line, calculate the distance from each point in the projected point cloud to the straight line, delete the points corresponding to the distances less than a preset threshold, and obtain a simplified projected point cloud after deleting the points; The simplified projected point cloud after the points are deleted is clustered to obtain at least one clustered point cloud.
[0011] Optionally, the performing cylinder detection on each of the clustered point clouds to determine all cylinders in the segmented portion includes: Select any of the clustered point clouds to perform arc detection, and when the clustered point cloud satisfies the arc feature, calculate the center and radius of the clustered point cloud; Determine a virtual cylinder according to the center and radius of the clustered point cloud and the projection surface; According to the cylindrical surface of the virtual cylinder, points on the cylindrical surface are found from the clustered point cloud to obtain the cylinder in the clustered point cloud; Each of the clustered point clouds is traversed to determine all cylinders in the segmented portion.
[0012] Optionally, the selecting any of the clustered point clouds for arc detection, and when the clustered point cloud satisfies arc features, calculating the center and radius of the clustered point cloud, includes: Simplifying the selected cluster point cloud to obtain a cluster simplified point cloud; Using a circle detection algorithm to detect a circle on the clustered simplified point cloud, to obtain a corresponding hypothetical circle and a center and radius of the hypothetical circle; Acquire points on the hypothetical circle in the cluster simplified point cloud, and cluster the points on the hypothetical circle to obtain at least one cluster; When the number of each cluster is 1, calculating the feature value of the point on the hypothetical circle; When the value of the number of points on the hypothetical circle divided by the number of points in the clustered simplified point cloud is greater than or equal to a first preset ratio, and the value of the feature value divided by the radius of the hypothetical circle is greater than or equal to a second preset ratio, the center of the circle and the radius are used as the center of the circle and the radius of the clustered point cloud.
[0013] In a second aspect, an embodiment of the present invention provides a cylinder detection device, the device comprising: A point cloud segmentation unit is used to segment the point cloud to be detected to obtain multiple segmented parts; A point cloud projection unit, configured to select a projection plane for each of the segmented parts, project the segmented parts, and obtain a projection point cloud; A projection simplification unit, used for simplifying the projection point cloud to obtain a simplified projection point cloud; A projection clustering unit, used for clustering the simplified projection point cloud to obtain at least one clustered point cloud; The cylinder detection unit is used to perform cylinder detection on each of the clustered point clouds to determine all cylinders in the segmented parts.
[0014] In a third aspect, an embodiment of the present invention provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, wherein the processor implements any of the above-described methods when executing the program.
[0015] In a fourth aspect, an embodiment of the present invention provides a storage medium having a computer program stored thereon, wherein the computer program implements any of the above-described methods when executed by a processor.
[0016] The embodiments of the present invention provide a cylinder detection method, device, electronic device and storage medium. The method divides the point cloud into plane groups, uses the plane groups to segment the point cloud, projects each segmented part to obtain a projected point cloud, and then simplifies the projected point cloud to obtain a simplified projected point cloud. The noise in the projected point cloud can be removed so that the simplified projected point cloud has a clearer curve structure. Straight line detection is performed on the simplified projected point cloud, and the straight line detection results are used to remove points in the simplified projected point cloud to further reduce noise. Finally, the simplified projected point cloud is clustered, and cylinder detection is performed on each cluster, so that all short cylinders in the point cloud can be detected more accurately.
[0017] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are 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 creative work.
[0019] Figure 1 A schematic structural block diagram of an electronic device provided by an embodiment of the present invention; Figure 2 A schematic flow chart of a cylinder detection method is provided for an embodiment of the present invention; Figure 3 A schematic flow chart of step S210 is provided for an embodiment of the present invention; Figure 4 A schematic flow chart of step S230 is provided for an embodiment of the present invention; Figure 5 A schematic diagram of a projected point cloud is provided for an embodiment of the present invention; Figure 6 A schematic diagram of a simplified projected point cloud is provided for an embodiment of the present invention; Figure 7A schematic flow chart of step S250 is provided for an embodiment of the present invention; Figure 8 A schematic diagram of circle detection using a broken line segment is provided for an embodiment of the present invention; Fig. 9 A schematic structural block diagram of a cylinder detection device is provided for an embodiment of the present invention.
[0020] Icon: 100 - electronic device; 101 - memory; 102 - communication interface; 103 - processor; 104 - bus; 300 - cylinder detection device; 310 - point cloud segmentation unit; 320 - point cloud projection unit; 330 - projection simplification unit; 340 - projection clustering unit; 350 - cylinder detection unit. DETAILED DESCRIPTION
[0021] 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.
[0022] 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.
[0023] 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.
[0024] 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.
[0025] As described in the background technology, when it is necessary to detect short cylinders with very small heights in point clouds (for example, height <= 30 mm), the short cylinder detection methods in point clouds can generally be divided into two categories, namely, methods based on point cloud registration and methods not based on point cloud registration. In the short cylinder detection method based on point cloud registration, it is necessary to first align the workpiece model point cloud with the collected workpiece point cloud, convert the reference plane normal in the weld database through the registration matrix, determine the reference plane position in the collected point cloud according to the converted reference plane normal, use a plane to segment the point cloud, project the segmented part onto the reference plane, and then detect the circle, thereby detecting the short cylinder in the point cloud. In the short cylinder detection method not based on point cloud registration, all planes in the point cloud are first detected, and then the planes are grouped according to the normal. Each group of planes corresponds to a point cloud segmentation scheme. After the point cloud is segmented by the plane, the segmented part is projected onto the segmentation plane. Then, it is determined which segmented part's projected point cloud is most likely to correspond to a circle, and the circle is detected on the projected point cloud of that part, thereby detecting the short cylinder in the point cloud.
[0026] For the short cylinder detection method based on point cloud registration, it is necessary to have a workpiece point cloud model and mark the normal of the reference surface. In model-free arc weld recognition, there is no workpiece point cloud model in advance, and it is impossible to mark the normal of the reference surface. In this case, the short cylinder detection method based on point cloud registration cannot be used. For the short cylinder detection method not based on point cloud registration, a simpler method is used to determine which segmented part of the projected point cloud is most likely to correspond to a circle, that is, to select the projected part with the largest eigenvalue for circle detection. This method may not be able to select the correct projected part, and when different projected parts contain circles, it is also impossible to determine whether each part contains a circle. Therefore, this method may not be able to correctly detect the short cylinder in the point cloud, or it may not be able to detect all the short cylinders in the point cloud.
[0027] Based on the above situation, an embodiment of the present invention provides a cylinder detection method, device, electronic device and storage medium, which divides the point cloud to be detected, projects and simplifies the divided parts, and then clusters them. Cylinder detection is performed on each cluster, so that all short cylinders in the point cloud can be detected more accurately without aligning the workpiece model point cloud with the collected workpiece point cloud.
[0028] To implement the process steps and functions of each example of the present invention, please refer to Figure 1 , Figure 1 A schematic structural block diagram of an electronic device provided in an embodiment of the present invention. The electronic device 100 includes a memory 101 and a processor 103, and the memory 101 and the processor 103 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 104 or signal lines. The memory 101 can be used to store software programs and modules, and the processor 103 executes the software programs and modules stored in the memory 101, thereby performing various functional applications and data processing.
[0029] The electronic device 100 may be, but is not limited to, a personal computer (PC), a server, a distributed computer, etc. It is understandable that the electronic device 100 is not limited to a physical server, but may also be a virtual machine on a physical server, a virtual machine built on a cloud platform, etc., which can provide the same functions as the server or virtual machine. The operating system of the electronic device 100 may be, but is not limited to, a Windows system, a Linux system, etc.
[0030] Among them, the memory 101 can 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.
[0031] The communication connection between the electronic device 100 and an external device is achieved through at least one communication interface 102 (which can be wired or wireless).
[0032] The processor 103 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the embodiment of the present invention can be completed by the hardware integrated logic circuit in the processor 103 or the instructions in the form of software. The processor 103 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can 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, discrete hardware components.
[0033] Understandably, Figure 1 The structure shown is for illustration only. 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.
[0034] The following is an exemplary description of the cylinder detection method provided by the present invention. Specifically, Figure 2 A flow chart of a cylinder detection method is provided for an embodiment of the present invention, see Figure 2 , the execution subject of this method can be the above Figure 1 The electronic device 100 shown in FIG. 1 includes: Figure 2 The following steps are shown: S210: Segment the point cloud to be detected to obtain multiple segmented parts.
[0035] A 3D camera can be used to photograph the workpiece to obtain a point cloud of the workpiece, which can be processed as a point cloud to be detected.
[0036] After the point cloud to be detected is divided into multiple parts, each part is processed separately.
[0037] S220: For each segmented part, select a projection plane, project the segmented part, and obtain a projection point cloud.
[0038] The point cloud to be detected is three-dimensional, and the segmented parts are still three-dimensional. Now a plane is selected as a projection plane, and the segmented parts are projected onto the projection plane to obtain a projected point cloud, so as to process the projected point cloud on the plane.
[0039] The method of obtaining the projection point cloud is to calculate the projection point on the selected projection surface for each point in the segmented part. Assuming that the equation of the projection surface is ax+by+cz+d=0, the projection point of the point (x, y, z) in the segmented part on the projection surface is (x′, y′, z′). The projection point can be calculated by the following steps: Compute the perpendicular from a point to the projection plane:
[0040] t are the parameters of the perpendicular line from the point (x, y, z) to the plane.
[0041] Calculate the projected point coordinates:
[0042] Collect all the projection points (x′, y′, z′) to form a new point cloud, which is the projected point cloud.
[0043] S230: Simplify the projected point cloud to obtain a simplified projected point cloud.
[0044] Since there may be a lot of noise in the projected point cloud, and there are undulating points on the plane or cylindrical surface of the point cloud to be detected, these undulating points will become undulating points around the projection curve after projection. Simplifying the projected point cloud can remove these undulating points to a large extent, so that the simplified projected point cloud can have a clearer curve structure.
[0045] S240: Clustering the simplified projection point cloud to obtain at least one clustered point cloud.
[0046] The simplified projected point cloud is clustered, that is, each point in the simplified projected point cloud is divided into at least one category.
[0047] There are many ways of clustering, such as K-means clustering, DBSCAN clustering, and Euclidean clustering.
[0048] S250: Perform cylinder detection on each cluster point cloud to determine all cylinders in the segmented part.
[0049] By performing cylinder detection on each cluster point cloud, all cylinders in the segmented part can be determined. By performing the same process on each segmented part, all cylinders in the point cloud to be detected can be determined.
[0050] This method divides the point cloud to be detected, projects and simplifies the divided parts, and then clusters them. Cylinder detection is performed on each cluster, so that all short cylinders in the point cloud can be detected more accurately.
[0051] There are many ways to segment the point cloud to be detected. You can directly use multiple planes to segment. In order to detect the cylinder more accurately, in one possible implementation, the point cloud to be detected can be segmented into groups, that is, using multiple plane groups, and each plane group is segmented separately. See Figure 3 , the above step S210 may include the following steps: S211: Use a plane detection algorithm to detect a plane in the point cloud to be detected.
[0052] The plane detection algorithm may be a surface growth algorithm based on 3D Hough transform, a RANSAC algorithm, a region growing algorithm, etc., which is not limited here.
[0053] Through the plane detection algorithm, multiple planes in the point cloud to be detected can be obtained.
[0054] S212: Grouping the planes according to the first normal of the planes to obtain at least one plane group.
[0055] By grouping the planes according to their first normals, planes with similar normals can be grouped together. For example, planes with normals with an angle of less than 10° can be grouped together.
[0056] S213: For each plane group, segment the point cloud to be detected using the plane group to obtain multiple segmented parts.
[0057] Use a plane group to segment the point cloud to be detected, and the number of segmented parts can be obtained as m i = n i + 1, among which, n i is the number of planes in the i-th plane group. If there are n plane groups in total, the number of parts cut out of the point cloud to be detected is .
[0058] In a possible implementation, when simplifying the projected point cloud, a simplified projected point cloud can be initialized first. Currently, the simplified projected point cloud is empty. A kdtree can also be established for the projected point cloud. The kdtree can effectively accelerate the search and query operations of point cloud data. See Figure 4 , the above step S230 may include the following steps: S231: For each point cloud point in the projected point cloud, determine whether the point cloud point has been processed.
[0059] Each point cloud point in the projected point cloud is processed separately, and first determine whether the point cloud point has been processed. The judgment method can be: record the i-th point cloud point as pi , p i (0) If it is not a number (NaN), it is considered that the point cloud point has been processed. i (0) If it is not NaN, it is considered that the point cloud point has not been processed.
[0060] S232: If not, in the projected point cloud, search for a point with the point cloud point as the center and a radius within a preset radius to obtain a first point to be processed.
[0061] If the point cloud point has been processed, skip it and process the next point cloud point.
[0062] If the point cloud point has not been processed, the point cloud point is processed to find the first point to be processed with the point cloud point as the center and the radius as the preset radius, so as to be processed later.
[0063] For example, a point within a radius of 10 with the point cloud point as the center can be searched in the kdtree established above as the first point to be processed.
[0064] S233: Calculate the center point of the points within the normal range of the point cloud according to each first point to be processed, and store the center point in the simplified projection point cloud.
[0065] Optionally, the step of calculating the center point of the points within the normal range of the point cloud may include: S2331: Obtain the second normal of the point cloud point, and initialize the center point set and the number of center points.
[0066] The second normal is the normal of the plane where the point cloud point is located, denoted as n i , the initialization center point set and the number of center points are recorded as p center and sum .
[0067] S2332: For each first point to be processed, determine whether the first point to be processed has been processed.
[0068] For each processing point, the method of determining whether it has been processed may be consistent with the method of determining whether the point cloud point has been processed.
[0069] If it has been processed, skip the first point to be processed and process the next first point to be processed.
[0070] S2333: If not, calculate the vector of the point cloud point pointing to the first point to be processed.
[0071] S2334: Project the vector toward the second normal direction to obtain the vertical distance.
[0072] S2335: When the vertical distance is less than the preset distance, the first point to be processed is added to the center point set, the number of center points is increased by 1, and the first point to be processed is marked as processed.
[0073] S2336: traverse each first point to be processed, obtain the final set of center points and the number of center points, and calculate the center points of the points within the normal range of the point cloud.
[0074] If the first point to be processed has not been processed, the vector pointing to the first point to be processed is calculated and recorded as p diff =p j -p i , p j represents the first point to be processed, p i Represents the point cloud point, p diff Towards the second normal n i Direction projection, get the vertical distance, determine whether the vertical distance is less than the preset distance, the determination can be expressed as: (p diff - (p diff ∙ n i ) n i ).norm() <= preset distance, if yes, it indicates the first point to be processed p j Point in this point cloud p i The normal range of the point, the first point to be processed p j Add to the center point collection p center , the number of center points sum Add 1 to mark the first pending point as processed.
[0075] By traversing each first point to be processed, the point cloud point can be obtained p i The final set of center points p center and the number of center points sum ,use p center / sum Indicates that at this point cloud point p i The center point of the points within the normal range.
[0076] The projected point cloud is simplified in this way to obtain a simplified projected point cloud. Figure 5 , Figure 6 ,The simplified projected point cloud removes the undulating points around the curve and has a clear curve structure.
[0077] The simplified projected point cloud may be directly clustered, and some data may be cleared again, for example, some straight line data may be deleted. In a possible implementation, the above step S240 may include the following steps: S241: Perform straight line detection on the simplified projection point cloud.
[0078] There is no limitation on the line detection algorithm, which may include but is not limited to Hough transform, RANSAC algorithm, and edge detection-based methods.
[0079] S242: For each detected straight line, calculate the distance from each point in the projected point cloud to the straight line, delete the points corresponding to the distances less than a preset threshold, and obtain a simplified projected point cloud after deleting the points.
[0080] Once the lines are detected, they can be used to remove points from the projected point cloud. This can be done by calculating the distance from the point to the line. If the distance from the point to the line is less than a preset threshold, the point is considered to be on the line and is removed.
[0081] For a point (x, y) and a line ax+by+c=0 in a two-dimensional point cloud, the distance d from the point to the line can be calculated by the following formula:
[0082] S243: Clustering the simplified projected point cloud after the points are deleted to obtain at least one clustered point cloud.
[0083] In one possible implementation, an arc judgment algorithm can be used to detect circles in each cluster and then detect cylinders, see Figure 7 , the above step S250 may include the following steps: S251: Select any cluster point cloud for arc detection, and when the cluster point cloud satisfies the arc feature, calculate the center and radius of the cluster point cloud.
[0084] Whether the curve corresponding to each cluster is an arc. When projecting on a cylindrical surface, the projection curve is an arc. When projecting on a plane, the projection curve is a straight line or a broken line. If the projection curve is an arc, it satisfies the arc feature and calculates the center and radius of the cluster point cloud.
[0085] S252: Determine a virtual cylinder according to the center, radius and projection surface of the clustered point cloud.
[0086] The radius of the virtual cylinder is the radius of the clustered point cloud, the axis point of the virtual cylinder is the center of the clustered point cloud, and the axial direction of the virtual cylinder is the normal direction of the projection surface.
[0087] S253: According to the cylindrical surface of the virtual cylinder, points on the cylindrical surface are found from the clustered point cloud to obtain the cylinder in the clustered point cloud.
[0088] Calculate points in clustered point cloud To find the distance from the cylindrical surface of the imaginary cylinder, first calculate the distance from the point to the axis point:
[0089] in, is the axis point of the virtual cylinder.
[0090] Then calculate the normal from the point to the axis point: The distance of the plane:
[0091] in, is the axial direction of the virtual cylinder.
[0092] Finally, calculate the distance from the point to the cylinder:
[0093] Where r is the radius of the virtual cylinder.
[0094] if Threshold, then the point Located on the cylindrical surface of the virtual cylinder.
[0095] S254: traverse each cluster point cloud to determine all cylinders in the segmented part.
[0096] After performing this processing on each cluster point cloud, all cylinders in the segmented part, that is, points on the cylindrical surface, can be obtained.
[0097] In a possible implementation, the step S251 of calculating the center and radius of the cluster point cloud includes the following steps: S2511: Simplify the selected cluster point cloud to obtain a cluster simplified point cloud.
[0098] The simplified processing of the clustered point cloud may be consistent with the simplified processing of the above step S230.
[0099] S2512: Use a circle detection algorithm to detect circles on the clustered simplified point cloud to obtain corresponding hypothetical circles and the center and radius of the hypothetical circles.
[0100] We do not know whether the curve of the current clustered simplified point cloud is an arc. We can first assume that it is an arc and use the circle detection algorithm to detect the circle on the curve to obtain its corresponding center and radius.
[0101] S2513: Obtain points on the hypothetical circle in the cluster simplified point cloud, cluster the points on the hypothetical circle, and obtain at least one cluster.
[0102] By using the circle formed by the center and radius of the hypothetical circle, it is possible to know which points in the clustered simplified point cloud are on the circle, and then cluster these points. The clustering method can be the same as the above step S240.
[0103] S2514: When the number of each cluster is 1, calculate the feature value of the point on the hypothetical circle.
[0104] First, determine whether the number of clusters is 1. If the number of clusters is not 1, the curve of the current cluster must not be a circle. Figure 8 , a circle can also be obtained by performing circle detection on a polyline segment. When judging which points are on this circle, it can be seen that there are two segments of points on this circle. At this time, the points on the circle correspond to two clusters. Therefore, only when the current number of clusters is 1 can it be a circle. Then further judge whether the cluster is a circle and calculate the eigenvalues of the points on the assumed circle.
[0105] The three scales of the minimum bounding box of a curve. For the projection point, the height is 0, so we only care about the width and length and take the width of the minimum bounding box as the eigenvalue.
[0106] S2515: When the value of the number of points on the hypothetical circle divided by the number of points in the clustered simplified point cloud is greater than or equal to a first preset ratio, and the value of the eigenvalue divided by the radius of the hypothetical circle is greater than or equal to a second preset ratio, the center and radius of the circle are used as the center and radius of the clustered point cloud.
[0107] When these two conditions are met, the clustered simplified point cloud is considered to be a circle, and the center and radius obtained in step S2512 are used as the center and radius of the clustered point cloud.
[0108] Optionally, the first preset ratio is 0.5, and the second preset ratio is 0.5.
[0109] The reasons for judgment are: 1. If it is a straight line, the number of its points on the hypothetical circle is only a small segment, accounting for a small proportion of the number of points in the clustered simplified point cloud of this segment. 2. The width of the part corresponding to the straight line segment is very small, and when performing circle detection, it is often detected as a large circle. At this time, the eigenvalue / radius will get a very small value, so it is judged to be a straight line rather than an arc.
[0110] Furthermore, the embodiment of the present invention also provides a cylindrical detection device, see Fig. 9 , the cylinder detection device 300 comprises: The point cloud segmentation unit 310 is used to segment the point cloud to be detected to obtain multiple segmented parts.
[0111] The point cloud projection unit 320 is used to select a projection plane for each segmented part, project the segmented part, and obtain a projected point cloud.
[0112] The projection simplification unit 330 is used to simplify the projection point cloud to obtain a simplified projection point cloud.
[0113] The projection clustering unit 340 is used to cluster the simplified projection point cloud to obtain at least one clustered point cloud.
[0114] The cylinder detection unit 350 is used to perform cylinder detection on each cluster point cloud to determine all cylinders in the segmented part.
[0115] In summary, the embodiments of the present invention provide a cylinder detection method, device, electronic device and storage medium, which divide the point cloud into plane groups, use the plane groups to segment the point cloud, project each segmented part to obtain a projected point cloud, and then simplify the projected point cloud to obtain a simplified projected point cloud. The noise in the projected point cloud can be removed, so that the simplified projected point cloud has a clearer curve structure, and straight line detection is performed on the simplified projected point cloud. The straight line detection results are used to remove points in the simplified projected point cloud to further reduce noise. Finally, the simplified projected point cloud is clustered, and cylinder detection is performed on each cluster, so that all short cylinders in the point cloud can be detected more accurately.
[0116] In the embodiments provided by the present invention, 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 multiple embodiments of the present invention. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of the code, and a module, a program segment or a part of the code contains one or more executable instructions for implementing the specified logical functions. 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 flowchart, and the combination of boxes in the block diagram and / or 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.
[0117] In addition, the functional modules in the various embodiments of the present invention may be integrated together to form an independent part, or each module may exist independently, or two or more modules may be integrated to form an independent part.
[0118] If the function is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, 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. The computer software product is stored in a computer-readable storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0119] The above are only preferred embodiments of the present invention and are 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.
[0120] 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 in all respects as exemplary and non-restrictive, 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 range of 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 a cylinder, characterized in that: The method comprises: Segment the point cloud to be detected to obtain multiple segmented parts; For each of the cut parts, a projection plane is selected, and the cut part is projected to obtain a projection point cloud; Simplifying the projected point cloud to obtain a simplified projected point cloud; Clustering the simplified projection point cloud to obtain at least one clustered point cloud; Cylinder detection is performed on each of the clustered point clouds to determine all cylinders in the segmented parts.
2. The method according to claim 1, characterized in that The point cloud to be detected is segmented to obtain multiple segmented parts, including: Using a plane detection algorithm to detect a plane in the point cloud to be detected; Grouping the planes according to the first normal of the planes to obtain at least one plane group; For each of the plane groups, the point cloud to be detected is segmented using the plane group to obtain a plurality of segmented parts.
3. The method according to claim 1, characterized in that The step of simplifying the projected point cloud to obtain a simplified projected point cloud includes: For each point cloud point in the projected point cloud, determining whether the point cloud point has been processed; If not, in the projected point cloud, search for a point with the point cloud point as the center and a radius within a preset radius to obtain a first point to be processed; According to each of the first points to be processed, the center point of the points within the normal range of the point cloud is calculated, and the center point is stored in the simplified projected point cloud.
4. The method according to claim 3, characterized in that The step of calculating the center point of the points within the normal range of the point cloud points according to each of the first points to be processed includes: Obtain the second normal of the point cloud point, and initialize the center point set and the number of center points; For each of the first to-be-processed points, determining whether the first to-be-processed point has been processed; If not, calculating a vector from the point cloud point to the first point to be processed; Projecting the vector toward the second normal direction to obtain a vertical distance; When the vertical distance is less than the preset distance, the first to-be-processed point is added to the central point set, the number of central points is increased by 1, and the first to-be-processed point is marked as processed; Each of the first points to be processed is traversed to obtain the final set of center points and the number of center points, and the center points of the points within the normal range of the point cloud are calculated.
5. The method according to claim 1, characterized in that The step of clustering the simplified projected point cloud to obtain at least one clustered point cloud comprises: Performing straight line detection on the simplified projected point cloud; For each detected straight line, calculate the distance from each point in the projected point cloud to the straight line, delete the points corresponding to the distances less than a preset threshold, and obtain a simplified projected point cloud after deleting the points; The simplified projected point cloud after the points are deleted is clustered to obtain at least one clustered point cloud.
6. The method according to claim 1, characterized in that The performing cylinder detection on each of the clustered point clouds to determine all cylinders in the segmented portion includes: Select any of the clustered point clouds to perform arc detection, and when the clustered point cloud satisfies the arc feature, calculate the center and radius of the clustered point cloud; Determine a virtual cylinder according to the center and radius of the clustered point cloud and the projection surface; According to the cylindrical surface of the virtual cylinder, points on the cylindrical surface are found from the clustered point cloud to obtain the cylinder in the clustered point cloud; Each of the clustered point clouds is traversed to determine all cylinders in the segmented portion.
7. The method according to claim 6, characterized in that The selecting any of the clustered point clouds for arc detection, and when the clustered point cloud satisfies the arc feature, calculating the center and radius of the clustered point cloud, includes: Simplifying the selected cluster point cloud to obtain a cluster simplified point cloud; Using a circle detection algorithm to detect a circle on the clustered simplified point cloud, to obtain a corresponding hypothetical circle and a center and radius of the hypothetical circle; Acquire points on the hypothetical circle in the cluster simplified point cloud, and cluster the points on the hypothetical circle to obtain at least one cluster; When the number of each cluster is 1, calculating the characteristic value of the point on the hypothetical circle; When the value of the number of points on the hypothetical circle divided by the number of points in the clustered simplified point cloud is greater than or equal to a first preset ratio, and the value of the feature value divided by the radius of the hypothetical circle is greater than or equal to a second preset ratio, the center of the circle and the radius are used as the center of the circle and the radius of the clustered point cloud.
8. A cylindrical object detection device, characterized in that: The device comprises: A point cloud segmentation unit is used to segment the point cloud to be detected to obtain multiple segmented parts; A point cloud projection unit, configured to select a projection plane for each of the cut parts, project the cut parts, and obtain a projection point cloud; A projection simplification unit, used for simplifying the projection point cloud to obtain a simplified projection point cloud; A projection clustering unit, used for clustering the simplified projection point cloud to obtain at least one clustered point cloud; The cylinder detection unit is used to perform cylinder detection on each of the clustered point clouds to determine all cylinders in the segmented parts.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that: When the processor executes the program, the method according to any one of claims 1 to 7 is implemented.
10. A 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 7 is implemented.
Citation Information
Patent Citations
Point cloud panoramic segmentation method and device
CN113379748A
Point cloud cylinder detection method and device
CN117726668A
Fitting method and system of incomplete cylindrical surface point cloud, medium and equipment
CN118587268A
Method and device for extracting centerline of quasi-cylinder by using point cloud
CN119417882A
Lidar noise removal using image pixel clusterings
US20190287254A1
Cited By
Angle measuring method for cylindrical detector
CN122050762A
A method of angle measurement for a cylindrical detector
CN122050762B
Method for detecting cylinder in point cloud and related equipment
CN122434933A