#include <iostream>
#include <io.h>
#include <direct.h>
#include <fstream>
#include <vector>
#include <string>
#include <pcl/io/io.h>
#include <pcl/io/pcd_io.h>
#include <pcl/io/ply_io.h>
#include <pcl/point_types.h>
#include <pcl/visualization/cloud_viewer.h>
#include<pcl/common/angles.h>
#include <Eigen/core>
#include <Eigen/Dense>
using namespace std;
struct PointXYZILID
{
PCL_ADD_POINT4D; // quad-word XYZ
float intensity; ///< laser intensity reading
uint16_t label; ///< point label
uint16_t id;
EIGEN_MAKE_ALIGNED_OPERATOR_NEW // ensure proper alignment
} EIGEN_ALIGN16;
// Register custom point struct according to PCL
POINT_CLOUD_REGISTER_POINT_STRUCT(PointXYZILID,
(float, x, x)
(float, y, y)
(float, z, z)
(float, intensity, intensity)
(uint16_t, label, label)
(uint16_t, id, id))
using PointType = PointXYZILID;
int main()
{
pcl::PointCloud<PointXYZILID>::Ptr cloud_1(new pcl::PointCloud<PointXYZILID>);//初始化点云
pcl::io::loadPLYFile<PointXYZILID>("chongjian0.0015.ply", *cloud_1);//加载pcd点云并放入cloud中
pcl::PointCloud<pcl::PointXYZI> cloud_NG;//初始化点云
cloud_NG.height = 1;
cloud_NG.width = cloud_1->points.size();
cloud_NG.is_dense = false;
cloud_NG.points.resize(cloud_NG.width * cloud_NG.height);
for (int i=0; i < cloud_1->points.size(); i++)
{
cloud_NG.points[i].x = cloud_1->points[i].x / 1000;
cloud_NG.points[i].y = cloud_1->points[i].y / 1000;
cloud_NG.points[i].z = cloud_1->points[i].z / 1000;
}
pcl::io::savePLYFileASCII("chongjian0.00115.ply", cloud_NG);
return 0;
}
PCL自定义点云格式以及坐标精度转换
最新推荐文章于 2024-08-10 22:58:42 发布
该程序读取一个名为chongjian0.0015.ply的PLY文件,将点云数据转换为PointXYZILID类型,然后缩放点云坐标值(除以1000),并将结果保存为新的PLY文件chongjian0.00115.ply。转换涉及点的x、y、z坐标以及intensity属性。
摘要由CSDN通过智能技术生成