gpt4 book ai didi

c++ - 如何使用 PCL 读取 .ply 文件

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:06:44 55 4
gpt4 key购买 nike

我可以使用这个程序读取 .pcd 数据。

#include <iostream>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>

int
main (int argc, char** argv)
{
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);

if (pcl::io::loadPCDFile<pcl::PointXYZ> ("airplane.pcd", *cloud) == -1) //* load the file
{
PCL_ERROR ("Couldn't read file test_pcd.pcd \n");
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;

return (0);
}

如何读取 .ply 文件我在第 10 行做了以下更改:

if (pcl::io::loadPLYFile<pcl::PointXYZ> ("airplane.ply", *cloud) == -1) //* load the file

它给出了编译错误。

所以我重写为:

if (pcl::io::loadPCDFile<pcl::PointXYZ> ("airplane.ply", *cloud) == -1) //* load the file

现在它给了我运行时错误:

[pcl::PCDReader::readHeader] No points to read
Couldn't read file test_pcd.pcd

如何解决?

最佳答案

pcl::io::loadPLYFile() 函数确实是您应该用来读取 PLY 文件的函数。要解决编译问题,请确保包含适当的头文件 (pcl/io/ply_io.h)。

关于c++ - 如何使用 PCL 读取 .ply 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30764222/

55 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com