首页 > 解决方案 > 不期望将 .ply 文件转换为 .pcd 文件

问题描述

我正在将 .ply 文件转换为 .pcd 文件。我的 .ply 文件的标题如下:

ply
format binary_little_endian 1.0
element vertex 63194
property float x
property float y
property float z
property uchar blue
property uchar green
property uchar red
property uchar alpha
end_header

输出数据如下:

VERSION 0.7VERSION 0.7
FIELDS x y z rgba
SIZE 4 4 4 4
TYPE F F F U
COUNT 1 1 1 1
WIDTH 63194
HEIGHT 1
VIEWPOINT 0 0 0 1 0 0 0
POINTS 63194
DATA ascii
-7734.2715 8366.3252 -2.1842694 0
-7734.5063 8366.3125 -1.9932992 0
-7733.0181 8366.3887 -2.20522 0
-7733.2417 8366.376 -2.0148311 0
-7731.7578 8366.4414 -2.2282174 0

我发现所有的 agba 都是 0,但是我找不到决定 rgba 值的代码。
所以我的问题是我怎样才能得到正确的 rgba?这是我的测试代码

bool loadCloud (const std::string &filename, pcl::PCLPointCloud2 &cloud)
{
  pcl::PLYReader reader;
  if (reader.read (filename, cloud) < 0)
    return (false);
  return (true);
}

void saveCloud (const std::string &filename, const pcl::PCLPointCloud2 &cloud, bool format)
{
  pcl::PCDWriter writer;
  writer.write (filename, cloud, Eigen::Vector4f::Zero (), Eigen::Quaternionf::Identity (), format);
}

int main (int argc, char** argv)
{

  pcl::PCLPointCloud2 cloud;
  if (!loadCloud ("input.ply", cloud))
    return (-1);

  saveCloud ("output.pcd", cloud, false);

  return (0);
}

标签: c++point-cloud-library

解决方案


推荐阅读