87 {
88#ifdef DEBUG_NCUT
89 double start_t = omp_get_wtime();
90#endif
91
92 _segment_pids.clear();
93 _segment_labels.clear();
94 _segment_bbox.clear();
95 _outlier_pids.clear();
96 _cluster_points.clear();
97 _cluster_bounding_box.clear();
98 _cluster_skeleton_points.clear();
99 _cluster_skeleton_features.clear();
100 std::vector<int> pids(cloud->size());
101 for (size_t i = 0; i < cloud->size(); ++i) {
102 pids[i] = static_cast<int>(i);
103 }
105 AINFO <<
"cloud obstacle size in ncut segment is " << _cloud_obstacles->size();
106#ifdef DEBUG_NCUT
107 ADEBUG <<
"segment enter ... input cloud size " << cloud->size();
108
109#endif
110
111
112
113 SuperPixelsFloodFill(cloud, _grid_radius, _super_pixel_cell_size, &_cluster_points);
114#ifdef DEBUG_NCUT
115
116 ADEBUG <<
"super pixels " << _cluster_points.size();
117 AINFO <<
"super pixels done " << omp_get_wtime() - start_t;
118 start_t = omp_get_wtime();
119#endif
120
121
122 PrecomputeAllSkeletonAndBbox();
123#ifdef DEBUG_NCUT
124 AINFO <<
"precompute skeleton and bbox done " << omp_get_wtime() - start_t;
125 start_t = omp_get_wtime();
126#endif
127
128 std::vector<std::vector<int>> segment_clusters;
129 std::vector<std::string> segment_labels;
130 NormalizedCut(_ncuts_stop_threshold, true, &segment_clusters, &segment_labels);
131#ifdef DEBUG_NCUT
132 AINFO <<
"normalized_cut done, #segments " << segment_clusters.size() <<
", time: " << omp_get_wtime() - start_t;
133 start_t = omp_get_wtime();
134#endif
135
136 for (size_t i = 0; i < segment_clusters.size(); ++i) {
137 std::vector<int> pids;
138 GetClustersPids(segment_clusters[i], &pids);
139 if (pids.size() > 0) {
140 _segment_pids.push_back(pids);
141 _segment_labels.push_back(segment_labels[i]);
142 NcutBoundingBox box;
143 GetComponentBoundingBox(segment_clusters[i], &box);
144 _segment_bbox.push_back(box);
145 }
146 }
147}