点云数据的读取与显示:
desk.pcd 数据百度链接:
链接:https://pan.baidu.com/s/1mYleYemNmizXZGLQbUC59A
提取码:atma
#include <iostream> #include <pcl\io\pcd_io.h> #include <pcl\point_types.h> #include <pcl\visualization\cloud_viewer.h> int main() { pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>); if (pcl::io::loadPCDFile<pcl::PointXYZ>("F:\\BaiduNetdiskDownload\\pcl\\desk.pcd", *cloud) == -1) { PCL_ERROR("Couldn't read file rabbit.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; }*/ pcl::visualization::CloudViewer viewer("cloud viewer"); viewer.showCloud(cloud); while (!viewer.wasStopped()) { } system("pause"); return 0; }View Code