
歐式聚類流程如下:
設置一個合適的聚類搜索半徑Cluster-Tolerance很重要,如果半徑過小,那么會分割出多個對象,如果設置太高會造成多個對應聚類到成一個,因此需要測試找到合適的搜索半徑。
#include?#include?#include?#include?pcl::PointCloud::Ptr?cloud_filtered?(new?pcl::PointCloud);//?Creating?the?KdTree?object?for?the?search?method?of?the?extractionpcl::search::KdTree::Ptr?tree?(new?pcl::search::KdTree); tree->setInputCloud?(cloud_filtered);std::vector?cluster_indices; pcl::EuclideanClusterExtraction?ec; ec.setClusterTolerance?(0.02);?//設置近鄰搜索的搜索半徑2cmec.setMinClusterSize?(100);????//設置一個聚類需要的最少點數目ec.setMaxClusterSize?(25000);??//設置一個聚類需要的最大數目ec.setSearchMethod?(tree);?????//設置點云的搜索方法ec.setInputCloud?(cloud_filtered); ec.extract?(cluster_indices);????????//從點云中提取聚類并保存到cluster_indices中//保存聚類后的點到磁盤int?j?=?0;for?(std::vector::const_iterator?it?=?cluster_indices.begin?();?it?!=?cluster_indices.end?();?++it) { ???pcl::PointCloud::Ptr?cloud_cluster?(new?pcl::PointCloud);???for?(std::vector::const_iterator?pit?=?it->indices.begin?();?pit?!=?it->indices.end?();?++pit) ?????cloud_cluster->points.push_back?(cloud_filtered->points[*pit]);?//* ???cloud_cluster->width?=?cloud_cluster->points.size?(); ???cloud_cluster->height?=?1; ???cloud_cluster->is_dense?=?true;???std::cout?<"PointCloud?representing?the?Cluster:?"?<points.size?()?<"?data?points."?<?(ss.str?(),?*cloud_cluster,?false);?//* ???j++; }
人工智能 大數據 AI
版權聲明:本文內容由網絡用戶投稿,版權歸原作者所有,本站不擁有其著作權,亦不承擔相應法律責任。如果您發現本站中有涉嫌抄襲或描述失實的內容,請聯系我們jiasou666@gmail.com 處理,核實后本網站將在24小時內刪除侵權內容。
版權聲明:本文內容由網絡用戶投稿,版權歸原作者所有,本站不擁有其著作權,亦不承擔相應法律責任。如果您發現本站中有涉嫌抄襲或描述失實的內容,請聯系我們jiasou666@gmail.com 處理,核實后本網站將在24小時內刪除侵權內容。