A. Preparation.

Parameter settings. 1. Setting the parameters of the LAPO algorithm. (1) *n* groups of initial clustering centers are used as an initial clustering center group for each group of *k* clustering centers (*k* is set randomly). (2) *t* is the number of iterations. (3) *tmax* is the maximum number of iterations. 2. Setting the DBSCAN algorithm parameters. (1) The traditional DBSCAN algorithm: *Eps* and *MinPts* are set according to the actual situation. (2) The dynamic DBSCAN algorithm: the radius range of the dynamic fruit tree is set according to the radius of the fruit tree, which is *Dyn*\_*rad* ∈ [*radmin*,*radmax*]. According to the LiDAR sensor parameters and distance, different neighborhood density thresholds are obtained as *Dyn*\_*pts* ∈ [*Pts*\_*nummin*, *Pts*\_*nummax*].

Setting various functions. 1. Equation (8) is the objective function.

$$F\_{\rm min} = \sum\_{i=1}^{n} \sum\_{j=1}^{k} v\_{i,j} \parallel x\_i - c\_j \parallel \,^2 \tag{8}$$

where *vi*,*<sup>j</sup>* = ' <sup>1</sup> *i f arg minjdis xi*, *cj* <sup>0</sup> *else* is the confidence function, which means that each

datum in the data set can only belong to one class.

2. Equation (9) is the Euclidean distance between two points, where *i* = *j*.

$$dis\left(X\_{i\prime}X\_{j}\right) = \sqrt{\sum\_{i=1}^{n}\sum\_{j=1}^{k}\left(X\_{i} - X\_{j}\right)^{2}}\tag{9}$$

B. Detailed steps.

1. Initializing the LiDAR data and setting the corresponding parameters.

2. Randomly selecting an initial cluster center group (*n* groups of cluster centers for each group of *k*) to form a matrix *C* of *n* rows and *k* columns:

$$\mathbf{C} = \begin{bmatrix} \{\boldsymbol{\varepsilon}\_{1,1}, \boldsymbol{\varepsilon}\_{1,2}, \dots, \boldsymbol{\varepsilon}\_{1,k-1,\prime}\boldsymbol{\varepsilon}\_{1,k}\} \\ \{\boldsymbol{\varepsilon}\_{2,1}, \boldsymbol{\varepsilon}\_{2,2}, \dots, \boldsymbol{\varepsilon}\_{2,k-1,\prime}\boldsymbol{\varepsilon}\_{2,k}\} \\ \vdots \\ \{\boldsymbol{\varepsilon}\_{n-1,1}, \boldsymbol{\varepsilon}\_{n-1,2}, \dots, \boldsymbol{\varepsilon}\_{n-1,k-1,\prime}\boldsymbol{\varepsilon}\_{n-1,k}\} \\ \{\boldsymbol{\varepsilon}\_{n,1,\prime}\boldsymbol{\varepsilon}\_{n,2,\prime}, \dots, \boldsymbol{\varepsilon}\_{n,k-1,\prime}\boldsymbol{\varepsilon}\_{n,k}\} \end{bmatrix}.$$

The cluster center of the row is expressed by Equation (10).

$$C\_i = Data\_{min} + rand \times (Data\_{max} - Data\_{min}) \tag{10}$$

where *rand* is a random number in the range [0, 1]. *Datamax* and *Datamin* are the maximum and minimum values of the radar data, respectively.

3. According to Equation (8), the fitness of cluster center group (*C*) is calculated. The optimal value, worst value, and average value of the cluster center group are *Cbest*, *Clow*, and *Cave*, respectively. According to the objective function, if *Flow* > *Fave*, we can assign the value of *Cave* to *Clow*.

4. If the cluster center (*Ci*) of a certain row is updated, a group of cluster centers (*Cj*) is randomly selected from the population, where *i* = *j*. If *Fave* > *Fj*, Equation (11) can be used to iterate.

$$\mathbf{C}\_{i} = \mathbf{C}\_{i} + rand \times (\mathbf{C}\_{\text{wave}} - rand \times (\mathbf{C}\_{i})) \tag{11}$$

If *Fj* > *Fave*, Equation (12) can be used to iterate.

$$\mathbb{C}\_{i} = \mathbb{C}\_{i} - rand \times \left( \mathbb{C}\_{\text{wve}} - rand \times \left( \mathbb{C}\_{i} \right) \right) \tag{12}$$

After the above process is complete, the updated cluster center group (*Cnew*) can be obtained.

5. Return to step (3). Updating the cluster center group (*Cnew*) and obtaining the optimal value, the worst value and mean value of the cluster center group will be *Cnew\_best*, *Cnew\_low*, and *Cnew\_ave*, respectively.

6. *Cnew* can be iterated through Equation (13) to obtain a new cluster center group *Cnew*.

$$\mathbb{C}\_{n\text{new}} = \mathbb{C}\_{n\text{new}} + rand \times \mathbb{S} \times \left(\mathbb{C}\_{n\text{new\\_ave}} + rand \times \left(\mathbb{C}\_{n\text{new\\_law}} - \mathbb{C}\_{n\text{new\\_best}}\right)\right) \tag{13}$$
 
$$\ell \le \lambda \qquad \ell \le \lambda$$

where *S* = 1 − *t tmax* <sup>×</sup> *exp* <sup>−</sup> *<sup>t</sup> tmax*

.

7. Return to step (3). The cluster center group (*Cnew*) needs to be updated and the optimal value (*Cnew\_best*), worst value (*Cnew\_low*), and mean value (*Cnew\_ave*) of the cluster center group can be obtained.

8. With step (2) to step (7), the optimal cluster center group (*Cbest*) can be obtained and the fitness can be calculated according to the objective function to obtain a set of optimal cluster centers (*cbest*), namely, {*c*1\_*best*, *c*2\_*best*, ··· *ck*−1\_*best*, *ck*\_*best*}.

9. According to the obtained cluster centers, Equation (9) can be used to find the distance between each cluster center. When the distance between two points is less than the diameter of the fruit tree (the diameter of the fruit tree at the height of the radar installation), the distance between the two points is used. The two cluster centers can be replaced with the midpoint (when encountering bifurcated fruit trees, the midpoint is also used to replace the two points). Otherwise, the cluster center remains unchanged. Finally, the updated cluster center (*cbest*) can be obtained.

10. Equation (9) can be used to calculate the distance from each point (*xi*) to the cluster center (*cbest*) in the data set and dividing each data point into each cluster center according to the confidence function, which is *Dist*(*xi*, *cn*\_*best*) = (*xi* − *cn*\_*best*) 2 .

11. According to the actual situation, when the *Eps* and *MinPts* conditions are met, the cluster center is retained; otherwise, the cluster center is discarded.

12. After discarding some of the cluster centers that do not meet the criteria, according to the DBSCAN algorithm (still must meet the *Eps* and *MinPts* conditions), clustering is performed to obtain the corresponding cluster, and the mean value of the corresponding cluster is used to represent the cluster center (*ci*).

13. When the distance between two cluster centers is less than the diameter of the fruit tree (the diameter of the fruit tree at the radar installation position), return to step (9). Otherwise, the final cluster center (*cfinal*) should be obtained to form a cluster.

14. According to the final cluster center (*cfinal*), the following two conditions need to be met to determine whether something is a fruit tree. Firstly, if the fruit tree dynamic radius (*Dyn*\_*rad*), which is *radmin* ≤ *Dist*(*Xi*, *Cn*\_*best*) ≤ *radmax*, is satisfied, an object is a fruit tree. At the same time, if it meets the dynamic neighborhood density threshold (*Dyn*\_*pts* ∈ [*Pts*\_*nummin*, *Pts*\_*nummax*]), the object is a fruit tree.

15. Finally, the position of each fruit tree can be detected.

#### 2.4.3. Algorithm Improvement

The algorithm solves the problem of local optimal solutions in the LAPO algorithm and parameter globality in the DBSCAN algorithm. In the LAPO algorithm, *n* initialized cluster centers are randomly selected, as shown in step (2). As the selected *n* cluster centers are random, there will be local optimal solutions in the calculation process for LAPO (from step (3) to step (8)). In the actual test, the local optimal solution may appear in the following situations. The results of the algorithm identify a set of clustering centers, but there is obvious deviation (the obvious deviation here refers to the situation where the clustering center is not on the data point and cannot correspond to the relevant data point) and two clustering centers are together. At the same time, the LAPO algorithm also has the problem of missing perception. To solve the above problems, the LAPO algorithm is improved. When the two clustering centers are together, the two clustering centers can be combined into one by taking the midpoint in step (9). In the cases of obvious deviation and missing detection, the final cluster center can be obtained by the DBSCAN algorithm (from step (10) to step (12)), but fruit trees may still not be detected. As the DBSCAN algorithm is affected by *Eps* and *MinPts*, in the step (14) *Eps* and *MinPts* are used to distinguish fruit trees by the dynamic threshold method. Through three-layer detection, the positive detection rate of fruit tree detection can be greatly improved.
