1 // 定义相关变量 2 pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_ptr (new pcl::PointCloud<pcl::PointXYZ>); 3 pcl::PointCloud<pcl::PointXYZ>& cloud = *cloud_ptr; //点云 4 //初始化点云数据PCD文件头 5 cloud.width = depthHeight * depthWidth; 6 cloud.height = 1; 7 cloud.is_dense = false; 8 cloud.points.resize (cloud.width * cloud.height); 9 10 //显示重建得到的点云数据 11 pcl::visualization::CloudViewer viewer("Cloud Viewer"); 12 viewer.showCloud(cloud_ptr); 13 14 //保存点云数据 15 pcl::io::savePCDFileASCII ("test_pcd.pcd", cloud); 16 std::cerr << "Saved " << cloud.points.size () << " data points to test_pcd.pcd." << std::endl;
时间: 2024-10-05 19:42:13