| 14 | using CloudT = pcl::PointCloud<PointT>; |
| 15 | |
| 16 | void findClusters(const CloudT::Ptr pc){ |
| 17 | pcl::PointCloud<pcl::Label> euclidean_labels; |
| 18 | std::vector<pcl::PointIndices> label_indices; |
| 19 | |
| 20 | pcl::EuclideanClusterComparator<PointT, pcl::Label>::Ptr |
| 21 | euclidean_cluster_comparator(new pcl::EuclideanClusterComparator<PointT, pcl::Label>()); |
| 22 | |
| 23 | std::cout << pc->points.size() << std::endl; |
| 24 | std::cout << pc->width << std::endl; |
| 25 | std::cout << pc->height << std::endl; |
| 26 | |
| 27 | euclidean_cluster_comparator->setInputCloud(pc); |
| 28 | euclidean_cluster_comparator->setDistanceThreshold(0.5, false); |
| 29 | |
| 30 | pcl::OrganizedConnectedComponentSegmentation<PointT, pcl::Label> |
| 31 | euclidean_segmentation(euclidean_cluster_comparator); |
| 32 | euclidean_segmentation.setInputCloud(pc); |
| 33 | euclidean_segmentation.segment(euclidean_labels, label_indices); |
| 34 | |
| 35 | pcl::PCDWriter writer; |
| 36 | std::cout << "NUM CLUSTERS: " << label_indices.size() << std::endl; |
| 37 | for (size_t i = 0; i < label_indices.size (); i++){ |
| 38 | if (label_indices.at(i).indices.size () > 100){ |
| 39 | std::cout << "LABEL INDICES SIZE: " << label_indices.at(i).indices.size() << std::endl; |
| 40 | |
| 41 | CloudT cluster; |
| 42 | pcl::copyPointCloud(*pc, label_indices.at(i).indices, cluster); |
| 43 | // clusters.push_back(cluster); |
| 44 | std::stringstream ss; |
| 45 | ss << "/opt/bags/inf/pcds/realcc/" << "cloud_cluster_" << i << ".pcd"; |
| 46 | writer.write<PointT> (ss.str (), cluster, false); |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | } |
| 51 | |
| 52 | int main(int argc, char* argv[]) |
| 53 | { |
no outgoing calls
no test coverage detected