zoukankan      html  css  js  c++  java
  • PCL学习(一)从PLY文件读入点云数据

    #include <iostream>  
    #include <pcl/io/pcd_io.h>  
    #include <pcl/point_types.h>  
    #include <pcl/io/ply_io.h>
    
    int main(int argc, char** argv)
    {
    	pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
    
    	if (pcl::io::loadPLYFile<pcl::PointXYZ>("model.ply", *cloud) == -1) //* load the file  
    	{
    		PCL_ERROR("Couldn't read file test_pcd.pcd 
    ");
    		system("PAUSE");
    		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;
    	//std::string filename("test.pcd");
    	//pcl::PCDWriter writer;
    	//writer.write(filename, *cloud);
    
    	system("PAUSE");
    	return (0);
    }
    

      上面这段代码从ply文件中读入点云

    #include <iostream>  
    #include <pcl/io/pcd_io.h>  
    #include <pcl/point_types.h>  
    #include <pcl/io/ply_io.h>
    #include <pcl/visualization/cloud_viewer.h>
    
    int main(int argc, char** argv)
    {
    	pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
    
    	if (pcl::io::loadPLYFile<pcl::PointXYZ>("model.ply", *cloud) == -1) //* load the file  
    	{
    		PCL_ERROR("Couldn't read file test_pcd.pcd 
    ");
    		system("PAUSE");
    		return (-1);
    	}
    	//pcl::StatisticalOutlierRemoval::applyFileter()
    	pcl::visualization::CloudViewer viewer("Viewer");
    	viewer.showCloud(cloud);
    
    	system("PAUSE");
    	return (0);
    }
    

      将读入的ply文件可视化出来

  • 相关阅读:
    Vuex的使用
    vue的props属性,vue的插槽
    ES6 Promise对象
    ES6 Map对象以及Set对象
    函数作用域以及块级作用域
    组件之间的传值-$refs&$parent
    Vue中父子组件的传值
    v-on 以及v-model的修饰符以及vue的常用指令
    时间线
    readline和xreadline的区别
  • 原文地址:https://www.cnblogs.com/BambooEatPanda/p/7551825.html
Copyright © 2011-2022 走看看