1. 程式人生 > 其它 >06-點雲的讀取與顯示

06-點雲的讀取與顯示

點雲資料的讀取與顯示:

  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