Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/134.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 读写不带PCL的pcd文件(点云库)_C++_Point Cloud Library_Uint32 T - Fatal编程技术网

C++ 读写不带PCL的pcd文件(点云库)

C++ 读写不带PCL的pcd文件(点云库),c++,point-cloud-library,uint32-t,C++,Point Cloud Library,Uint32 T,我正在尝试编写一个程序,在没有PCD(点云库)的情况下读取和写入PCL文件, 我可以毫无问题地读取每个点的位置, 但是RGB值是用uint32_t编写的,我不知道如何读取此格式并将其转换为RGB值 # .PCD v0.7 - Point Cloud Data file format VERSION 0.7 FIELDS x y z rgb SIZE 4 4 4 4 TYPE F F F F COUNT 1 1 1 1 WIDTH 100 HEIGHT 1 VIEWPOINT 0 0 0 1 0

我正在尝试编写一个程序,在没有PCD(点云库)的情况下读取和写入PCL文件, 我可以毫无问题地读取每个点的位置, 但是RGB值是用uint32_t编写的,我不知道如何读取此格式并将其转换为RGB值

# .PCD v0.7 - Point Cloud Data file format
VERSION 0.7
FIELDS x y z rgb
SIZE 4 4 4 4
TYPE F F F F
COUNT 1 1 1 1
WIDTH 100
HEIGHT 1
VIEWPOINT 0 0 0 1 0 0 0
POINTS 100
DATA ascii
-0.031568773 -0.99000001 0.99000013 2.3418052e-038
0.031568673 -0.98999995 0.99000013 2.3418052e-038
-0.031568974 -0.54999995 0.77000004 2.3418052e-038
0.031568889 -0.54999995 0.77000004 2.3418052e-038
是否将最后一个值(2.3418052e-038)转换为RGB值

在没有点云库的情况下,有没有办法做到这一点


谢谢。

请阅读以下来自维基百科的PLY格式数据

添加示例代码段以编写PLY文件

std::string fname = "sample.ply";
std::ofstream out(fname);
out << "ply\n";
out << "format ascii 1.0\n";
out << "comment\n";
out << "element vertex " << cloud5->points.size() << "\n";
out << "property float" << sizeof(float) * 8 << " x\n";
out << "property float" << sizeof(float) * 8 << " y\n";
out << "property float" << sizeof(float) * 8 << " z\n";
out << "property uchar red\n";
out << "property uchar green\n";
out << "property uchar blue\n";
out << "property list uchar int vertex_indices\n";
out << "end_header\n";
out.close();

out.open(fname, std::ios_base::app);
for (size_t i = 0; i < cloud5->points.size(); ++i)
{
    out << cloud5->points[i].x << " " << cloud5->points[i].y << " " << cloud5->points[i].z << " " << (int)cloud5->points[i].r 
        << " " << (int)cloud5->points[i].g << " " << (int)cloud5->points[i].b << "\n";
}
out.close();
std::string fname=“sample.ply”;
标准::流出流(fname);

通过谷歌搜索“PCL RGB格式”,我得到了一个简短的答案,虽然没有明确的答案,但结尾是一条评论,表明该人在评论中得到了他们需要的东西。下面详细描述了如何阅读此内容的代码说明: