用c++写一个点云pcd文件读取
时间: 2023-03-12 12:19:54 浏览: 90
我可以为你提供一个示例代码,可以用来读取PCD文件:
#include <pcl/io/pcd_io.h>// 定义一个点云类型
typedef pcl::PointCloud<pcl::PointXYZ> PointCloud;int main (int argc, char** argv)
{
// 读取点云文件
PointCloud::Ptr cloud (new PointCloud);
if (pcl::io::loadPCDFile<pcl::PointXYZ> (argv[1], *cloud) == -1) //* load the file
{
PCL_ERROR ("Couldn't read file test_pcd.pcd \n");
return (-1);
}
std::cout << "Loaded "
<< cloud->width * cloud->height
<< " data points from test_pcd.pcd with the following fields: "
<< std::endl;
for (size_t i = 0; i < cloud->points.size (); ++i)
std::cout << " " << cloud->points[i].x
<< " " << cloud->points[i].y
<< " " << cloud->points[i].z << std::endl;
return (0);
}