Cylinder detection method, device, electronic device and storage medium
By performing slicing, projecting and simplifying processing of point clouds, combined with clustering technology, the problem of being unable to accurately detect low cylinders in the existing technology is solved, and high-precision cylinder detection under model-free conditions is achieved.
Patent Information
- Application Number
- CN202510369870.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-27
- Publication Date
- 2025-08-12
- Estimated Expiration
- 2045-03-27
AI Technical Summary
The prior art cannot accurately detect dwarf cylinders in point clouds, especially in the absence of workpiece point cloud models, resulting in the inability to correctly identify or detect all dwarf cylinders.
By slicing the point cloud to be detected, selecting the projection surface for projection, simplifying the processing, clustering, and finally cylindrical detection of each clustered point cloud, using a plane group to slicing the point cloud and projecting and simplifying it to remove noise and improve detection accuracy.
This enables more accurate detection of all dwarf cylinders in point clouds without the need for workpiece models, improving the accuracy and completeness of detection.
Smart Images

Figure CN119887767B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of point cloud processing technology, 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 seam of the workpiece. The weld seam of the workpiece is often found by converting the workpiece into a workpiece point cloud and then finding the weld seam in the workpiece point cloud. To find the weld seam, it is necessary to first detect the cylinder in the workpiece point cloud and then find the weld seam through the tangent of the cylinder and the plane.
[0003] In related technologies, 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. The circle is detected on the projected point cloud of this part, thereby detecting short cylinders in the point cloud.
[0004] However, this method may not be able to select the correct projected part, and when different projected 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 short cylinders in the point cloud, or may not be able to detect all 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, apparatus, electronic device, and storage medium to at least partially improve the above-mentioned problem.
[0006] In order to achieve the above objectives, the technical solutions adopted in the embodiments of the present invention are as follows:
[0007] In a first aspect, an embodiment of the present invention provides a cylinder detection method, the method comprising:
[0008] Segment the point cloud to be detected to obtain multiple segmented parts;
[0009] For each of the segmented parts, selecting a projection plane, projecting the segmented part, and obtaining a projected point cloud;
[0010] Simplifying the projected point cloud to obtain a simplified projected point cloud;
[0011] Clustering the simplified projected point cloud to obtain at least one clustered point cloud;
[0012] Cylinder detection is performed on each of the clustered point clouds to determine all cylinders in the segmented portion.
[0013] Optionally, the point cloud to be detected is segmented to obtain multiple segmented parts, including:
[0014] Detecting a plane in the point cloud to be detected using a plane detection algorithm;
[0015] Grouping the planes according to the first normal directions of the planes to obtain at least one plane group;
[0016] 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.
[0017] Optionally, the simplifying the projected point cloud to obtain a simplified projected point cloud includes:
[0018] For each point cloud point in the projected point cloud, determining whether the point cloud point has been processed;
[0019] If not, searching for a point within a preset radius with the point cloud point as the center in the projected point cloud to obtain a first point to be processed;
[0020] Based on each of the first points to be processed, a center point of the points within the normal range of the point cloud is calculated, and the center point is stored in a simplified projected point cloud.
[0021] Optionally, calculating the center point of the points within the normal range of the point cloud points based on each of the first points to be processed includes:
[0022] Obtain the second normal of the point cloud point, and initialize the center point set and the number of center points;
[0023] For each of the first to-be-processed points, determining whether the first to-be-processed point has been processed;
[0024] If not, calculating a vector from the point cloud point to the first point to be processed;
[0025] Projecting the vector toward the second normal direction to obtain a vertical distance;
[0026] If the vertical distance is less than the preset distance, the first to-be-processed point is added to the set of central points, the number of central points is increased by 1, and the first to-be-processed point is marked as processed;
[0027] 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.
[0028] Optionally, clustering the simplified projected point cloud to obtain at least one clustered point cloud includes:
[0029] Performing line detection on the simplified projected point cloud;
[0030] For each detected straight line, calculate the distance from each point in the projected point cloud to the straight line, delete the points whose distance is less than a preset threshold, and obtain a simplified projected point cloud after deleting the points;
[0031] Clustering is performed on the simplified projected point cloud after the points are deleted to obtain at least one clustered point cloud.
[0032] Optionally, performing cylinder detection on each of the clustered point clouds to determine all cylinders in the segmented portion includes:
[0033] 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;
[0034] Determining a virtual cylinder according to the center and radius of the clustered point cloud and the projection surface;
[0035] 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;
[0036] Each of the clustered point clouds is traversed to determine all cylinders in the segmented portion.
[0037] Optionally, the selecting any one 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:
[0038] Simplifying the selected cluster point cloud to obtain a cluster simplified point cloud;
[0039] 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;
[0040] Obtaining points on the hypothetical circle in the clustered simplified point cloud, and clustering the points on the hypothetical circle to obtain at least one cluster;
[0041] When the number of each cluster is 1, calculating the characteristic values of the points on the hypothetical circle;
[0042] 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 of the circle and the radius are used as the center of the circle and the radius of the clustered point cloud.
[0043] In a second aspect, an embodiment of the present invention provides a cylinder detection device, the device comprising:
[0044] A point cloud segmentation unit is used to segment the point cloud to be detected to obtain multiple segmented parts;
[0045] a point cloud projection unit, configured to select a projection plane for each of the segmented parts, project the segmented parts, and obtain a projected point cloud;
[0046] a projection simplification unit, configured to simplify the projected point cloud to obtain a simplified projected point cloud;
[0047] a projection clustering unit, configured to cluster the simplified projection point cloud to obtain at least one clustered point cloud;
[0048] 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.
[0049] 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.
[0050] 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.
[0051] 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.
[0052] In order to make the above-mentioned objects, features and advantages of the present application 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
[0053] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments. It should be understood that the following drawings only illustrate certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without paying any creative work.
[0054] Figure 1 A schematic structural block diagram of an electronic device provided by an embodiment of the present invention;
[0055] Figure 2 A schematic flow chart of a cylinder detection method is provided for an embodiment of the present invention;
[0056] Figure 3 A schematic flow chart of step S210 is provided for an embodiment of the present invention;
[0057] Figure 4 A schematic flow chart of step S230 is provided for an embodiment of the present invention;
[0058] Figure 5 A schematic diagram of a projected point cloud is provided for an embodiment of the present invention;
[0059] Figure 6 A schematic diagram of a simplified projected point cloud is provided for an embodiment of the present invention;
[0060] Figure 7 A schematic flow chart of step S250 is provided for an embodiment of the present invention;
[0061] Figure 8 A schematic diagram of circle detection using a broken line segment is provided for an embodiment of the present invention;
[0062] Figure 9 A schematic structural block diagram of a cylinder detection device is provided for an embodiment of the present invention.
[0063] 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
[0064] To make the objectives, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions of the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only 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 herein can be arranged and designed in various different configurations.
[0065] 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 as claimed, but rather merely represents selected embodiments of the present invention. All other embodiments derived by persons of ordinary skill in the art based on the embodiments of the present invention without creative effort shall fall within the scope of protection of the present invention.
[0066] It should be noted that similar reference numerals and letters represent similar items in the following drawings. Therefore, once an item is defined in one drawing, it does not need to be further defined or explained in subsequent drawings. At the same time, in the description of the present invention, the terms "first", "second", etc. are used only to distinguish the description and should not be understood as indicating or implying relative importance.
[0067] It should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply the existence of any such actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or device comprising the element.
[0068] As described in the background technology, when it is necessary to detect short cylinders with very small height in the point cloud (for example, height <= 30 mm), the short cylinder detection methods in the point cloud 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 to detect 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 using 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. The circle is detected on the projected point cloud of this part, thereby detecting short cylinders in the point cloud.
[0069] Point cloud registration-based short cylinder detection requires a workpiece point cloud model and the normal of the reference surface to be marked. However, in model-free circular arc weld recognition, without a prior workpiece point cloud model and without the normal of the reference surface to be marked, the point cloud registration-based short cylinder detection method cannot be used. Short cylinder detection methods not based on point cloud registration employ a simpler approach to determine which segment's projected point cloud most likely corresponds to a circle: the projected segment with the largest eigenvalue is selected for circle detection. This method may not select the correct projected segment, and when different projected segments all contain circles, it is impossible to determine whether each segment contains a circle. Therefore, this method may not correctly detect short cylinders in the point cloud, or may not detect all short cylinders in the point cloud.
[0070] Based on the above situation, an embodiment of the present invention provides a cylinder detection method, device, electronic device and storage medium. By dividing the point cloud to be detected, projecting and simplifying the divided parts, clustering them, and performing cylinder detection on each cluster, all short cylinders in the point cloud can be detected more accurately without having to align the workpiece model point cloud with the collected workpiece point cloud.
[0071] To implement the process steps and functions of each example of the present invention, please refer to Figure 1 , Figure 1This is a schematic 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. The memory 101 and processor 103 are electrically connected to each other, directly or indirectly, to enable data transmission or interaction. For example, these components can be electrically connected to each other via 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.
[0072] The electronic device 100 may be, but is not limited to, a personal computer (PC), a server, a distributed computer, or the like. It is understood that the electronic device 100 is not limited to a physical server and may also be a virtual machine on a physical server, a virtual machine built on a cloud platform, or other computer that provides the same functionality as the server or virtual machine. The operating system of the electronic device 100 may be, but is not limited to, Windows, Linux, or the like.
[0073] The memory 101 may be, but is not limited to, a random access memory (RAM), a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), etc.
[0074] 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).
[0075] Processor 103 may be an integrated circuit chip with signal processing capabilities. During implementation, each step of the embodiments of the present invention may be completed by hardware integrated logic circuits in processor 103 or by software instructions. Processor 103 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 gate or transistor logic devices, or discrete hardware components.
[0076] I understand. Figure 1 The structure shown is for illustration only. The electronic device 100 may further include Figure 1 More or fewer components than shown, or with Figure 1 Different configurations shown. Figure 1 Each component shown in the figure can be implemented by hardware, software or a combination thereof.
[0077] 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. Figure 2 , the execution subject of this method can be the above Figure 1 The electronic device 100 shown in FIG. 1 includes the following steps: Figure 2 The following steps are shown:
[0078] S210: Segment the point cloud to be detected to obtain multiple segmented parts.
[0079] A 3D camera can be used to photograph the workpiece, obtain a point cloud of the workpiece, and process the point cloud as a point cloud to be detected.
[0080] After the point cloud to be detected is divided into multiple parts, each part is processed separately.
[0081] S220: For each segmented part, select a projection plane, project the segmented part, and obtain a projected point cloud.
[0082] The point cloud to be detected is three-dimensional, and the segmented part is still three-dimensional. Now a plane is selected as the projection plane, and the segmented part is projected onto the projection plane to obtain a projected point cloud so that the projected point cloud can be processed on the plane.
[0083] The projected point cloud can be obtained by calculating 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:
[0084] Compute the perpendicular from a point to the projection plane:
[0085]
[0086] t are the parameters of the perpendicular line from the point (x, y, z) to the plane.
[0087] Calculate the projected point coordinates:
[0088]
[0089] Collect all the projection points (x′, y′, z′) to form a new point cloud, which is the projected point cloud.
[0090] S230: Simplify the projected point cloud to obtain a simplified projected point cloud.
[0091] 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.
[0092] S240: Clustering the simplified projected point cloud to obtain at least one clustered point cloud.
[0093] Clustering is performed on the simplified projected point cloud, that is, each point in the simplified projected point cloud is divided into at least one category.
[0094] There are many clustering methods, such as K-means clustering, DBSCAN clustering, and Euclidean clustering.
[0095] S250: Perform cylinder detection on each cluster point cloud to determine all cylinders in the segmented part.
[0096] By performing cylinder detection on each clustered 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.
[0097] 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.
[0098] There are many ways to segment the point cloud to be detected. You can directly use multiple planes to segment it. In order to detect cylinders more accurately, in one possible implementation, the point cloud to be detected can be grouped and segmented, 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:
[0099] S211: Detecting a plane in the point cloud to be detected using a plane detection algorithm.
[0100] The plane detection algorithm may be a surface growing algorithm based on 3D Hough transform, a RANSAC algorithm, a region growing algorithm, etc., which is not limited here.
[0101] Through the plane detection algorithm, multiple planes in the point cloud to be detected can be obtained.
[0102] S212: Grouping the planes according to the first normal of each plane to obtain at least one plane group.
[0103] By grouping the planes according to their first normals, planes with similar normals can be grouped together. For example, planes with an angle between their normals less than 10° can be grouped together.
[0104] S213: For each plane group, segment the point cloud to be detected using the plane group to obtain multiple segmented parts.
[0105] 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, the number of parts of the point cloud to be detected is .
[0106] In one 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:
[0107] S231: For each point cloud point in the projected point cloud, determine whether the point cloud point has been processed.
[0108] Each 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 p i , p i (0) If it is not a number (NaN), it is considered that the point cloud point has been processed, p i (0) If it is not NaN, it is considered that the point cloud point has not been processed.
[0109] S232: If not, search the projected point cloud 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.
[0110] If the point cloud point has been processed, skip it and process the next point cloud point.
[0111] 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 within the preset radius for subsequent processing.
[0112] 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.
[0113] 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 projected point cloud.
[0114] Optionally, the step of calculating the center point of the points within the point cloud point normal range may include:
[0115] S2331: Get the second normal of the point cloud point and initialize the center point set and the number of center points.
[0116] 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 .
[0117] S2332: For each first point to be processed, determine whether the first point to be processed has been processed.
[0118] For each processing point, the method of determining whether it has been processed may be consistent with the method of determining whether a point cloud point has been processed.
[0119] If it has been processed, skip the first point to be processed and process the next first point to be processed.
[0120] S2333: If not, calculate the vector of the point cloud point pointing to the first point to be processed.
[0121] S2334: Project the vector toward the second normal to obtain the vertical distance.
[0122] S2335: When the vertical distance is less than the preset distance, the first to-be-processed point is added to the center point set, the number of center points is increased by 1, and the first to-be-processed point is marked as processed.
[0123] S2336: Traverse each first point to be processed to obtain the final center point set and the number of center points, and calculate the center points of the points within the point cloud point normal range.
[0124] If the first point to be processed has not been processed, the vector of the point cloud point pointing to the first point to be processed is calculated and recorded as p diff =p j -p i , p j Indicates the first point to be processed, p i Represents the point cloud point, p diff Toward the second normal n i Direction projection is performed to obtain the vertical distance, and it is determined 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 Normal range of the point, the first point to be processed p j Add to the center point set p center , the number of center points sum Add 1 to mark the first pending point as processed.
[0125] By traversing each first point to be processed, the point cloud point can be obtained p iThe final set of center points p center and the number of center points sum ,use p center / sum Indicates that the point cloud p i The center point of the points within the normal range.
[0126] The projected point cloud is simplified by this method, and the simplified projected point cloud is obtained. Figure 5 、 Figure 6 ,The simplified projected point cloud removes the undulating points around the curve and has a clear curve structure.
[0127] 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:
[0128] S241: Perform line detection on the simplified projected point cloud.
[0129] 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.
[0130] S242: For each detected straight line, calculate the distance from each point in the projected point cloud to the straight line, delete the points whose distance is less than a preset threshold, and obtain a simplified projected point cloud after deleting the points.
[0131] Once 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 is less than a preset threshold, the point is considered to be on the line and is removed.
[0132] For a point (x, y) in a two-dimensional point cloud and a line ax+by+c=0, the distance d from the point to the line can be calculated using the following formula:
[0133]
[0134] S243: Clustering the simplified projected point cloud after the points are deleted to obtain at least one clustered point cloud.
[0135] In one possible implementation, an arc detection 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:
[0136] S251: Select any cluster point cloud for arc detection, and when the cluster point cloud meets the arc feature, calculate the center and radius of the cluster point cloud.
[0137] Whether the curve corresponding to each cluster is an arc. When projecting onto a cylindrical surface, the projected curve is an arc. When projecting onto a plane, the projected curve is a straight line or a broken line. If the projected curve is an arc, the arc feature is satisfied, and the center and radius of the cluster point cloud are calculated.
[0138] S252: Determine a virtual cylinder according to the center, radius, and projection surface of the clustered point cloud.
[0139] 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.
[0140] 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.
[0141] 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:
[0142]
[0143] in, is the axis point of the virtual cylinder.
[0144] Then calculate the normal from the point to the axis point. The distance of the plane:
[0145]
[0146] in, is the axial direction of the virtual cylinder.
[0147] Finally, calculate the distance from the point to the cylindrical surface:
[0148]
[0149] Where r is the radius of the virtual cylinder.
[0150] if Threshold, then the point Located on the cylindrical surface of the virtual cylinder.
[0151] S254: Traverse each cluster point cloud to determine all cylinders in the segmented part.
[0152] 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.
[0153] In a possible implementation, the step S251 of calculating the center and radius of the clustered point cloud includes the following steps:
[0154] S2511: Simplify the selected cluster point cloud to obtain a cluster simplified point cloud.
[0155] The simplification process of the clustered point cloud may be consistent with the simplification process of the above step S230 .
[0156] S2512: Using a circle detection algorithm to detect circles on the clustered simplified point cloud, obtain a corresponding hypothetical circle and the center and radius of the hypothetical circle.
[0157] 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.
[0158] S2513: Obtain points on the hypothetical circle in the clustered simplified point cloud, cluster the points on the hypothetical circle, and obtain at least one cluster.
[0159] Using the circle formed by the center and radius of the hypothetical circle, we can know which points in the clustered simplified point cloud are on this circle, and then cluster these points. The clustering method can be the same as the above step S240.
[0160] S2514: When the number of each cluster is 1, calculate the feature values of the points on the hypothetical circle.
[0161] 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 , circle detection can also be performed on a polyline segment to obtain a circle. When determining which points are on this circle, it can be seen that two segments of points are 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, we further determine whether the cluster is a circle and calculate the eigenvalues of the points on the hypothetical circle.
[0162] 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.
[0163] 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.
[0164] 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.
[0165] Optionally, the first preset ratio is 0.5, and the second preset ratio is 0.5.
[0166] The reasons for this judgment are: 1. If it is a straight line, the number of points on the hypothetical circle is only a small segment, accounting for a small proportion of the points in the clustered simplified point cloud. 2. The width of the portion corresponding to the straight line segment is very small, and when performing circle detection, it is often detected as a large circle. In this case, the eigenvalue / radius is very small, so it is judged to be a straight line rather than an arc.
[0167] Furthermore, the embodiment of the present invention also provides a cylindrical object detection device, see Figure 9 , the cylinder detection device 300 includes:
[0168] The point cloud segmentation unit 310 is used to segment the point cloud to be detected to obtain multiple segmented parts.
[0169] 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.
[0170] The projection simplification unit 330 is used to simplify the projected point cloud to obtain a simplified projected point cloud.
[0171] The projection clustering unit 340 is configured to cluster the simplified projection point cloud to obtain at least one clustered point cloud.
[0172] The cylinder detection unit 350 is used to perform cylinder detection on each clustered point cloud to determine all cylinders in the segmented part.
[0173] In summary, the embodiments of the present invention provide a cylinder detection method, device, electronic device and storage medium, which 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, 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.
[0174] 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 illustrative. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architectures, 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, program segment, or part of the code, which 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 boxes can also occur in an order different from that 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, as well as the combination of boxes in the block diagram and / or flowchart, can be implemented using a dedicated hardware-based system that performs the specified functions or actions, or can be implemented using a combination of dedicated hardware and computer instructions.
[0175] 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.
[0176] If a function is implemented as a software 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 portion that contributes to the prior art, or the portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a computer-readable storage medium and includes several instructions for causing a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the various embodiments of the method of the present invention. The aforementioned storage medium includes various media that can store program code, such as USB flash drives, mobile hard drives, read-only memories (ROMs), random access memories (RAMs), magnetic disks, or optical disks.
[0177] The above are merely preferred embodiments of the present invention and are not intended to limit the present invention. Those skilled in the art will readily appreciate that various modifications and variations of the present invention are possible. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present invention shall be included within the scope of protection of the present invention.
[0178] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above and that the invention can be embodied in other specific forms without departing from the spirit or essential characteristics of the invention. Therefore, the embodiments should be considered in all respects as illustrative and not restrictive, and the scope of the invention is defined by the appended claims, not the foregoing description, and all variations within the meaning and range of equivalents of the claims are intended to be included therein. Any reference sign in a claim should not be construed as limiting the claim to which it relates.
Claims
1. A cylinder detection method, characterized in that: The method comprises: Segment the point cloud to be detected to obtain multiple segmented parts; For each of the segmented parts, selecting a projection plane, projecting the segmented part, and obtaining a projected point cloud; For each point cloud point in the projected point cloud, determine whether the point cloud point has been processed; if not, search the projected point cloud for a point within a preset radius with the point cloud point as the center to obtain a first point to be processed; based on each of the first points to be processed, calculate the center point of the points within the normal range of the point cloud point, and store the center point in a simplified projected point cloud; Clustering the simplified projected 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 portion.
2. The method according to claim 1, characterized in that The point cloud to be detected is segmented to obtain multiple segments, including: Detecting a plane in the point cloud to be detected using a plane detection algorithm; Grouping the planes according to the first normal directions 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 calculating the center point of the points within the normal range of the point cloud points based on 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; If the vertical distance is less than the preset distance, the first to-be-processed point is added to the set of central points, 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.
4. The method according to claim 1, wherein Clustering the simplified projected point cloud to obtain at least one clustered point cloud includes: Performing 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 whose distance is less than a preset threshold, and obtain a simplified projected point cloud after deleting the points; Clustering is performed on the simplified projected point cloud after the points are deleted to obtain at least one clustered point cloud.
5. The method according to claim 1, wherein The performing cylinder detection on each of the clustered point clouds to determine all cylinders in the segmented portion includes: 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; Determining 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.
6. The method according to claim 5, characterized in that The selecting any one of the clustered point clouds for arc detection, and calculating the center and radius of the clustered point cloud when the clustered point cloud satisfies the arc feature, 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; Obtaining points on the hypothetical circle in the clustered simplified point cloud, and clustering the points on the hypothetical circle to obtain at least one cluster; When the number of each cluster is 1, calculating the characteristic values of the points 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 eigenvalue 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.
7. 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 segmented parts, project the segmented parts, and obtain a projected point cloud; a projection simplification unit, configured to determine, for each point cloud point in the projected point cloud, whether the point cloud point has been processed; if not, search the projected point cloud for a point within a preset radius with the point cloud point as the center to obtain a first point to be processed; calculate, based on each of the first points to be processed, a center point of the points within the normal range of the point cloud point, and store the center point in a simplified projected point cloud; a projection clustering unit, configured to cluster 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.
8. 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 6 is implemented.
9. 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 6 is implemented.
Citation Information
Patent Citations
Point cloud cylinder detection method and device
CN117726668A
Fitting method and system of incomplete cylindrical surface point cloud, medium and equipment
CN118587268A