0%

PCL类型转换

PCL相关类型 对象与指针互换

  1. pcl::PointIndices -> pcl::PointIndices::Ptr
1
2
pcl::PointIndices inliers;
pcl::PointIndices::Ptr inliers_ptr(new pcl::PointIndices(inliers));
  1. pcl::PointIndices::Ptr -> pcl::PointIndices
1
2
3
pcl::PointIndices inliers;
pcl::PointIndices::Ptr inliers_ptr;
inliers=*inliers_ptr;
  1. std::vector -> pcl::IndicesPtr
1
2
std::vector<int> vec_indices;
pcl::IndicesPtr indices_ptr = boost::make_shared<std::vector<int>>(vec_indices);
  1. pcl::PointCloud -> pcl::PointCloud::Ptr
1
2
3
PointCloud<PointT>::Ptr cloud_ptr(new pcl::PointCloud<PointT>);
PointCloud<PointT> cloud;
cloud=*cloud_ptr;
  1. pcl::PointCloud::Ptr -> pcl::PointCloud
1
2
3
PointCloud<PointT>::Ptr cloud_ptr(new pcl::PointCloud<PointT>);
PointCloud<PointT> cloud;
cloud_ptr=cloud.makeShared();

不同数据类型的点云转换

  1. pcl::PointCloudpcl::PointXYZRGB -> pcl::PointCloudpcl::PointXYZ::Ptr
1
2
3
4
pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud_ori(new pcl::PointCloud<pcl::PointXYZRGB>);

pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
pcl::copyPointCloud(*cloud_ori, *cloud);