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文件可视化出来

  • 相关阅读:
    Python——极限编程
    RPC是什么?科普一下
    缓存在高并发场景下的常见问题
    如何提高缓存命中率
    数据库性能优化的误区
    缓存在大型网站架构中的应用
    APP多版本共存,服务端如何兼容?
    水平分库分表的关键问题及解决思路
    分库分表的几种常见玩法及如何解决跨库查询等问题
    分布式系统事务一致性解决方案
  • 原文地址:https://www.cnblogs.com/BambooEatPanda/p/7551825.html
Copyright © 2011-2022 走看看