pcl 是一個命名空間,跟std類似,PointCloud是類模板,<pcl::PointXYZ>是模板類實例化的類型。
在使用pcl::PointCloud<pcl::PointXYZI>::Ptr時需要使用new進行初始化,如下:
pcl::PointCloud<pcl::PointXYZI>::Ptr cloudxyzi(new pcl::PointCloud<pcl::PointXYZI>);
在使用 pcl::PointCloud<pcl::PointXYZI> cloudxyzi時作爲一個對象。
兩者可以相互轉換,如下:
//PointCloud::Ptr—>PointCloud
pcl::PointCloud<pcl::PointXYZ> cloud;
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_ptr(new pcl::PointCloud<pcl::PointXYZ>);
cloud=*cloud_ptr;
//PointCloud->PointCloud::Ptr
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_ptr(new pcl::PointCloud<pcl::PointXYZ>);
pcl::PointCloud<pcl::PointXYZ> cloud;
cloud_ptr=cloud.makeShared();
在實際的使用中,我們常常需要將pcl類型的數據保存爲las格式。具體的代碼如下所示:
int pcl2las(const std::string &output_lasfile,
const