gpt4 book ai didi

c++ - PCL : X and Y values are changed when pcd file is loaded by PCL library

转载 作者:行者123 更新时间:2023-11-30 04:43:27 32 4
gpt4 key购买 nike

我想使用 PCL 加载点云数据。我可以在教程中正确加载示例数据,但是当我尝试使用我的数据时,pcd 文件的值被更改为非常小的值。

终端输出图像

实际值类似于 3603538.71629,但当 PCL 读取此文件时,它会变成非常小的值。这是我的 pcd 文件。

# .PCD v.7 - Point Cloud Data file format
VERSION .7
FIELDS x y z cluster
SIZE 4 4 4 4
TYPE F F F F
COUNT 1 1 1 1
WIDTH 14937
HEIGHT 1
VIEWPOINT 0 0 0 1 0 0 0
POINTS 14937
DATA binary
# POINT_X;POINT_Y;Count;Cluster
3603538.71629;5794698.05946;1;4
3605159.73611;5792213.47052;1;20
3605158.44424;5792230.86339;1;20
3605158.97718;5792221.85844;1;20
3605152.30217;5792232.17992;1;20
3604558.82308;5793345.02318;1;55
3604944.90684;5794341.30959;1;56

这是我的pcd_read.cpp

#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> ("xyzc-Cloud.pcd", *cloud) == -1) //* load the file
{
PCL_ERROR ("Couldn't read file xyzc-Cloud.pcd \n");
return (-1);
}
std::cout << "Loaded "
<< cloud->width * cloud->height
<< " data points from xyzc-Cloud.pcd with the following fields: "
<< std::endl;

for (size_t i = 0; i < 10; ++i)
std::cout << " " << cloud->points[i].x
<< " " << cloud->points[i].y
<< " " << cloud->points[i].z << std::endl;

return (0);
}
'''

环境:macOS 版本 10.14.16

最佳答案

我认为您看到损坏是因为您的坐标数据格式不正确。这些字段应该是空格或制表符分隔的,而你有一个字符 ;

引自docs :

Storing point cloud data in both a simple ascii form with each point on a line, space or tab separated, without any other characters on it, as well as in a binary dump format, allows us to have the best of both worlds: simplicity and speed, depending on the underlying application.

通过查看 reader source 可以确认这一点使用以下内容拆分行。您的分号将导致无效拆分和随后的 float 提取。该函数不会因格式不正确而返回错误,这就是为什么您的代码仍然有效,尽管不正确。

boost::split (st, line, boost::is_any_of ("\t\r "), boost::token_compress_on);

因此,答案是使用空格分隔符格式化您的 .pcd 正文数据。


另外正如@UlrichtEckhardt 评论的那样,您正在混合和匹配预期的输出格式:

替换

DATA binary

DATA ascii

关于c++ - PCL : X and Y values are changed when pcd file is loaded by PCL library,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58282502/

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