# RGB-D-Based Robotic Grasping in Fusion Application Environments
## 2 Materials and Methods
### Clustering Algorithm  
In this paper, we chose Density-Based Spatial Clustering of Applications with Noise (DBSCAN) [18] as the clustering algorithm. As a density-based clustering algorithm, DBSCAN has the advantage of finding arbitrarily shaped clusters in a noisy spatial database. Considering that there are non-negligible errors in the measurement results of depth cameras on non-optimal smooth surfaces, the DBSCAN algorithm is well suited to handle the problem we face. As shown in Figure 2, after we obtain the instance segmentation result from the output of the NN, we then project the 2D information into a 3D point cloud by combining the pixel positions of the segmented instances with the corresponding depth map.The project formulas are as follows:  
\[\begin{split} z&=Image_{depth}(u,v)\\ x&=(u-C_{x})*z/f_{x}\\ y&=(v-C_{y})*z/f_{y}\\ \end{split} \tag{1}\]  
Figure 3: RGB-D cameras have poor performance when measuring smooth surfaces; significant breaks and distortions in the 3D point cloud data exist in the figure.  
Figure 2: The overall processing of the robotic grasping method in this paper.  
\(u\) and \(v\) are the pixel coordinates in both RGB images and Depth images, \(C_{x}\) and \(C_{y}\) are the coordinates of the camera's principal point, \(f_{x}\) and \(f_{y}\) are the scale factors of the camera in the u-axis and v-axis directions they could obtain from the camera intrinsic matrix. Moreover, it is vital that RGB images and Depth images are aligned. After that, we perform DBSCAN clustering on the filtered segmented images, as shown in Algorithm 1. When we have accumulated the latest five frames of data, we take the intersection of them as the segmentation result.  
```
0: dataset \(D=\{p_{1},p_{2},...,p_{n}\}\), algorithm parameter \((\epsilon,Min\text{Pts})\)
1: Initializing the set of core points \(\Omega=\emptyset\), the number of clusters \(k=0\), unvisited sample set \(B=D\) and the set of clusters \(C=\emptyset\)
2:for each \(p_{i}\in D\)do
3: Initializing its neighborhood points set \(N_{\epsilon}(p_{i})=\emptyset\)
4:for any \(p_{m}\
eq p_{i}\) In addition, \(p_{m}\in D\)do
5: Calculate the distance \(d(i,m)\) to \(p_{i}\)
6:if\(d(i,m)<\epsilon\)then
7:\(N_{\epsilon}(p_{i})=N_{\epsilon}(p_{i})\cup p_{m}\)
8:endif
9:endfor
10:if\(|N_{\epsilon}(p_{i})|>Min\text{Pts}\)then
11:\(\Omega=\Omega\cup p_{i}\)
12:endif
13:endfor
14:if\(\Omega=\emptyset\)then
15: Quit the algorithm
16:endif
17: Randomly choose an item \(o\in\Omega\), initializing the current core points set \(\Omega_{cur}=\{o\}\), marking the item as the cluster \(k\), initializing its cluster set \(C_{k}=\{o\}\) and update \(B=B-\{o\}\)
18:if\(\Omega_{cur}=\emptyset\)then
19:\(C_{k}\) has been determined, updating the set of clusters \(C=\{C_{1},C_{2},...,C_{k}\}\) and back to line 14.
20:endif
21:Updating \(\Omega=\Omega-C_{k}\)
22:Randomly chose an item \(o^{\prime}\in\Omega_{cur}\), determine its neighborhood points set \(N_{\epsilon}(o^{\prime})\) based on the distance parameter \(\epsilon\), let \(\Delta=N_{\epsilon}(o^{\prime})\cap B\), updating \(C_{k}=C_{k}\cup\Delta\), \(B=B-\Delta\) and \(\Omega_{cur}=\Omega_{cur}\cup(\Delta\cap\Omega)-o^{\prime}\), back to line 18
23:Clusters set \(C=\{C_{1},C_{2},...,C_{k}\}\)
```  
**Algorithm 1** DBSCAN