最遠(yuǎn)點(diǎn)采樣(Farthest Point Sampling)
這里我們來(lái)單獨(dú)看一下調(diào)用代碼,這里可以看到PCL中支持直接調(diào)用farthest_sampling這個(gè)函數(shù)可以實(shí)現(xiàn)最遠(yuǎn)點(diǎn)采樣。
最遠(yuǎn)點(diǎn)采樣(Farthest Point Sampling)是一種非常常用的采樣算法,由于能夠保證對(duì)樣本的均勻采樣,被廣泛使用,像3D點(diǎn)云深度學(xué)習(xí)框架中的PointNet++對(duì)樣本點(diǎn)進(jìn)行FPS采樣再聚類作為感受野,3D目標(biāo)檢測(cè)網(wǎng)絡(luò)VoteNet對(duì)投票得到的散亂點(diǎn)進(jìn)行FPS采樣再進(jìn)行聚類,6D位姿估計(jì)算法PVN3D中用于選擇物體的8個(gè)特征點(diǎn)進(jìn)行投票并計(jì)算位姿。FPS算法原理:
1、輸入點(diǎn)云有N個(gè)點(diǎn),從點(diǎn)云中選取一個(gè)點(diǎn)P0作為起始點(diǎn),得到采樣點(diǎn)集合S={P0};
2、計(jì)算所有點(diǎn)到P0的距離,構(gòu)成N維數(shù)組L,從中選擇最大值對(duì)應(yīng)的點(diǎn)作為P1,更新采樣點(diǎn)集合S={P0,P1};
3、計(jì)算所有點(diǎn)到P1的距離,對(duì)于每一個(gè)點(diǎn)Pi,其距離P1的距離如果小于L[i],則更新L[i] = d(Pi, P1),因此,數(shù)組L中存儲(chǔ)的一直是每一個(gè)點(diǎn)到采樣點(diǎn)集合S的最近距離;
3、選取L中最大值對(duì)應(yīng)的點(diǎn)作為P2,更新采樣點(diǎn)集合S={P0,P1,P2};
4、重復(fù)2-4步,一直采樣到N’個(gè)目標(biāo)采樣點(diǎn)為止。
std::vector< pcl::PointCloud< pcl::PointXYZ >> input_point_clouds(1);
std::vector< pcl::PointCloud< pcl::PointXYZ >> output_point_clouds;
ASSERT_NE(pcl::io::loadPLYFile< pcl::PointXYZ >(STR(INPUT_POINT_CLOUD_PATH),
input_point_clouds[0]), -1) < < "Couldn't read file test point cloud file";
farthest_sampling::samplePointCloudsCuda(input_point_clouds, output_point_clouds, 4096);
boost::filesystem::path output_path = STR(OUTPUT_POINT_CLOUD_PATH);
if (output_path.has_parent_path() && !boost::filesystem::exists(output_path.parent_path()))
{
boost::filesystem::create_directories(output_path.parent_path());
}
pcl::io::savePLYFile(STR(OUTPUT_POINT_CLOUD_PATH), output_point_clouds[0]);
ASSERT_EQ(output_point_clouds[0].size(), 4096);
-
plc
+關(guān)注
關(guān)注
5016文章
13388瀏覽量
465416 -
函數(shù)
+關(guān)注
關(guān)注
3文章
4346瀏覽量
62974 -
采樣
+關(guān)注
關(guān)注
1文章
123瀏覽量
25617
發(fā)布評(píng)論請(qǐng)先 登錄
相關(guān)推薦
評(píng)論