Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
246 views
in Technique[技术] by (71.8m points)

c++ - Cannot read .pcd file in PCL

I'm trying to read a .pcd file in PCL. When reading the file I get these warnings:

Failed to find match for field 'x'.
Failed to find match for field 'y'.
Failed to find match for field 'z'.

And when printing the point cloud all points are (0, 0, 0). This is the code I'm running:

pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud_ptr(new pcl::PointCloud<pcl::PointXYZRGB>);
pcl::PointCloud<pcl::PointXYZRGB> &cloud = *cloud_ptr;

if (pcl::io::loadPCDFile<pcl::PointXYZRGB>(argv[1], cloud) == -1) {
    std::cerr << "Was not able to open file "" << argv[1] << ""." << std::endl;
    return -1;
}

for (size_t i = 0; i < 100; i++)
{
    std::cout << "("
              << cloud.points[i].x << ", "
              << cloud.points[i].y << ", "
              << cloud.points[i].z
              << ")"
              << std::endl;
}

Any help would be appreciated, thanks!

This is the start of the .pcd file in question:

# .PCD v0.7 - Point Cloud Data file format
VERSION 0.7
FIELDS x y z rgb
SIZE 8 8 8 4
TYPE F F F U
COUNT 1 1 1 1
WIDTH 110810
HEIGHT 1
VIEWPOINT 0 0 0 1 0 0 0
POINTS 110810
DATA ascii
376.955 301.529 33.3325 6190433
376.665 298.94 32.9225 6321233
376.815 301.199 33.3225 5336153
377.475 301.969 34.0125 4480345
376.935 301.77 32.8725 6716771
...

This file was generated by converting a .ply file through the pcl_ply2pcd tool. I have also tried to directly read the .ply file through loadPLYFile but I get the same result.

This is the version of PCL that I'm using:

-> apt-cache policy libpcl-dev
libpcl-dev:
    Installed: 1.10.0+dfsg-5ubuntu1
    Candidate: 1.10.0+dfsg-5ubuntu1
Version table:
*** 1.10.0+dfsg-5ubuntu1 500
    500 http://archive.ubuntu.com/ubuntu focal/universe amd64 Packages
    100 /var/lib/dpkg/status

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...