如何使用PCL读取.ply文件 [英] How to read .ply file using PCL
本文介绍了如何使用PCL读取.ply文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以使用此程序读取.pcd数据.
I can read .pcd data using this program.
#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行进行了以下更改:
How to read a .ply file i made the following change in line 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
现在它给了我运行时错误:
Now it gave me run-time error:
[pcl::PCDReader::readHeader] No points to read
Couldn't read file test_pcd.pcd
该如何解决?
推荐答案
pcl::io::loadPLYFile()
函数确实是您用来读取PLY文件的函数.要解决编译问题,请确保包含适当的头文件(pcl/io/ply_io.h
).
The function pcl::io::loadPLYFile()
is indeed what you should use to read PLY files. To solve the compilation problem, make sure that you include appropriate header file (pcl/io/ply_io.h
).
这篇关于如何使用PCL读取.ply文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文