How to read .ply file using PCL

匿名 (未验证) 提交于 2019-12-03 02:03:01

问题:

I can read .pcd data using this program.

#include  #include  #include   int main (int argc, char** argv) {   pcl::PointCloud<:pointxyz>::Ptr cloud (new pcl::PointCloud<:pointxyz>);    if (pcl::io::loadPCDFile<:pointxyz> ("airplane.pcd", *cloud) == -1) //* load the file   {     PCL_ERROR ("Couldn't read file test_pcd.pcd \n");     return (-1);   }   std::cout width * cloud->height             points.size (); ++i)     std::cout points[i].x               points[i].y               points[i].z 

How to read a .ply file i made the following change in line 10:

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

It gave comilation error.

SO i rewrote as:

if (pcl::io::loadPCDFile<: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  

How to resolve this?

回答1:

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).



回答2:

We can also create a PLYReader as the PCDReader as shown below to read the PLY file and all the points to the required cloud

#include  pcl::PointCloud<:pointxyz>::Ptr cloud (new pcl::PointCloud<:pointxyz pcl::plyreader="" reader="" reader.read="" of="" the="" ply="" file="">


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!