Geometric Modeling of Rosa roxburghii Fruit Based on Three-Dimensional Point Cloud Reconstruction

Fruit three-dimensional (3D) model is crucial to estimating its geometrical and mechanical properties and improving the level of fruit mechanical processing. Considering the complex geometrical features and the required model accuracy, this paper proposed a 3D point cloud reconstruction method for the Rosa roxburghii fruit based on a three-dimensional laser scanner, including 3D point cloud generation, point cloud registration, fruit thorns segmentation, and 3D reconstruction. The 3D laser scanner was used to obtain the original 3D point cloud data of the Rosa roxburghii fruit, and then the fruit thorns data were removed by the segmentation algorithm combining the statistical outlier removal and radius outlier removal. By analyzing the eﬀects of ﬁve-point cloud simpliﬁcation methods, the optimal simpliﬁcation method was determined. The Poisson reconstruction algorithm, the screened Poisson reconstruction algorithm, the greedy projection triangulation algorithm, and the Delaunay triangulation algorithm were utilized to reconstruct the fruit model. The number of model vertices, the number of facets, and the relative volume error were used to determine the best reconstruction algorithm. The results indicated that this model can better reconstruct the actual surface of Rosa roxburghii fruit. The method provides a reference for the related application.


Introduction
Rosa roxburghii is a perennial deciduous shrub of the Rosaceae Rosa genus, which is mainly distributed in southwest areas in China, such as Yunnan, Guizhou, and Sichuan [1,2]. Rosa roxburghii fruit has high nutritional value and health function [2][3][4], and it is a kind of fruit with great economic value. In recent years, the Rosa roxburghii has been vigorously promoted in Guizhou, which has 133,000 hectares of planting area and 100,000 tons of annual output of fresh fruits. However, the degree of automation in the fruit processing process is not high, especially the process of fruit picking and fruit pedicle removal. In order to realize the whole automation of fruit processing, it is particularly important for the three-dimensional digital reconstruction of Rosa roxburghii fruit.
3D reconstruction of agricultural and forestry crops has become an important research method in agricultural scientific research. In this method, plants with complex shapes can be studied by combining agricultural production knowledge and computer graphics technology [5,6]. e 3D reconstruction methods of agricultural and forestry crops mainly include the image-based reconstruction, the parametric model-based reconstruction, and the 3D point cloudbased reconstruction [7][8][9][10]. e image-based reconstruction method is to use multiple images to reconstruct the surface model of crops. Quan et al. [11] and Wang et al. [12] reconstructed 3D models of plants and corn ears, respectively, based on image technology. A robotic arm with a camera was used to collect a series of two-dimensional images of the object to achieve three-dimensional reconstruction, and the influence of the motion of the robotic arm on the accuracy of the threedimensional image reconstruction was studied [13]. is method has the advantage of quickness and simplicity but has the defect in detailed features. e parametric model-based reconstruction method needs to collect the surface characteristic parameters of the object. Kempthorne et al. [14] applied the discrete smoothing D 2 -spline algorithms to reconstruct the leaf surfaces from point cloud data. Hu et al. [15] presented the method based on 3D visualization to measure the leaf area, length, and width of poplar seedlings. Tinoco et al. [16] modeled the topological structure of coffee fruits based on Bezier curves and performed finite element analysis. e accuracy of this method is not very high, and it is not suitable for the reconstruction of complex shapes. e 3D point cloud-based reconstruction method relies on the instrument to directly obtain the 3D information of the measured object, which has high accuracy and wide applications. Sun and Wang [17] proposed the 3D rapid greenhouse plant point cloud reconstruction method based on autonomous Kinect v2 sensor position calibration. Xie et al. [18] used the terrestrial LiDAR to obtain point cloud data of a single tree and reconstructed the 3D model of the tree with leaves. Zermas et al. [19] utilized an unmanned aerial vehicle and the handheld camera with structure from motion to reconstruct 3D canopies of small groups of corn plants. An accurate 3D point cloud data is critical for these methods, but the methods of using the Kinect v2 sensor, terrestrial LiDAR, and unmanned aerial vehicle to obtain point cloud data ignore or simplify the object details. In addition, the prickly surface of Rosa roxburghii fruit brings challenges to the acquisition of the 3D point cloud of the fruit. e 3D lasers canner is widely used to obtain 3D point cloud data due to the advantages of noncontact and high accuracy [20]. Zhang et al. [21] employed the 3D laser scanning technology to obtain the point cloud data of apple tree leaves and achieved 3D reconstruction of apple tree leaves. Considering that the detailed features of the fruit surface can be acquired by a 3D laser scanner, it is a novel idea to use the 3D laser scanner to obtain the point cloud data of the Rosa roxburghii fruit. e novelties and contributions of this paper are summarized as follows: (1) Proposing a 3D point cloud reconstruction method for the Rosa roxburghii fruit based on the 3D laser scanner (2) Designing a fruit thorns segmentation algorithm combining statistical outlier removal and radius outlier removal and improving the accuracy of the 3D model of Rosa roxburghii fruit (3) Proposing a volume calculation method for Rosa roxburghii fruit based on cylindrical coordinates to verify the accuracy of the reconstructed model e main purpose of this paper is to obtain an accurate 3D geometric model of the Rosa roxburghii fruit without thorns which will facilitate the subsequent finite element simulation of the mechanical properties and the design of related mechanical processing equipment. e rest of this paper is arranged as follows: in Section 2, the measurement system, point cloud registration, segmentation algorithm, and 3D reconstruction algorithm are described in detail. In Section 3, the results of point cloud segmentation, simplification, and reconstruction are discussed in detail, and the 3D reconstruction method is verified. Section 4 summarizes this paper.

Structure and Principle of the Measurement System.
e schematic diagram of obtaining point cloud data of Rosa roxburghii fruit is shown in Figure 1. Figure 1 shows that Rosa roxburghii fruit has sharp thorns and an uneven surface. e noncontact 3D laser scanner (Laser-RE600111) was used to obtain the surface of Rosa roxburghii in this experiment. And its collection frequency, scanning accuracy, scanning distance, and measurement range are 1000-15000/s, 0.02 mm, 150 mm, and 600 mm (length) × 500 mm (width) × 400 mm (height), respectively. e operation process of collecting data was divided into 3 steps. Firstly, a white developer was sprayed on the fruit surface to obtain a good diffuse reflection shape, and then the laser scanner was employed to measure the horizontal and vertical point cloud data of the fruit in the rotating state. Secondly, the point cloud data from different angles were manually registered through three preset marker points, and then the point cloud processing software (Geomagic studio 2017) was used for secondary fine registration. Finally, the final point cloud format was saved as a PCD file to facilitate the subsequent running of algorithms. e point cloud data collection experiment of Rosa roxburghii was completed in the reverse engineering laboratory.
In the paper, the point cloud images were all visualized by MATLAB R2018b. e 3D reconstruction flowchart of Rosa roxburghii fruit is shown in Figure 2.

Registration of the Point Cloud of Fruit.
Since the pedicle end of the fruit is concave and the stalk end is approximately flat, the point cloud data of the top and bottom of the fruit cannot be obtained for the vertical position. erefore, it is necessary to rotate the fruit to obtain the top and bottom point cloud data. In the experiment, the fruit was placed vertically along the z-axis (Figure 1), and the platform was rotated 360°t o collect point cloud data around the fruit. In order to make the point cloud on the top and bottom of the fruit and the point cloud on the side of the fruit in the same coordinate system, the fruit must be rotated 90°and −90°(rotate counterclockwise as positive direction) around the y-axis (Figure 1), respectively. rough the rotation matrix (equation (1)), the point cloud data on the top and bottom of the fruit and the point cloud data on the side of the fruit can be unified into the same coordinate system by iterative closest point (ICP) [22] algorithm. e registration process of fruit point cloud data is shown in Figure 3. e relationship between point cloud data before and after rotation is shown in equation (2): pointcloud ′ m x n , y n , z n � pointcloud m x n , y n , z n × R y (α), where pointcloud m is the mth point cloud data before rotation adjustment; (x n , y n , z n ) are the coordinates of the point  Journal of Food Quality cloud; n is the number of point clouds; pointcloud ′ m is the mth point cloud data after rotation adjustment; R y (α) is rotation matrix of the fruit rotating around the y-axis; and α is the rotation angle of the point cloud.
In Figure 3, the point cloud data of the side, top, and bottom of the Rosa roxburghii fruit were scanned by a platform that can rotate at a uniform speed, and they were registered together through the corresponding rotation matrix. After the point cloud registration process, the complete point cloud of Rosa roxburghii fruit was obtained for fruit thorns segmentation and point cloud simplification.

Segmentation Algorithm of Fruit orns.
Generally, it is inevitable to be affected by the accuracy of the instrument, the operation of personnel, and external environmental factors, so that the collected point cloud data contains noise, which have adverse effects on the subsequent operation and 3D reconstruction of the point cloud data [23]. Besides, the analysis of mechanical properties of Rosa roxburghii fruit is affected by the fruit thorns on the fruit surface, which need to be removed when building the geometric model. e segmentation algorithm combining the statistical outlier removal [24,25] and radius outlier removal [26] was proposed to remove noise and fruit thorns. A flowchart of a fruit thorn segmentation algorithm was proposed, as shown in Figure 4. e steps of the segmentation algorithm can be summarized as follows: Step 1: the point cloud dataset is assumed to be P � p 1 , p 2 , . . . , p n , and the three-dimensional space coordinates of any point p i is (x i , y i , z i ). e size k value of the neighborhood is input, and then the 3D space coordinates of the k neighbors of p i are expressed as (x j , y j , z j ). e formula for calculating the average distance d i from each point to its k neighbors is as follows: Step 2: the mean μ and standard deviation σ of the average distance between each point's neighborhoods are calculated. eir calculation formulas are as follows: where n is the original point cloud number of Rosa roxburghii fruit.
Step 3: each point of the dataset is judged on whether it is an outlier. e standard deviation multiple α is set as a constant; if d > μ + ασ, the point is judged as an outlier, and it is deleted; and if d < μ + ασ, the point is judged to be a normal point, and it is retained.
Step 4: steps 1-3 are repeated until all points are calculated and judged.
Step 5: the remaining outliers are removed by radius outlier removal. e threshold N of the number of k nearest neighbors and the radius r of the search sphere are, respectively, determined. If the number of neighbors of a point within the radius r of the sphere is less than the threshold N, the point is determined to be an outlier and can be deleted. Otherwise, the point is a normal point and retained.
Step 6: until all the points are traversed, the segmentation algorithm is ended.

Point Cloud 3D
Reconstruction. Nowadays, some wellknown reconstruction algorithms based on point cloud have been proven to have good reconstruction effects on solid surfaces, such as ball pivoting [27], Poisson reconstruction [28], screened Poisson reconstruction [29], marching cubes [30], alpha shapes [31], greedy projection triangulation [32], and Delaunay triangulation [33]. is paper uses the Poisson reconstruction algorithm, screened Poisson reconstruction algorithm, greedy projection triangulation algorithm, and Delaunay triangulation algorithm to reconstruct the 3D model of Rosa roxburghii fruit.

Poisson Reconstruction Algorithm.
e Poisson reconstruction algorithm belongs to the implicit function of the triangle mesh reconstruction algorithm, in which the advantages of local fitting and global fitting are taken into account [34]. While the global smoothness of the reconstructed surface is realized, the local detailed features are preserved, and the reconstruction effect for closed surfaces is better. Except for the point samples around the surface, the gradient of the indicator function everywhere is a vector field with a value of zero. erefore, the indicator function is equal to the inner normal of the surface. e core idea of the algorithm is as follows: for an unknown 3D entity M, to solve an indicator function χ after its surface zM is smoothed, so that its gradient field is equal to the divergence of the surface zM vector field V → [28]: where χ M is the indicator function of M, F shows the smoothing filter function, N → denotes the inward normal of the point, and p s is the area of the small patch. e approximate steps of the Poisson reconstruction algorithm are as follows [35]: (1) discretization function space through Octree, (2) estimating the vector field by using principal component analysis, (3) solving the Poisson equation, and (4) extracting the isosurface. e flowchart of the algorithm is shown in Figure 5.

Screened Poisson Reconstruction Algorithm.
Although in the process of solving Poisson's equation, an approximate solution of the indicator function can be obtained, this approximate solution may be very different from the real indicator function. In order to avoid this shortcoming, Kazhdan and Hoppe [29] proposed the screened Poisson surface reconstruction algorithm, which introduces the constraints of the point set to turn the problem solving into the process of solving the screened Poisson equation to make the solved indicator function more accurate. Figure 6 shows the flowchart of the screened Poisson reconstruction algorithm. e detailed steps of the screened Poisson reconstruction algorithm are as follows: (1) incorporating point constraints, (2) scale-independent screening, (3) discretizing the function space with an Octree, (4) estimating the vector field, and (5) solving the screened Poisson equation as follows:

Greedy Projection Triangulation
Algorithm. e greedy projection triangulation algorithm is a surface reconstruction technology based on triangulation and the greedy algorithm. e idea of the greedy algorithm is to simplify complex problems without considering the overall situation, but only seeking local optimal solutions. And the greedy algorithm follows three criteria, namely, the nearest greedy criterion, the nearest neighbor greedy criterion, and the directed greedy criterion. e basic steps of the algorithm are as follows [32]: Step 1: at a certain point, the local tangent plane perpendicular to the normal vector of the point should be determined first.
Step 2: in the three-dimensional point cloud set, an initial triangle is determined, and the k nearest neighbors of the three points constituting the triangle are searched.
ese three points and their k neighboring points are projected on the tangent plane of the point along the normal direction.
Step 3: the two-dimensional triangulation of the projection point on the projection plane is performed.
Step 4: the optimal expansion point on the two-dimensional plane is mapped back to the three-dimensional space to form a spatial triangle grid.
Step 5: steps 1-4 are looped until a complete mesh surface is formed, and then the algorithm is stopped.

Delaunay Triangulation
Calculate the mean μ and standard deviation σ of the average distance d i Journal of Food Quality by constructing a triangle mesh. In the triangulation algorithm, the Delaunay triangulation algorithm can obtain the optimal triangulation grid. According to the different implementation processes, Delaunay triangulation can be divided into point-by-point insertion method [36], region growth method, divide-and-conquer method [37], and random Delaunay filtering method [38]. In this paper, the Delaunay triangulation algorithm based on region growth is adopted. e basic steps of the algorithm are as follows [33]: Step 1: any point in the point set is selected, and the nearest neighbor point to that point is found.
Step 2: the line connecting these two points is used as the initial edge to expand outward, and the third point that can form the best Delaunay triangle with the initial edge is searched.
Step 3: the initial side and the third point form a new triangle, and the other two sides of the new triangle except for the initial side are added to the edge queue, but the existing sides cannot be added repeatedly.
Step 4: steps 1-3 are repeated until the surface growth is completed.

Result of Point Cloud Segmentation.
e original 3D point cloud of the Rosa roxburghii obtained by the 3D laser scanner is shown in Figure 7(a), and the total number of point clouds contained 230674 points. e 3D point cloud after segmentation using the statistical outlier removal algorithm [24,25] is shown in Figure 7(b), and the number of neighbor points k and the standard deviation multiple were set to 35 and 1.3, respectively. e 3D point cloud after segmentation using the radius outlier removal algorithm [26] is shown in Figure 7(c), and the threshold N of the number of neighbor points and the radius r of the sphere were taken as 60 and 0.8, respectively. e 3D point cloud after segmentation using the bilateral filtering algorithm [39] is shown in Figure 7(d). It can effectively remove the noise points, but it cannot effectively remove the thorns. e 3D point cloud after segmentation using the proposed separation algorithm is shown in Figure 7  removed, indicating that the segmentation effect was particularly obvious. Figures 7(a)-7(e) show that the four segmentation algorithms can effectively remove noise, and the proposed segmentation algorithm can remove fruit thorns better than the other three segmentation algorithms.

Comparison of Different Simplification Methods.
Owing to the high accuracy of the 3D laser scanner, the amount of point cloud data collected is greatly large, which not only contains the geometric information of the Rosa roxburghii fruit but also has redundant data points that need to be eliminated [40]. Plenty of time is consumed, and a large amount of computer memory is occupied in the data processing process. Furthermore, all points need not be calculated at the stage of 3D reconstruction, as long as the feature points are retained. In order to balance the contradiction between time and efficiency, it is necessary to streamline the point cloud data for the grid reconstruction process [41]. e 3D voxel grid filter method [42,43], the curvature sampling method [44], the random sampling method, the uniform sampling method, and the distance sampling method are common simplification methods.
In the point cloud streamlining processing stage, the 3D voxel grid filter method, the curvature sampling method, the random sampling method, the uniform sampling method, and the distance sampling method were compared and analyzed, and the best sampling method was determined as the simplification algorithm. In order to assess the point cloud simplification effect of different sampling methods, the simplification rate η and average error ε were introduced to evaluate the simplification effect. e simplification rate η was defined as follows: where n 1 represents the number of point clouds before simplification and n 2 represents the number of point clouds before simplification. e average error ε is defined as follows [45]: where d(u, v) represents the Euclidean distance between the sampling point u of the original surface S of the fruit and the projection point v of the simplified surface. Generally, when the simplification rate is constant, the greater the average error is, the greater the deviation between the surface and the sampled data is and vice versa. Table 1 shows the simplification rate and average error of the point cloud reconstruction model with different sampling methods. e effect of different sampling methods on the point cloud is shown in Figure 8. It can be seen from Table 1 that when simplification rate η was approximately 90%, the average error of the 3D voxel grid filter method is the smallest in the five sampling methods, and the average error of the random sampling method is the largest. Moreover, it can be seen from Figure 8 that the random sampling method did not consider the detailed feature points to randomly sample and streamline, which resulted in uneven point cloud sampling. From the effect point of view, although the uniform sampling method and the distance sampling method were more uniform, the detail feature of the point cloud was not obvious. Although the curvature sampling method can retain feature points well, the standard deviation of the reconstructed model is higher than that of the 3D voxel grid filter method. Considering the average error of the reconstruction model and the advantages and disadvantages of the point cloud sampling methods, the 3D voxel grid filter can retain the features better and the error was small, so this method was selected to simplify the point cloud of the Rosa roxburghii fruit.

Comparison of Different Reconstruction Algorithms.
e above four reconstruction algorithms were used in the 3D reconstruction of Rosa roxburghii fruit for experimental comparison, and the effect of the fruit reconstruction model is shown in Figure 9. Based on the number of vertices (NMV), the number of facets (NMF), and the relative volume error (RVE) of the fruit reconstruction model, the reconstruction accuracies of the four reconstruction algorithm models were analyzed, which are shown in Table 2.
e three evaluation indicators selected in this article are described in detail as follows.

Number of Model Vertices (NMV).
For the triangular mesh reconstruction algorithm, the reconstructed mesh model is composed of a large number of triangular facets, and the number of vertices of the triangular facets represents the degree of fineness of the facets. e finer the patch, the higher the realism of the model.

Number of Model Facets (NMF).
e larger the number of triangles is, the more obvious the details of the reconstructed model are, and the higher the accuracy of the model is.

Relative Volume Error (RVE).
e actual volume of the Rosa roxburghii fruit is 14.2 cm 3 by calculating the volume of water discharged from the container, and the reconstructed model volume was calculated by Geomagic Studio. RVE is given by the following equation: where V 1 represents the area of the actual volume and V 2 represents the area of the reconstructed model volume.
As can be seen from Table 2, the NMV and NMF of the Poisson reconstruction and those of the screened Poisson reconstruction algorithm are very close, and the NMV and NMF of the greedy projection triangulation algorithm and those of the Delaunay triangulation algorithm are also similar. From the point of view of the number of model vertices and the number of faces, the reconstruction effects of Poisson reconstruction and screened Poisson reconstruction algorithm were better than other algorithms. From the perspective of the RVE of the model, the screened Poisson reconstruction algorithm has the smallest volume error (1.06%), which showed that its reconstruction accuracy is better than other algorithms. It can be seen from Figure 9 that not only does the reconstruction model reconstructed by the screened Poisson reconstruction algorithm have obvious fruit details but also the model is smooth and complete without redundant facets on the surface. So, the screened Poisson reconstruction algorithm has the best reconstruction effect. e surface details of the model reconstructed by the greedy projection reconstruction and triangulation reconstruction algorithms are not prominent. So, the reconstruction effect was relatively poor. erefore, the screened Poisson reconstruction algorithm was considered to be the most suitable algorithm to reconstruct the 3D model of the Rosa roxburghii fruit.

Effects of Octree Depth Value on Reconstruction Results.
In order to obtain a high-precision 3D model, the effect of the Octree depth value on the accuracy of the model reconstructed by the screened Poisson reconstruction algorithm was studied in this section. In the screened Poisson reconstruction algorithm, the function space needed to be discretized, the bounding box of the rectangular parallelepiped containing all the point clouds was subdivided through the Octree, and then the Poisson equation was solved. Generally, the greater the Octree depth value is, the richer the retained details are and the higher the accuracy of the surface reconstruction is. However, the reconstruction time is also affected by the Octree depth value. With the increase of the Octree depth value, the reconstruction time was longer and the efficiency showed a downward trend. In   order to evaluate the accuracy of the 3D reconstruction algorithm of Rosa roxburghii fruit in this paper, the REV (equation (10)) was used to evaluate the effect of this reconstruction method. Table 3 shows the relationship between the Octree depth value and the reconstruction effect, reconstruction time, and volume relative error.
As is shown in Table 3, as the Octree depth value increases, the NMV, NMF, and T all increase, and the REV first decreases and then increases. When the Octree depth value is 10, the NMV, NMF, and T all increase, but the REV at this time is still 1.76%. When the Octree depth value is 7, the REV of the reconstruction model is the smallest. erefore,  the Octree depth value of the screened Poisson reconstruction algorithm is selected as 7.

Verification of 3D Reconstruction.
In order to verify the consistency between the reconstructed model and the actual fruit shape, the peripheral area, the length in the x-axis direction, and the length in the y-axis direction of the corresponding section were calculated step by step. Along the z-axis, the Rosa roxburghii fruit was sliced with a thickness of 2 mm. In this article, the internal structure of Rosa roxburghii fruit was ignored, and only the external shape was verified. e schematic diagram of calculating the peripheral sectional area, the length in the x-axis direction, and the length in the y-axis direction is shown in Figure 10. e sectional area A j was integrated as follows [46]:    , (11) where Δθ i is the stepping angle, r j i is the radius of the stepping angle, and n is the number of stepping angles. e slice peripheral sectional area and length of the reconstructed model were calculated in the 3D modeling software UG. e actual peripheral sectional area and length were manually measured using equation (11). e relative error of sectional area and length between actual measurement and 3D reconstruction model is shown in Figure 11. e mean absolute percentage error is calculated as MAPE � (1/n) n 0 |x m − x r /x m | (x m is measured values, x r is model values). e MAPE of the peripheral sectional area is 1.01%, the MAPE of the length in the x-axis direction is 1.30%, and the MAPE of the length in the y-axis direction is 1.06%. e results illustrated this model can better reconstruct the actual curved surface of Rosa roxburghii fruit, and the method provides a reference for the development of the related application.

Conclusions
In this paper, a 3D laser scanner was used to acquire point cloud data on the surface of a Rosa roxburghii fruit. e segmentation algorithm and the simplification algorithm were implemented to obtain the point cloud data which is conducive to model reconstruction.
e Poisson reconstruction algorithm, the screened Poisson reconstruction algorithm, the greedy projection triangulation algorithm, and the Delaunay triangulation algorithm were used to reconstruct the fruit model. In order to verify the accuracy of the reconstruction model, the volume of the reconstructed model obtained using the point cloud was compared with the volume measured manually. e main findings can be summarized as follows: (1) A segmentation algorithm combining statistical outlier removal and radius outlier removal is proposed, and the fruit thorns on the Rosa roxburghii fruit model can be effectively removed by the segmentation algorithm. (2) Compared with the curvature sampling method, random sampling method, uniform sampling method, and distance sampling method, the average error of the reconstruction model using the 3D voxel grid filter method is the smallest, and the detailed features are obviously retained. (3) Compared with the greedy projection triangulation algorithm, Delaunay triangulation algorithm, and Poisson reconstruction algorithm, the reconstruction model using the screened Poisson reconstruction algorithm has the most vertices and facets, and no holes are generated. When the Octree depth value is set to 7, the REV of the reconstruction model is the smallest.
(4) e MAPE of the peripheral sectional area is 1.01%, which shows that this model can better reconstruct the actual curved surface of the Rosa roxburghii fruit.

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

Conflicts of Interest
e authors declare that they have no conflicts of interest.