PCL基础2:点云赋值
生活随笔
收集整理的這篇文章主要介紹了
PCL基础2:点云赋值
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1.用于交換兩個點云
? ? ? ? 1.1 使用賦值號 =
each_board_edge_pc_v[0] = each_board_edge_pc_v[1];
? ? ?? 1.2?使用swap()函數
each_board_edge_pc_v[0].swap(each_board_edge_pcl_v[1]);
2.使用pcl::copyPointCloud()
? ?? 2.1拷貝部分點云(即按照索引拷貝)pcl::copyPointCloud (const pcl::PointCloud &cloud_in, const std::vector &indices,pcl::PointCloud &cloud_out)
pcl::PointCloud<pcl::PointXYZ>::Ptr src(new pcl::PointCloud<pcl::PointXYZ>);
pcl::io::loadPCDFile("src.pcd",*src);//讀入
pcl::PointCloud<pcl::PointXYZ>::Ptr cloudout(new pcl::PointCloud<pcl::PointXYZ>);//建立空的用于存儲新拷貝的點云
std::vector<int>indexs = { 0,2,6 };//索引
pcl::copyPointCloud(*src, indexs, *cloudout);//按照索引位置拷貝到cloudout
pcl::io::savePCDFile("cloud_out.pcd", *cloudout);//只取src中的第1,第3個,第7個點賦值到新的cloudout中。
? ? ? ?? 2.2完全拷貝到新的點云之中:pcl::copyPointCloud (const pcl::PointCloud &cloud_in,pcl::PointCloud &cloud_out)
pcl::PointCloud<pcl::PointXYZ>::Ptr src(new pcl::PointCloud<pcl::PointXYZ>);
pcl::PointCloud<pcl::PointNormal>::Ptr src_PN(new pcl::PointCloud<pcl::PointNormal>);pcl::io::loadPCDFile("src.pcd",*src);//載入原數據
pcl::io::loadPCDFile("src_pn.pcd", *src_PN);//載入原數據pcl::copyPointCloud(*src, *src_PN);//src中的xyz覆蓋掉src_PN中的xyz值,然后把xyz+normal的信息給src_PNpcl::io::savePCDFile("src_with_normal.pcd", *src_PN);
?
其余的拷貝方式見官網,的重載函數:PCL中還有很多
http://docs.pointclouds.org/1.8.1/group__common.html#gab99511f54b952b8a5608e4ed7f41a68d
?
總結
以上是生活随笔為你收集整理的PCL基础2:点云赋值的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: PCL基础1:点云数据结构
- 下一篇: PCL基础4:PCLVisualizer