pcl點雲的創建、訪問與轉換


一、點雲的創建與訪問

第一種,是一種vector的賦值方式,將point數據push_back到pcl::PointXYZ類型的模板中。
1 pcl::PointCloud<pcl::PointXYZ> pointCloud; 2 pcl::PointXYZ point; 3       point.x = 2.0f - y; 4       point.y = y; 5       point.z = z; 6       pointCloud.points.push_back(point);

訪問:PointXYZ 成員:float x,y,z;表示了xyz3D信息,可以通過points[i].data[0]或points[i].x訪問點X的坐標值。

第二種,指針型類模板,采用“->points[i]”方式賦值。

1 pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>); 2 for (int i = 0; i < cloud->points.size (); ++i) 3  { 4     cloud->points[i].x = 1024 * rand () / (RAND_MAX + 1.0f); 5     cloud->points[i].y = 1024 * rand () / (RAND_MAX + 1.0f); 6     cloud->points[i].z = 1024 * rand () / (RAND_MAX + 1.0f); 7   }

二、點雲的轉換

//創建
pcl::PointCloud<pcl::PointXYZ> cloud;//點雲對象
pcl::PointCloud<pcl::PointXYZ>::Ptr cloudPtr
		(new pcl::PointCloud<pcl::PointXYZ>);//點雲指針對象

  

//轉換
cloud = * cloudPtr; cloudPtr = cloud.makeShared();

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM