Patrol robot fence line extraction method
By combining vehicle posture clustering algorithms and the Ransac algorithm, noise points in the fence point cloud of the pigsty inspection robot are removed, achieving high-precision and stable fence line fitting. This solves the problems of low efficiency and accuracy in existing fence line fitting technologies and ensures stable navigation of the inspection robot.
Patent Information
- Application Number
- CN202510833407.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-20
- Publication Date
- 2025-10-31
AI Technical Summary
Existing technologies for fencing line fitting in pig farming environments suffer from problems such as tedious tasks, low accuracy, and low work efficiency. Furthermore, they are weak in resisting interference and make it difficult to achieve stable and high-precision fencing line extraction.
A clustering algorithm combining vehicle posture and the Ransac algorithm were adopted. Point cloud data of the fence around the pigsty was acquired by 2D LiDAR. Noise points were removed first, and then a precise fence fitting line was obtained by robust feature value fitting.
It improves the accuracy and stability of fence line extraction, solves the problems of cumbersome work and low real-time fitting efficiency of traditional methods, and ensures the stable movement of the inspection robot within the fence.
Smart Images

Figure CN120876884A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of automation control and intelligent agriculture, specifically to a method for extracting fence lines for inspection robots. Background Technology
[0002] Animal husbandry is a vital industry in agriculture and one of the key pillars of my country's economic development. my country is a major pig-producing country globally, with pig farming accounting for a significant proportion of its livestock sector. However, with the increasing scale of pig farming, the drawbacks of traditional methods have become increasingly apparent. First, labor costs in large-scale pig farms account for nearly 10% annually, indicating a growing burden on my country's pig farming industry. Second, the impact of African swine fever in recent years has increased the risk of pigs carrying the disease in artificially bred pigs, hindering the large-scale development of pig farming. To address these two significant issues, there is a greater need to design an intelligent inspection robot to regularly monitor the condition of pig farms.
[0003] The inspection robot's perception sensors consist of LiDAR, and a key challenge lies in obtaining distances from the discrete point cloud of the fence. The main task of point cloud processing is to fit the fence on both sides and obtain the fence centerline so that the inspection robot can travel along this line. Currently, the conventional methods are SLAM mapping and RANSAC fitting. SLAM mapping requires mapping the on-site environment using LiDAR. However, in actual pig farming environments, as pigs grow, the size of the cages changes accordingly, and the width between the fences also changes. This necessitates another SLAM mapping, which leads to tedious tasks, high workload, low efficiency, and a lack of real-time functionality. RANSAC fitting of the fence point cloud suffers from weak anti-interference capabilities and inaccurate point cloud fitting due to the influence of the pigs inside the fence.
[0004] Therefore, it is necessary to propose a new fitting algorithm with strong anti-interference capabilities to overcome the above-mentioned defects and achieve more accurate and stable fence line fitting. Summary of the Invention
[0005] The purpose of this invention is to provide a method for extracting fence lines for inspection robots, used for navigation of pigsty inspection robots within fences. This method aims to solve the problems of cumbersome tasks, low accuracy, and low work efficiency in existing technologies, and to achieve fence line extraction with anti-interference capabilities and high accuracy.
[0006] To achieve the above objectives, the technical solution adopted by the present invention is as follows:
[0007] A method for extracting fence lines for an inspection robot, the method comprising the following steps:
[0008] S1. Perform robot posture data processing;
[0009] S2. Read point cloud and robot posture data;
[0010] S3. Perform point cloud coordinate preprocessing;
[0011] S4. A clustering algorithm combining vehicle body posture is used for point cloud denoising.
[0012] S5. Use the Ransac algorithm to coarsely extract the target point cloud;
[0013] S6. A robust eigenvalue fitting algorithm is used to accurately extract the pigpen fence.
[0014] Furthermore, in S1, the robot posture data processing procedure is as follows:
[0015] The point cloud coordinates of OpenCV are determined based on the distance values of 2D LiDAR at various fixed angles. Since the angle values of the LiDAR are fixed, the coordinate point cloud will change due to the rotation of the vehicle body.
[0016] When the robot first enters the fence, it will use the corner points on both sides of the fence to make the fence point cloud parallel to the y-axis coordinate system in the OpenCV coordinate system, and record the z-axis angle value of the IMU at this time as init_theta. This angle value will only be initialized once.
[0017] The angle value when the fixed fence point cloud is parallel to the y-axis of the coordinate system should be 90°. Since the angle value of the IMU is not fixed, it is necessary to set the difference offset = init_theta - 90°.
[0018] Step S1 is performed only once, when the robot first enters the fence and adjusts the fence line point cloud to be parallel to the y-axis of OpenCV. That is, after all the steps in claim 1 have been run once, subsequent operations will only be performed in steps S2-S5.
[0019] Furthermore, in S2, the robot's surrounding environment information is read using a 2D LiDAR and the robot's z-axis angle is read using an IMU.
[0020] Furthermore, in S3, the point cloud preprocessing process is as follows:
[0021] A coordinate system is established with the 2D LiDAR as the center. The positive x-axis points to the right of the vehicle and is parallel to the ground plane, while the positive y-axis points to the rear of the vehicle, is parallel to the ground, and is perpendicular to the x-axis.
[0022] Using the origin of the coordinate system as the vertex, divide the system into two extended regions, each 90° to the left and right, with the two regions being symmetrical about the x-axis.
[0023] Point cloud data from the two regions were extracted as target point clouds, with the point cloud data in the negative x-axis direction used as the left side of the pigsty fence and the point cloud data in the positive x-axis direction used as the right side of the pigsty fence.
[0024] The fence lines were extracted from the point clouds on the left and right sides of the fence using a fence line extraction algorithm for inspection robots based on vehicle posture clustering and robust eigenvalue fitting.
[0025] The process in S4 is as follows:
[0026] 4.1) Set the labels of all initial points in the target point cloud to 0. Points with labels other than 0 are unlabeled points. Read the robot's angle value θ once.
[0027] 4.2) Use KDTree to efficiently search for points near the target point. Use formula (1) to determine the points in the neighborhood of the current point. Calculate the distance between the point in the target point cloud and the current point using Euclidean distance. If the distance is less than the maximum neighbor radius threshold d... th, Then it belongs to the neighboring point in the current neighborhood;
[0028] ||P i -P f ||2≤d th (1)
[0029] 4.3) KDTree can be used to quickly search for nearby points and perform preliminary screening of neighboring points, thereby improving the running speed. After the screening is completed, a rectangular neighborhood search is performed. Formulas (2) and (3) are the direction vectors of the long side of the rectangle (parallel to the fence line) and the direction vectors of the short side of the rectangle (perpendicular to the fence line), respectively. The vector difference diff between the neighboring points screened by KDTree and the target point is calculated one by one using formula (4). j , where (x j y j (x) represents the coordinates of a nearby point. f y f Let ) be the coordinates of the target point, and calculate the diff using formulas (5) and (6) respectively. j Projection on the fence line And the projection perpendicular to the fence line. Define the lengths of the longer and shorter sides of the rectangle as H and W, respectively. and This indicates that the nearby point is a neighboring point. Based on the neighboring point determination condition, the label of the current target point and all points in the neighborhood that meet the condition are set to 1, and the minimum label is set to 1.
[0030]
[0031] diff j =(|xj -x f | |y j -y f |) (4)
[0032]
[0033] 4.4) Traverse the next target point. Based on 4.2) and 4.3) above, judge the neighboring points. If there are unlabeled points in the neighborhood, set the label of the current target point and all points in the neighborhood to the minimum label plus 1, and increment the minimum label by 1. If there are labeled points in the neighborhood, set the label of the target point and the points in the neighborhood to the label of the labeled point, and do not change the minimum label. Repeat this step until all points are traversed.
[0034] 4.5) After traversing all points, discrete noise points can be removed.
[0035] The process of S5 is as follows:
[0036] 5.1) Select two non-collinear points from the clustered target point cloud and calculate the equation of the straight line: Ax + By + C = 0;
[0037] 5.2) Calculate the distance d from each point to the line. i The formula is as follows:
[0038]
[0039] Where, x i With y i P not pointed to i (x i, y i The x and y coordinates of ( );
[0040] 5.3) Based on the distance d from each sampling point to the straight line i Distance threshold d h The comparison is performed to separate noise points;
[0041] 5.4) Criteria for determining noise points d i With d h Comparison, if d i Greater than or equal to d h If the point is not found to be a noise point, it is considered a noise point and removed from the target point cloud.
[0042] 5.5) Based on the target point cloud after separating the noise points, if the current number of point clouds is greater than 80% of the number before separation, then the coarse extraction is complete; otherwise, repeat the above steps until the condition is met.
[0043] The process of S6 is as follows:
[0044] 6.1) The point cloud obtained from the coarse extraction by Ransac is fitted with a single feature value to obtain the linear equation Ax + By + C = 0;
[0045] 6.2) Use formula (7) to calculate the distance d from all point clouds after coarse extraction to the line. i Let the current point set be P. i ;
[0046] 6.3) Solve for the distance d from each point to the line. i The sample standard deviation is given by the following formula:
[0047]
[0048] Where, d i This represents the distance from a point to a line. This represents the average distance from each point to the line. The formula for calculating the average is: n represents the number of point clouds after coarse extraction;
[0049] 6.4) Set the threshold to 1.5S, if d i If the value is ≥2S, then the point is considered an outlier and removed from the current point set; otherwise, it is retained in the current point set. Let the processed point set be P'. i ;
[0050] 6.5) Process the point set P' i A new linear equation, Ax + By + C = 0, is obtained by fitting eigenvalues.
[0051] 6.6) Repeat steps 6.2)-6.5) above until the above set P is reached. i =P' i That is, after thresholding and eigenvalue fitting, the point set no longer changes, and the final fitted line equation Ax+By+C=0 is the most accurate fitted line required.
[0052] The main advantages of this invention are as follows: By acquiring real-time point cloud data of the fence around the pig house inspection robot using 2D LiDAR, interference noise points in the point cloud are effectively removed by combining a clustering algorithm based on the vehicle's posture with the Ransac algorithm. Then, a more accurate fence fitting line is obtained through robust feature value fitting, which effectively improves the accuracy of fence line extraction. This solves the problems of cumbersome work, low real-time fitting efficiency, and weak anti-interference of traditional methods, and significantly improves the stability and accuracy of fitting within a fixed time, ensuring the stable movement of the pig house inspection robot within the fence. Attached Figure Description
[0053] Figure 1 This is a flowchart of the method of the present invention.
[0054] Figure 2 It is the original point cloud map of the real environment.
[0055] Figure 3 It is the original point cloud map of the simulation environment.
[0056] Figure 4 This is a clustering effect diagram of the uncombined vehicle body posture in the simulation environment.
[0057] Figure 5 It is a clustering effect diagram of vehicle body posture combined with the simulation environment.
[0058] Figure 6 This is a rough extraction result of Ransac in a simulation environment.
[0059] Figure 7 This is a graph showing the robust eigenvalue fitting effect of the simulation environment. Detailed Implementation
[0060] To make the objectives, technical solutions, and advantages of the present invention clearer, the embodiments of the present invention will be further described in detail below with reference to specific examples and the accompanying drawings.
[0061] Reference Figures 1 to 7 A method for extracting fence lines for an inspection robot, comprising:
[0062] S1. Perform robot posture data processing, the process is as follows:
[0063] The point cloud coordinates of OpenCV are determined based on the distance values of 2D LiDAR at various fixed angles. Since the angle values of the LiDAR are fixed, the coordinate point cloud will change due to the rotation of the vehicle body.
[0064] When the robot first enters the fence, it will use the corner points on both sides of the fence to make the fence point cloud parallel to the y-axis coordinate system in the OpenCV coordinate system, and record the z-axis angle value of the IMU at this time as init_theta. This angle value will only be initialized once.
[0065] The angle value when the fixed fence point cloud is parallel to the y-axis of the coordinate system should be 90°. Since the angle value of the IMU is not fixed, it is necessary to set the difference offset = init_theta - 90°.
[0066] Step S1 is performed only once, when the robot first enters the fence and adjusts the fence line point cloud to be parallel to the y-axis of OpenCV. That is, after all the steps in claim 1 are run once, subsequent operations only perform steps 2-5.
[0067] S2. Read all point cloud data and robot body posture. The point cloud data is acquired using a 2D LiDAR, which can measure 360°. The measured point cloud data is then converted to the OpenCV coordinate system, as shown below. Figure 2 As shown, this figure is the original point cloud transformed in OpenCV coordinates. The two symmetrical columns of point clouds in the center of the figure are the point cloud of the left and right fences, while the point clouds outside these two fence lines are the interference noise points. The vehicle body attitude data is mainly the z-axis angle of the IMU.
[0068] S3. Perform point cloud preprocessing, the process is as follows:
[0069] A coordinate system is established with the 2D LiDAR as the center. The positive x-axis points to the right of the vehicle and is parallel to the ground plane, while the positive y-axis points to the rear of the vehicle, is parallel to the ground, and is perpendicular to the x-axis.
[0070] Using the origin of the coordinate system as the vertex, divide the system into two extended regions, each 90° to the left and right, with the two regions being symmetrical about the x-axis.
[0071] Point cloud data from the two regions were extracted as target point clouds, with the point cloud data in the negative x-axis direction used as the left side of the pigsty fence and the point cloud data in the positive x-axis direction used as the right side of the pigsty fence.
[0072] The fence lines were extracted from the point clouds on the left and right sides of the fence using a pigsty fence line extraction algorithm that combines clustering and robust eigenvalue fitting.
[0073] S4. Point cloud denoising is performed using a clustering algorithm that incorporates vehicle body posture. The process is as follows:
[0074] 4.1) Set the labels of all initial points in the target point cloud to 0. Points with labels other than 0 are unlabeled points. Read the robot's angle value θ once.
[0075] 4.2) Use KDTree to efficiently search for points near the target point. Use formula (1) to determine the points in the neighborhood of the current point. Calculate the distance between the point in the target point cloud and the current point using Euclidean distance. If the distance is less than the maximum neighbor radius threshold d... th If it is a neighboring point in the current neighborhood, then it belongs to the neighboring point in the current neighborhood;
[0076] ||P i -P f ||2≤d th (1)
[0077] 4.3) KDTree can be used to quickly search for nearby points and perform preliminary screening of neighboring points, thereby improving the running speed. After the screening is completed, a rectangular neighborhood search is performed. Formulas (2) and (3) are the direction vectors of the long side of the rectangle (parallel to the fence line) and the direction vectors of the short side of the rectangle (perpendicular to the fence line), respectively. The vector difference diff between the neighboring points screened by KDTree and the target point is calculated one by one using formula (4). j , where (x j y j (x) represents the coordinates of a nearby point. f y f Let ) be the coordinates of the target point, and calculate the diff using formulas (5) and (6) respectively. j Projection on the fence line And the projection perpendicular to the fence line. Define the lengths of the longer and shorter sides of the rectangle as H and W, respectively. and This indicates that the nearby point is a neighboring point. Based on the neighboring point determination condition, the label of the current target point and all points in the neighborhood that meet the condition are set to 1, and the minimum label is set to 1.
[0078]
[0079] diff j =(|x j -x f | |y j -y f |) (4)
[0080]
[0081] 4.4) Traverse the next target point. Based on 4.2) and 4.3) above, judge the neighboring points. If there are unlabeled points in the neighborhood, set the label of the current target point and all points in the neighborhood to the minimum label plus 1, and increment the minimum label by 1. If there are labeled points in the neighborhood, set the label of the target point and the points in the neighborhood to the label of the labeled point, and do not change the minimum label. Repeat this step until all points are traversed.
[0082] 4.5) After traversing all points, discrete noise points can be removed;
[0083] S5. The Ransac algorithm is used to coarsely extract the target point cloud. The point cloud after clustering in step S3 is used as the point cloud to be processed by the Ransac algorithm. The processing flow of the Ransac algorithm includes:
[0084] 5.1) Select two non-collinear points from the clustered target point cloud and calculate the equation of the straight line: Ax + By + C = 0;
[0085] 5.2) Calculate the distance d from each point to the line. i The formula is as follows:
[0086]
[0087] Where, x i With y i P not pointed to i (x i, y i The x and y coordinates of ( );
[0088] 5.3) Based on the distance d from each sampling point to the straight line i Distance threshold d h The comparison is performed to separate noise points;
[0089] 5.4) Criteria for determining noise points d i With d h Comparison, if d i Greater than or equal to d h If the point is not found to be a noise point, it is considered a noise point and removed from the target point cloud.
[0090] 5.5) Based on the target point cloud after separating noise points, if the current number of point clouds is greater than 80% of the number before separation, then the coarse extraction is complete; otherwise, repeat the above steps until the condition is met.
[0091] After performing the above operations, you can obtain the result image after the coarse extraction by Ransac, such as... Figure 6 As shown in the figure, the Ransac algorithm can effectively process dense point clouds that are far from the fence lines.
[0092] S6. A robust eigenvalue fitting algorithm is used to accurately extract the pigpen fence, resulting in the final fence extraction line as shown below. Figure 7 As shown, the algorithm's computation time is approximately 0.02 seconds, and the robot's control cycle is 0.1 seconds, thus meeting the real-time performance requirements. Furthermore, the final linear equation is y = ax + b, with the value of a around 2, indicating a small error.
[0093] The process of S6 is as follows:
[0094] 6.1) The point cloud obtained from the coarse extraction by Ransac is fitted with a single feature value to obtain the linear equation Ax + By + C = 0;
[0095] 6.2) Use formula (7) to calculate the distance d from all point clouds after coarse extraction to the line. i Let the current point set be P. i ;
[0096] 6.3) Solve for the distance d from each point to the line. i The sample standard deviation is given by the following formula:
[0097]
[0098] Where, d i This represents the distance from a point to a line. This represents the average distance from each point to the line. The formula for calculating the average is: n represents the number of point clouds after coarse extraction;
[0099] 6.4) Set the threshold to 1.5S, if d i If the value is ≥2S, then the point is considered an outlier and removed from the current point set; otherwise, it is retained in the current point set. Let the processed point set be P'. i ;
[0100] 6.5) Process the point set P' i A new linear equation, Ax + By + C = 0, is obtained by fitting eigenvalues.
[0101] 6.6) Repeat steps 6.2)-6.5) above until the above set P is reached. i =P' i That is, after thresholding and eigenvalue fitting, the point set no longer changes, and the final fitted line equation Ax+By+C=0 is the most accurate fitted line required.
[0102] In this embodiment, to more intuitively demonstrate the effect, it is verified in a simulation, such as... Figure 3 As shown in the figure, 50 fence point clouds were generated, each spaced 2cm apart, along a straight line with the equation y = 2x + 5. Simultaneously, 700 discrete noise points outside the fence line were generated, with deviations from the fence line within ±50cm. Firstly, the clustering algorithm employed was the FEC clustering algorithm incorporating vehicle posture. This algorithm is faster than traditional clustering algorithms and is more suitable for real-time tasks. Figure 4 , Figure 5 The images show the results of the original FEC clustering algorithm and the clustering algorithm combined with vehicle posture. It can be clearly seen from the two images that the FEC clustering algorithm combined with vehicle posture is more effective at removing discrete points.
[0103] The above are preferred embodiments of the present invention. Any changes made to the technical solution of the present invention that do not exceed the scope of the technical solution of the present invention shall fall within the protection scope of the present invention.
Claims
1. A method for extracting fence lines for an inspection robot, characterized in that, The method includes the following steps: S1. Perform robot posture data processing; S2. Read point cloud and robot posture data; S3. Perform point cloud coordinate preprocessing; S4. A clustering algorithm combining vehicle body posture is used for point cloud denoising. S5. Use the Ransac algorithm to coarsely extract the target point cloud; S6. A robust eigenvalue fitting algorithm is used to accurately extract the pigpen fence.
2. The method for extracting fence lines of an inspection robot as described in claim 1, characterized in that, In S1, the robot posture data processing procedure is as follows: The point cloud coordinates of OpenCV are determined based on the distance values of 2D LiDAR at various fixed angles. Since the angle values of the LiDAR are fixed, the coordinate point cloud will change due to the rotation of the vehicle body. When the robot first enters the fence, it will use the corner points on both sides of the fence to make the fence point cloud parallel to the y-axis coordinate system in the OpenCV coordinate system, and record the z-axis angle value of the IMU at this time as init_theta. This angle value will only be initialized once. The angle value when the fixed fence point cloud is parallel to the y-axis of the coordinate system should be 90°. Since the angle value of the IMU is not fixed, it is necessary to set the difference offset = init_theta - 90°.
3. The method for extracting fence lines of an inspection robot as described in claim 2, characterized in that, In S2, the robot's surrounding environment information is read by 2D LiDAR and the robot's z-axis angle is read by IMU.
4. The method for extracting fence lines from an inspection robot as described in claim 3, characterized in that, In S3, the point cloud preprocessing process is as follows: A coordinate system is established with the 2D LiDAR as the center. The positive x-axis points to the right of the vehicle and is parallel to the ground plane, while the positive y-axis points to the rear of the vehicle, is parallel to the ground, and is perpendicular to the x-axis. Using the origin of the coordinate system as the vertex, divide the system into two extended regions, each 90° to the left and right, with the two regions being symmetrical about the x-axis. Point cloud data from the two regions were extracted as target point clouds, with the point cloud data in the negative x-axis direction used as the left side of the pigsty fence and the point cloud data in the positive x-axis direction used as the right side of the pigsty fence. The fence lines were extracted from the point clouds on the left and right sides of the fence using a fence line extraction algorithm for inspection robots based on vehicle posture clustering and robust eigenvalue fitting.
5. The method for extracting fence lines of an inspection robot as described in claim 4, characterized in that, The process in S4 is as follows: 4.1) Set the labels of all initial points in the target point cloud to 0. Points with labels other than 0 are unlabeled points. Read the robot's angle value θ once. 4.2) Use KDTree to efficiently search for points near the target point. Use formula (1) to determine the points in the neighborhood of the current point. Calculate the distance between the point in the target point cloud and the current point using Euclidean distance. If the distance is less than the maximum neighbor radius threshold d... th, Then it belongs to the neighboring point in the current neighborhood; ‖P i -P f ‖2≤d th (1) 4.3) KDTree can be used to quickly search for nearby points and perform preliminary screening of neighboring points, thereby improving the running speed. After the screening is completed, a rectangular neighborhood search is performed. Formulas (2) and (3) are the direction vectors of the long side of the rectangle (parallel to the fence line) and the direction vectors of the short side of the rectangle (perpendicular to the fence line), respectively. The vector difference diff between the neighboring points screened by KDTree and the target point is calculated one by one using formula (4). j , where (x j y j (x) represents the coordinates of a nearby point. f y f Let ) be the coordinates of the target point, and calculate the diff using formulas (5) and (6) respectively. j Projection on the fence line And the projection perpendicular to the fence line. Define the lengths of the longer and shorter sides of the rectangle as H and W, respectively. and This indicates that the nearby point is a neighboring point. Based on the neighboring point determination condition, the label of the current target point and all points in the neighborhood that meet the condition are set to 1, and the minimum label is set to 1. diff j =(|x j -x f | |y j -y f |) (4) 4.4) Traverse the next target point. Based on 4.2) and 4.3) above, judge the neighboring points. If there are unlabeled points in the neighborhood, set the label of the current target point and all points in the neighborhood to the minimum label plus 1, and increment the minimum label by 1. If there are labeled points in the neighborhood, set the label of the target point and the points in the neighborhood to the label of the labeled point, and do not change the minimum label. Repeat this step until all points are traversed. 4.5) After traversing all points, discrete noise points can be removed.
6. The method for extracting fence lines of an inspection robot as described in claim 5, characterized in that, The process of S5 is as follows: 5.1) Select two non-collinear points from the clustered target point cloud and calculate the equation of the straight line: Ax + By + C = 0; 5.2) Calculate the distance d from each point to the line. i The formula is as follows: Where, x i With y i P not pointed to i (x i, y i The x and y coordinates of ( ); 5.3) Based on the distance d from each sampling point to the straight line i Distance threshold d h The comparison is performed to separate noise points; 5.4) Criteria for determining noise points d i With d h Comparison, if d i Greater than or equal to d h If the point is not found to be a noise point, it is considered a noise point and removed from the target point cloud. 5.5) Based on the target point cloud after separating the noise points, if the current number of point clouds is greater than 80% of the number before separation, then the coarse extraction is complete; otherwise, repeat the above steps until the condition is met.
7. The method for extracting fence lines of an inspection robot as described in claim 6, characterized in that, The process of S6 is as follows: 6.1) The point cloud obtained from the coarse extraction by Ransac is fitted with a single feature value to obtain the linear equation Ax + By + C = 0; 6.2) Use formula (7) to calculate the distance d from all point clouds after coarse extraction to the line. i Let the current point set be P. i ; 6.3) Solve for the distance d from each point to the line. i The sample standard deviation is given by the following formula: Where, d i This represents the distance from a point to a line. This represents the average distance from each point to the line. The formula for calculating the average is: n represents the number of point clouds after coarse extraction; 6.4) Set the threshold to 1.5S, if d i If the value is ≥2S, then the point is considered an outlier and removed from the current point set; otherwise, it is retained in the current point set. Let the processed point set be P'. i ; 6.5) Process the point set P' i A new linear equation, Ax + By + C = 0, is obtained by fitting eigenvalues. 6.6) Repeat steps 6.2)-6.5) above until the above set P is reached. i =P' i That is, after thresholding and eigenvalue fitting, the point set no longer changes, and the final fitted line equation Ax+By+C=0 is the most accurate fitted line required.