【学习记录】将pcd文件转换成点云形式

pcl初学,希望我能好好掌握吧
使用blensor传感器运行得出了一系列数据
共有四个传感器,每个传感器内有20组点云数据(由于传感器是一条一条扫过去的),需要先将pcd文件转换成点云形式,并将它们进行拼接。
在这里插入图片描述在这里插入图片描述
建立cpp文件,并且要把pcd文件放在同一个目录下,以Scan04SR100000.pcd文件为例,

#include <iostream>  //输入输出头文件
#include <pcl\io\pcd_io.h>  //pcl读写类头文件
#include <pcl\point_types.h>  //pcl支持的点类型头文件
#include <pcl\point_cloud.h>  
#include <pcl\visualization\cloud_viewer.h>

int main(int argc, char** argv)    // pcl 函数名的方式
{
	//创建一个 PointCloud<pcl::PointXYZ>
	pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);

	//打开点云文件
	if(pcl::io::loadPCDFile<pcl::PointXYZ>("Scan04SR100000.pcd",*cloud)==-1)
	{
	PCL_ERROR("Couldn't read file Scan04SR100000.pcd\n");
	return (-1);
	}
	
	std::cout << "Loaded "
		<< cloud->width*cloud->height
		<< " data points from Scan04SR100000.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;
	return(0);
}

运行得到,确实得到了点云数据,但数据怎么转换成点云呢,并且还要读取很多组数据获得点,并且要把它们转换成可视的点云在这里插入图片描述
另外,把pcd文件后缀名改txt打开,如下所示

# .PCD v0.7 - Point Cloud Data file format
VERSION 0.7
FIELDS x y z rgb label
SIZE 4 4 4 4 4
TYPE F F F F U
COUNT 1 1 1 1 1
WIDTH 23
HEIGHT 1
VIEWPOINT 0 0 0 1 0 0 0
POINTS 23
DATA ascii
-0.000000 0.000000 -1.051850 1.858162681609866e-38 1802396020
-0.016934 0.000000 -1.046925 1.858162681609866e-38 1802396020
-0.033872 0.000000 -1.046785 1.858162681609866e-38 1802396020
-0.050819 0.000000 -1.046549 1.858162681609866e-38 1802396020
-0.067785 0.000000 -1.046323 1.858162681609866e-38 1802396020
-0.084786 0.000000 -1.046183 1.858162681609866e-38 1802396020
-0.101827 0.000000 -1.046032 1.858162681609866e-38 1802396020
-0.118914 0.000000 -1.045862 1.858162681609866e-38 1802396020
-0.136059 0.000000 -1.045689 1.858162681609866e-38 1802396020
-0.153269 0.000000 -1.045513 1.858162681609866e-38 1802396020
-0.170556 0.000000 -1.045336 1.858162681609866e-38 1802396020
-0.187928 0.000000 -1.045158 1.858162681609866e-38 1802396020
-0.205395 0.000000 -1.044975 1.858162681609866e-38 1802396020
-0.222967 0.000000 -1.044792 1.858162681609866e-38 1802396020
-0.240655 0.000000 -1.044607 1.858162681609866e-38 1802396020
-0.258469 0.000000 -1.044425 1.858162681609866e-38 1802396020
-0.295730 0.000000 -1.117189 1.864923666440540e-38 1802396020
-0.315082 0.000000 -1.116948 1.864923666440540e-38 1802396020
-0.334602 0.000000 -1.116702 1.864923666440540e-38 1802396020
-0.354303 0.000000 -1.116452 1.864923666440540e-38 1802396020
-0.374198 0.000000 -1.116201 1.864923666440540e-38 1802396020
-0.394301 0.000000 -1.115946 1.864923666440540e-38 1802396020
-0.414626 0.000000 -1.115689 1.864923666440540e-38 1802396020

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值