A Point Cloud-Based Feature Recognition and Path Planning Method

Based on the research background of in situ automatic ultrasonic phased array inspection of irregular porous castings, due to the limited in situ inspection stations, complex shape of irregular porous castings, and extreme multireﬂection structural features, it is necessary to identify the positioning inspection features among multiple features to be inspected and plan the optimal inspection path. This research is interested in the porous location recognition and its detection path planning of irregular porous castings. For this, a point cloud-based multifeature contour recognition and location algorithm were proposed to simultaneously extract and locate the hole feature and cylindrical feature from an irregular porous castings. Furthermore, a detection path planning method was put forward to search the shortest robot’s detection path based on the above acquired features by visual recognition and positioning technology. First, through the calibration of the industrial robot tool coordinate system and the internal and external parameters of the camera, the “EyeinHand” hand-eye conversion relationship was established. Second, the robot vision system collects the point cloud information of the area to be inspected and performs point cloud splicing, the accuracy of the original data, the removal of noise such as invalid points, outliers and internal noise points, on this basis, the boundary curve of the hole to be inspected was extracted, the cylindrical equation was ﬁtted, its geometric center was calculated, and the central coordinates and axis direction of the contour of the hole to be inspected were obtained. Finally, all the detection paths were traversed through the multibranch tree to obtain the optimal detection path of the detection points of multiple targets. The experimental results show that the positioning accuracy of the feature of the hole to be inspected by the vision system is 0.107mm, the aperture extraction accuracy is 0.002mm, the cylinder ﬁtting accuracy is 0.04mm, and the calculation accuracy of the angle between the two axes is within 0.4. When the number of features to be inspected is diﬀerent, the average moving distance can be saved by 10.7% by using the end eﬀector after path optimization. The feasibility of in situ automatic ultrasonic phased array detection for irregular porous castings using by visual positioning is veriﬁed.


Introduction
Irregular porous castings are widely used in active military and naval weapons and equipment. As a key component of this type of large-scale weapons equipment, with the improvement of the requirements of battlefield indexes such as multiple bursts, high bore pressure, and long distance, its structural features are large and heavy loads, multiple deep and narrow cylindrical cavities, and adjacent distribution of barrel assembly holes. If the structural strength of the adjacent area of the multideep and narrow column cavity is weak, and there are missing casting defects in the critical stress area, then with the omission of inspection defects, under the cyclic ignition loads of up to 3000 tons, the defects are constantly expanding. Inevitably, there will be failure problems such as large deformation or instant fracture. In order to control the internal quality of irregular porous castings more effectively, the manufacturing process requires flaw detection of irregular porous castings after the process of "parts processing." At this time, the irregular porous casting has not been processed and cannot be reassembled or removed from the machine tool. Otherwise, machining accuracy will be affected, and the irregular porous castings can only be inspected online. erefore, the detection station is limited, and the shape of irregular porous casting parts is complex, and there are more extreme multireflective structure features. Aiming at the abovementioned detection problems, it is an effective solution to use in situ automated ultrasonic phased array detection.
For most application scenarios of industrial robots, it is necessary to predict the position and pose of the target object to complete the corresponding task. Xu Chunguang's team [1,2] developed a robotic ultrasonic inspection system, which requires the calibration of the fixture coordinate system of the workpiece to be inspected and the inspection coordinate system of the dual robotic arms. Furthermore, the digital model is used to locate the ultrasonic testing reference point of the regular shape workpiece, and the automatic control of the ultrasonic testing of the robotic arm is finally realized. Zhao et al. [3] used tooling fixtures to fix the workpiece to be inspected, and based on the mathematical representation method of the workpiece geometry and model, realized the positioning of the workpiece to be inspected datum point on the CNC machine tool. Abdallah et al. [4] used the information in the CAD model of the part to perform offline programming to detect defects in aviation machinery parts and check whether all subcomponents were installed correctly. Božek et al. [5] offered a new method of analytic geometry to calculate the trajectories of mechatronic systems and CAD/CAM. e method can accurately calculate the trajectory for the centrally symmetric conic sections and, in some cases, arbitrary differentiable planar curves. Obviously, the use of robotic arms in this type of technology has become the mainstream of automatic ultrasonic testing, but the abovementioned technology cannot realize the testing of irregular porous castings.
e key reason is that its actual casting shape does not correspond to its digital model, so it is impossible to accurately locate its testing reference point by precision tooling. At present, in the industrial applications of robots, the working path of most robot is planned through manual teaching or offline programming. However, this method strictly limits the starting and ending poses of the target object. e preplanned path can only be repeated mechanically, and it is necessary to teach different working objects separately to get the corresponding teaching files. e highly structured working environment seriously restricts the efficiency, flexibility, and intelligence of the robot, which cannot meet the requirements of a flexible production system [6]. Machine vision is widely used in industrial production because of its fast, stable, and noncontact characteristics [7]. With the help of visual guidance, assist the robot to locate the target object.
is method can effectively improve the working efficiency and automation level of the production line.
DeAraujo and Lins [8] used the binocular vision inspection method to detect the features to be inspected, and the spatial coordinates of the reference points to be inspected in the machine coordinate system are output, so as to realize the accurate spatial positioning of the reference points of irregular features to be inspected, the proposed system presented, on average, absolute deviations of (0.46 ± 0.06 mm), (0.11 ± 0.05 mm), and (0.25 ± 0.09 mm) in X, Y, and Z axes. Mineo et al. [9] developed a 6DOF robotic arm-assisted ultrasonic phased array inspection system, which uses machine vision inspection technology to build a global ultrasonic inspection reference field for the workpiece to be inspected, and realizes effectively locate and detect the characteristics of the workpiece to be inspected. However, the disadvantage is that the construction cost of this global ultrasonic testing system is quite expensive. Khan et al. [10] used the depth vision sensor to pick up the datum of the workpiece to be inspected, and based on this, the ultrasonic inspection path is planned to realize the guidance of automatic ultrasonic inspection, and the image acquisition method produces a UT tool path with an accuracy of 0.43 mm. Sun et al. [11] calculated the local plane normal vector determined by the point cloud method, and then fitted the reference point with B-spline curve equation, and finally, the elevation of the reference surface and the inclination angle of the radial point were calculated according to the fitted curve equation, so as to obtain the position and normal characteristics of the key points of the point cloud. Yang et al. [12] propose a novel 3-D path extraction method of weld seams based on a stereo-structured light sensor, which could be well adapt to different types of welds and different groove sizes. Meanwhile, the position information and pose information of weld seam are established to serve 3-D path teaching of a welding robot. e maximum path extraction error of V-type but joint is less than 0.7 mm. Liu [13] in order to realize the rapid measurement for large dimension workpieces in industrial fields, a new measuring system based on stereovision was proposed and implemented. A binocular structure light scanner was constructed to acquire the surface detail information of the workpieces. Experimental results indicate that the new measuring system is suitable for large workpiece measurement with an accuracy of 0.112 mm/3 m. It can be seen that using machine vision technology to pick up the special-shaped porous castings with variable curvature casting surface characteristics to be inspected, such as the space coordinates of the reference points to be inspected, normal, and inspection sequence planning, so as to drive the ultrasonic transducer. It is a good choice to perform ultrasonic testing of the robotic arm. Kuric et al. [14] present pose repeatability measurement of the industrial robot Fanuc LR Mate 200iC. By evaluating results of pose repeatability, it can be said that the repeatability of the robot at the selected area of its workspace corresponds to the repeatability value stated by the manufacturer (±0.02 mm). Pollak [15] describes the measurement of unidirectional pose accuracy and repeatability of a collaborative robot. e objective of the measurements is to investigate and evaluate unidirectional accuracy of the six-axis collaborative robot UR5 of the company Universal Robots. On the basis of the measurement, they verified technical specifications of unidirectional pose accuracy and repeatability of the robotic arm UR5specified by its producer. Ren [16] proposed a general pose testing method of industrial robot. is testing method is illustrated with a KUKA KR210 R2700 industrial robot with a drilling end effector. e pose accuracy and repeatability of the robot are 0.3 mm and 0.06 mm, which are in accordance with the nominal index. And the coordinate deviation of the tool center point (TCP) from direct measurement is less than 0.015 mm. It can be seen that using a robot to drive an ultrasonic transducer for ultrasonic nondestructive testing has the characteristics of good pose repeatability and positioning accuracy. e global positioning of the ultrasonic inspection of irregular porous castings is mainly reflected in the determination of the spatial coordinates and normal vectors of several reference points to be inspected and the planning of ultrasonic scanning sequence. To solve this problem, Graumann [17] introduced an automatic ultrasonic examination trajectory planning algorithm, which uses the depth camera to obtain the point cloud of the three-dimensional patient surface, and set the parameter path function to generate single or multiple parallel scanning trajectories of a larger target surface. en, the spline curve is generated by preparing the path, so that the ultrasonic probe can scan smoothly. Wu and Huang [18] obtained the depth data of the tissue surface through Kinect, converted it to the coordinate system of the detection equipment, automatically planned the scanning path, and guides the ultrasonic probe to automatically scan. Shahzad et al. [19] put forward machine vision and path planning technology for shortest path calculation to improve the production efficiency of industrial robots and successfully realized the precise path optimization in the bottle manufacturing industry. It can be seen that by traversing all the reference points to be inspected, it is possible to realize the inspection and scanning sequence planning of multiple inspection surfaces of the irregular porous castings, thus realizing the global path planning of the ultrasonic inspection of the robot arm of the irregular porous castings.
According to the above research, planning the automatic detection process through manual teaching or off-line programming can only be repeated mechanically, and different working objects need to be taught separately to obtain the corresponding teaching files, which severely restricts the working efficiency and flexibility of the robot. At present, there are some problems in the field of ultrasonic automatic detection, such as insufficient detection accuracy, expensive equipment, and less application. erefore, this paper constructs a vision-guided industrial robot ultrasonic detection system. First, aiming at the difficult positioning of the complex structure of irregular porous castings, a multifeature profile recognition and positioning algorithm based on point cloud are proposed to achieve the accurate acquisition of the poses of the feature points to be inspected. Second, a multifeature detection path optimization method is presented. Based on the vision inspection technology, the feature position of the irregular porous casting is identified, and the inspection path of the robot is generated, which solves the problem of inefficiency caused by unreasonable inspection paths. Finally, experimental tests and results are provided, and the performance of this method is illustrated in the following section.

Visual Positioning Algorithm.
In order to solve the difficult problem of detecting the complex structure of special-shaped porous castings, this paper proposes a multifeature surface mathematical representation algorithm based on point clouds. is method can identify the inner cylindrical surface and outer cylindrical surface of irregular castings in the point cloud data and accurately extract the hole position, aperture parameters, and mathematical characteristics of the cylindrical surface. is method uses both the contour extraction method and the cylindrical fitting method, which can extract multiple features of irregular porous castings more conveniently and directly, and is more convenient than the traditional single feature extraction method. e original algorithm makes the edge extraction effect better by adjusting the threshold and improves the accuracy of cylinder fitting. e point cloud data collected by the RVCXmini depth camera have no obvious geometric distribution characteristics, and the measurement points are randomly generated, showing a disordered state. Because of the disordered and random distribution of the point cloud, most of the measurement points are distributed around the feature to be detected. e measuring points at the boundary of the hole may be distributed on the inner diameter and surrounding plane of the hole, and only a few points are just at the boundary of the hole. According to the distribution of measuring points on the hole boundary, it can be judged whether it is a boundary point or not by the geometric distribution of k neighborhood points [20]. If a certain point is a boundary point, the distribution of its k neighborhood points will be tilted to one side (as shown in Figure 1(a)). If a certain point is not a boundary point, the k neighborhood points are more evenly around the point (as shown in Figure 1(b)). erefore, for the scattered point cloud at the boundary of the hole, it is necessary to perform boundary point extraction preprocessing [21,22], including point cloud splicing, original data accuracy inspection, invalid points removal, outliers and internal noise points, and other noise removal. Research [23,24] proposes deep learning methods to remove noise and preserve its clear features to filter point clouds automatically and robustly and achieve automatic prediction of normals. Research [25] proposed a robust normal estimation method for point clouds using a low-rank matrix approximation algorithm and provide a new filtering method for point cloud data to smooth the position data to fit the estimated normals. At present, the deep learning method for point cloud preprocessing is very common. However, in this study, the traditional filtering method is still used for point cloud preprocessing. Because the characteristics of special-shaped porous castings are relatively obvious, this research is carried out for this workpiece. In order to reduce the influence of discrete point cloud on segmentation, based on the principle of statistical filtering, the discrete noise point cloud is removed according to the degree of discrete point cloud [26]. For any point p(x, y, z) in the point cloud, define a point with p(x, y, z) as the Shock and Vibration 3 center, R is the radius of the sphere V R [p(x, y, z)], As shown in Figure 2, the black solid point in the figure indicates the point cloud.
is recorded as D r (p), and D r (p) is used to measure the dispersity of point cloud, which is defined as In formula (1), d i represents the distance between p(x, y, z) and p i (x, y, z), and num represents the number of distances less than R. If D r (p) is less than the threshold D rmin , the point p(x, y, z) is detected as a discrete point, otherwise it is a valid point.
Since the average distance from one point to the adjacent point in the point cloud diagram is approximately in accordance with Gaussian distribution. Calculate the average μ d and standard deviation σ d of the distance between p(x, y, z) and all point clouds p i (x i , y i , z i )(i � 1, 2, . . . , n) in the neighborhood of R: According to Chebyshev's inequality P |X − μ| ≥ ε ≤ σ 2 /ε 2 , when ε � 5σ, the misjudgment rate is the smallest. erefore, R in formula (1) is set to 5σ d , and D rmin � 50.
As shown in Figure 3, the number of point clouds before filtering is 424355, and the number of point clouds after filtering is 219066. In addition, the discrete points and the background points can be eliminated through filtering, see Figure 3(b).
According to the characteristics of flat hole, the contour is linearly approximated by α shapes algorithm [27]. For a plane point cloud of arbitrary shape, if a circle with a radius of α is rolled around it, if the rolling circle radius α is small enough, every point in the point cloud is a boundary point, as shown in Figure 4; If α is properly increased to a certain degree, it will only roll on the boundary point, and its rolling trajectory is the boundary of point cloud.
e specific steps of the algorithm are in (1) For any point P, the radius of the rolling circle is α, and all points within 2α from the point P are searched in the point cloud, which is recorded as the point set Q; (2) As shown in Figure 5, select any point p 1 (x 1 , y 1 ) in Q. According to the coordinates of these two points and α, the center coordinates are calculated: e center of the circle p 2 and p 3 are the coordinates of the center of the circle when the two points p and  p 1 are passed and the radius is α. e coordinate calculation formula is shown in formula (3): Among them (3) After removing the point p 1 from the Q point, calculate the distances from the remaining points to the points p 2 and p 3 respectively. If the distance from all points to p 2 or p 3 is greater than α, it indicates that p is a boundary point. (4) If the distances between the remaining points to the points p 2 or p 3 are not all greater than α, all points in the traversal point set Q are rotated as points p 1 . If there is a point that satisfies conditions (2) and (3), it means that the point is a boundary point, and the judgment of this point is terminated to judge the next point. If there is no such point as p 1 among adjacent points in Q, it means that point p is a nonboundary point.
In the algorithm, the radius α controls the fineness of the boundary. e radius of the radius α directly affects the accuracy of extracting boundary point. rough many experiments, the proper radius α value is set to estimate the characteristic boundary of the irregular porous castings. Specific steps are as follows: (1) Input the point cloud and set the initial α.  e abovementioned α shapes boundary extraction method is used to extract the boundary of the hole features of special-shaped porous castings, and the obtained hole boundary by setting the α value to 1 mm is shown in Figure 6.
According to the cylindrical surface characteristics of the special-shaped porous castings, as shown in Figure 7, P is any point on the cylindrical surface, P 0 (x 0 , y 0 , z 0 ) is a point on the cylinder axis, (a, b, c) is the cylinder axis vector, and r 0 is the radius of the cylinder bottom circle. It can be concluded that the distance from a point on the cylindrical surface to its axis is always equal to the radius r 0 , namely: 2 . By calculating these seven parameters, one cylinder can be uniquely determined [28]. e cylinder fitting method used in this paper is described in detail as follows: (1) Determine the initial value of the parameters of the cylinder. Search for several adjacent points at any point on the cylinder, fit these points into a plane, and unify the normal vector of the plane into the unit normal vector of the point. Each point on the cylinder is processed to obtain the unit normal vector of each point. e unit normal vector of each point is regarded as a point, and these points are fitted into a plane to get the plane normal vector, that is, the initial values a 0 , b 0 , and c 0 of the cylinder axial quantity. In this step, principal component analysis method is used to solve the problem. After the axis is obtained, coordinate transformation is carried out on the cylinder, so that the axial quantity (a 0 , b 0 , c 0 ) of the cylinder is transformed into a vector parallel to the Z axis, and the (x, y) coordinate of a point on the cylinder is a plane circle. Use them fit the center of the circle, namely (x 1 , y 1 , z 1 ) and radius r.
Linearize f: e error equation is among them e error equation is written in matrix form AX � Y, the least square solution of AX � 0 is solved by the least square method, and the eigenvector corresponding to the minimum eigenvalue of A T * A is solved. is is a process of cyclic iteration. e initial value substituted in each iteration is equal to the previous initial value plus the modified X value. When the X value is small enough to meet the required accuracy, the iteration will exit. e cylindrical feature of special-shaped porous castings is extracted by using the abovementioned cylindrical feature fitting method, and the extracted cylindrical feature is shown in Figure 8. e point cloud after the above processing can represent the main features to be inspected of special-shaped porous castings, which lays a foundation for the subsequent experiments.

Inspection Path Planning.
e location of features to be detected and the extraction of the detection paths by machine vision lay the foundation for automatic detection. Because there is more than one feature to be inspected, it is inevitable that there will be many features to be inspected in the working range. In order to improve detection efficiency, this paper studies and designs a robot path optimization algorithm suitable for multifeatures to be detected. rough this path optimization algorithm, when multiple targets to be detected are detected, the path can make the end of the robot move the shortest distance among multiple targets can be found, thus improving the efficiency of automatic detection of ultrasonic phased array.
Assume that there are 3 features to be detected, in which point O represents the initial point when the end effector starts working, and A, B, and C represent the position of the feature to be detected. Starting from the initial point O, the end effector can select features to be inspected from A, B, and C for detection. Considering that the area to be inspected has three characteristics to be inspected, the schematic diagram of any detection path is shown in Figure 9. Assuming that there are N < 8 features to be inspected in the visual area, the total number of all features to be inspected is N! alternative paths. Taking 3 features to be inspected in the area as an example, there are 6 different inspection paths in total, and a   Shock and Vibration 7 path planning decision tree as shown in Figure 10 can be built. e optimal path planning algorithm is designed according to the path planning decision tree. By traversing all paths, we can get the shortest path during the process of the end effector movement. e formula for calculating the distance of the segment is as follows: e formula for calculating the total distance of the path is is path is an alternative one. To get the optimal path, traverse all feasible paths in the path planning decision tree shown in Figure 8 and select the path with the shortest distance as the optimal path.

System Components.
e vision-guided ultrasonic inspection system for industrial robots is mainly composed of KUKA KR20 R1810 industrial robot, M2M ultrasonic phased array detector, PC and RVCXmini depth camera, probe, fixed bracket, and other parts. Ultrasonic phased array detector is used for ultrasonic nondestructive testing of special-shaped porous castings, PC is used for image processing and path planning, probes are used for system calibration, and the attitude of probes and ultrasonic phased array probes can be interchanged.
e RVCXmini depth camera is composed of two 2D industrial cameras and a structured light sensor. e structure of the system is shown in Figure 11. e algorithm development environment adopts 64-bit Windows 10 operating system, and the RVCXmini depth camera driver, Matlab, RVC Manager image collection toolbox, PCL point cloud processing toolbox and robot network communication toolbox are installed, and the Visual Studio 2015 software development framework is adopted. Develop directly with C++, call OpenCV, and PCL computer vision libraries and directly call function libraries to process images. e software flow chart is shown in Figure 12. Figure 13 shows the experimental set-up for establishing the hand-target-eye spatial attitude transformation. e RVCXmini depth camera is installed at the end of the robot arm, and the pose of the target object in the robot tool coordinate system is further obtained by using the method of joint calibration of the robot hand-eye relationship and the tool coordinate system. According to the positioning result, the robot arm drives the end tool to move to the target position pose. By comparing the pose data of the robot arm tool end with the pose data of the robot arm tool end detected by the vision system, the robustness and accuracy of the algorithm are verified.

System Calibration.
First, the internal parameters of the camera are calibrated using Zhang Zhengyou's checkerboard calibration method [29] to take 15 to 20 checkerboard target images at different positions and angles. e principal point coordinates (u 0 , v 0 ) of the camera focal length f and the distortion coefficients k 1 , k 2 , p 1 , p 2 can be obtained by Zhang Zhengyou's calibration algorithm. ereby, the internal parameter transformation matrix M c between the image      Shock and Vibration to the robot flange coordinate system is determined, there is no attitude change between the center point of the ultrasonic phased array probe wafer and the center point of the robot flange end, but only the translation in position, so the transformation matrix M t of the tool coordinate system is established.
As shown in Figure 13, C v is define as a certain point in the pixel coordinate system, and C c is defined as the corresponding pixel point in the camera coordinate. Establish the relationship between them C v * M c � C c , define C u as the coordinates of the robot coordinate system, the external parameter equation between the camera coordinate system and the robot coordinate system is C c * M u � C u , define C e as the coordinate of the center point of the ultrasonic phased array wafer, and establish the coordinate relation expression according to the tool coordinate system as C u * M t � C e . When a certain point on the image C v is identified, C e � M c * M u * M t * C v can be deduced according to the above formula.
As a result, the hand-target-eye spatial attitude transformation relation is established. According to existing research [32][33][34], the camera is used to measure unidirectional pose accuracy and repeatability of industrial robots. e basic principle is to use a structured light sensor to indirectly measure the absolute posture of the robot by measuring 4 fixed reference points and to compare the real posture with the command posture to test the accuracy and repeatability of the posture. By evaluating results of pose repeatability, it can be said that the repeatability of the robot at the selected area of its workspace corresponds to the repeatability value stated by the manufacturer (±0.04 mm). Figure 14 shows the experimental device for visually inspecting and identifying the characteristics for irregular porous castings. Make sure that the features to be inspected of irregular porous castings are within the camera's field of view, scan through the RVCXmini depth camera to identify the target object of the irregular porous castings to be inspected, and obtain the pose of the target object in the camera coordinate system. Using the measurement algorithm proposed in this paper, the 4 groups of features to be inspected for irregular porous castings are repeatedly measured for 9 times, and the error range of the calculation algorithm is analyzed according to the measurement results, so as to verify the stability of the algorithm. Figure 15 shows the experimental setup of path optimization for multifeature detection. Obtain multiple features to be detected of special-shaped porous castings through visual inspection and feature recognition, by calculating the detection path distance between multiple features, select the shortest path during the movement of the ultrasonic probe at the end of the robotic arm. Calculate the distance of detection path, select the shortest path according to different numbers of features to be detected, and then carry out the corresponding ultrasonic phased array nondestructive testing operation.

Visual Positioning Experiment.
Experiments are carried out on the extraction effect of feature contour to be detected, and the effectiveness of the algorithm is verified by identifying the feature contour of the irregular porous casting under different backgrounds. rough many experiments, the recognition accuracy of the number of features to be detected within the shooting angle range is counted. Figure 16(a) is the scattered point cloud data of the multitarget specimen measured by the structured light scanner, which contains 920688 points, and the detection results obtained are shown in Figure 16(b). e boundary point extraction algorithm proposed in this paper was used to extract boundary points in the scattered point cloud data. e number of extracted boundary points extracted is 37392; 9 holes features in this feature have been successfully extracted. It can be seen from Figure 16 that this method in this paper can effectively extract the hole boundary features in the scattered point cloud and meet the recognition requirements for multiple features to be inspected.
Using RVCXmini depth camera to measure 9 holes with theoretical diameter d � 8 mm on multitarget specimens (as shown in Figure 16), the scattered point cloud data of specimens were obtained. e method proposed in this paper was used to process the data, and the parameters of the hole are obtained. e theoretical diameter is compared with the extraction result of this method, and the deviation of the extracted hole parameters by this method was obtained. e extraction results of the theoretical diameter and the parameters in this paper are shown in Figure 17.
When the machine vision system identifies the feature to be inspected, the central coordinates of the feature to be inspected in the image coordinate system are obtained, and the corresponding world coordinate system coordinates are solved as the calibration value. rough the forward kinematics of the robot, the robot is controlled to move to this point, and the center coordinates of the end effector at this time are obtained, which is used as the theoretical value of positioning. By comparing the deviation between the calibration value and the theoretical value of the center of the end effector in the world coordinate system, the positioning accuracy of the system can be judged.
e experimental results are shown in Table 1.
In order to verify the accuracy of the method to fit the cylindrical size, the RVCXmini depth camera was used to measure 5 theoretical cylindrical models (as shown in Figure 8) on the special-shaped porous castings, and the scattered point cloud data of the test piece was obtained. e fitting results were compared with the standard data of cylinder measurement. Table 2 shows the statistical data of 5 groups of fitting data.
From the extraction results and deviation in Table 1 and Figure 17, it can be concluded that the average value of the extraction deviation of the holes on the test piece by the method proposed in this paper is 0.107 mm, and the maximum value is 0.266 mm; the average extraction deviation of hole diameter is 0.002 mm, and the maximum value is 0.02 mm. From the analysis of extraction results and extraction deviation accuracy of hole position by this method is high, which can reach 0.107; from the analysis of Table 2, it is found that the average error of fitting the cylinder is less than 0.04 mm, and the calculation accuracy of the included angle between the two axes is less than 0.4°, which meets the fitting accuracy requirements. Comparing the data obtained by the algorithm proposed in this paper with the data of other scholars, research [35] proposes a contour extraction method, in which the position accuracy of the extraction hole was 0.1 mm, and the maximum error of the circles radius was less than 0.05 mm. Research [36] proposed a cylindrical fitting method to extract the diameter at breast diameter of bamboo, and the fitting accuracy was 0.4 cm. e algorithm proposed in this paper has met the practical requirements in extracting aperture, hole location, and cylinder fitting.

Features to be inspected
Order to be inspected

Path Planning Experiment.
e experiment of path optimization for multifeature detection is carried out. As shown in Figure 9, the coordinates of the initial point O were (0, 0, 0), and the coordinates of the three feature center points A, B, and C to be inspected were (250, 200, 0), (600, 150, 0), (300, 450, 0) (unit: mm), According to the path distance calculation formula, it can be obtained that the shortest distance d min of the 6 harvesting paths was 1127.1 mm, and the maximum distance d max was 1210.9 mm. e shortest distance path corresponds to the first path

Shock and Vibration
A ⟶ B ⟶ C and the sixth path C ⟶ B ⟶ A in the decision tree, and the sequence coordinates of the shortest path were (250, 200 ,0), (600, 150, 0), (300, 450, 0). In the process of path optimization, when the number of features of the detection area is different, the photos of the detection area are grouped to get the position coordinates and optimize the path. e data are shown in Table 3. e length of the detection path was used to evaluate detection efficiency. By analyzing the data in the table, the number of features to be inspected was 3, 4, and 5. Different detection trajectories are selected in each case, and the shortest path distance obtained by the path optimization algorithm was 6.9%, 11.5%, and 13.8% smaller than the longest path distance, respectively. e average value of the maximum efficiency improvement in the three cases was 10.7%. Considering that in the process of sequential detection, the actual detection path of the machine before path optimization may be any one in Figure 10. erefore, in these three cases, the detection efficiency is improved. It can be seen that when the path optimization algorithm proposed in this paper is used to sequentially detect multiple features, the moving distance of the end effector in the shortest detection path is shorter than that of other detection paths.

Conclusions
In this paper, special-shaped porous castings were taken as the research object, and a method of pore location parameter extraction based on scattered point clouds was proposed.
is method was used to process the scattered point cloud data of special-shaped porous castings. e radius center search method based on distance range and scale was used to skillfully avoid the interference of noise points. Finally, the scanned cylindrical point cloud was subjected to threedimensional visualization. So that it was convenient to intuitively reflect the state of the cylindrical model of the special-shaped porous casting. e test results show that this method can accurately extract all the hole features in the scattered point cloud, the extraction accuracy of hole position is high, the extraction accuracy can reach 0.107 mm, the average extraction deviation of hole diameter is 0.002 mm, the fitting diameter accuracy of the cylinder processed by this method is less than 0.04 mm, and the calculation accuracy of the included angle between the two axes is less than 0.4°, which meets the precision requirements of fitting cylindrical point cloud.
From the point of view of coordinate transformation, the point cloud data of the robot tool end were fitted into the three-dimensional space, and the optimal path is used for detection in this process, which improves the detection efficiency and accuracy, and the measured coordinates can be transformed to the robot world coordinate system. Experiments show that it can effectively maintain realtime accuracy of the center point of the robot end tool and meet the needs of rapid calibration of the robot end tool parameters in actual industrial production. Combining with the high-precision and noncontact characteristics of structured light, the rapid, high-precision and noncontact global three-dimensional reconstruction of large-scale structures is realized, which provides a positioning method basis for the damage detection of irregular porous castings based on vision, and improves the detection efficiency by using the automatic detection of the optimal path. e research content of this article has been applied to the actual production of military ship weapons and equipment. e irregular porous castings are unprocessed and cannot be reassembled or disassembled from the machine tool. In situ automatic ultrasonic phased array inspection will be carried out. e feature extraction algorithm of this research can accurately identify the features of deep irregular porous castings, and the robot can accurately reach the location of the feature to be inspected. e path optimization algorithm can provide a shorter detection path when performing ultrasonic automatic detection and realize the moving distance of the end effector in the shortest detection path is shorter than that of other detection paths. It can directly solve the technical problems that large-scale military castings cannot be inspected effectively on-site at present, can guide the inspectors to carry out scientific inspections, reasonably evaluate the manufacturing quality and ensure its battlefield index, and has important military benefits. At the same time, it is very helpful to promote the ultrasonic automatic nondestructive testing of deep specialshaped porous castings and has great economic and social benefits.

Data Availability
e data used to support the findings of this study are available from the corresponding author upon request.