我正在尝试使用可视化点云PCL http://pointclouds.org/云浏览器。问题是我对 C++ 很陌生,我找到了两个教程first https://pcl.readthedocs.io/projects/tutorials/en/latest/writing_pcd.html#writing-pcd演示点云的创建和second https://pcl.readthedocs.io/projects/tutorials/en/latest/cloud_viewer.html#cloud-viewer演示点云的可视化。但是,我无法将这两个教程结合起来。
这是我想出的:
#include <iostream>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <pcl/visualization/cloud_viewer.h>
int main (int argc, char** argv)
{
pcl::PointCloud<pcl::PointXYZ> cloud;
// Fill in the cloud data
cloud.width = 5;
cloud.height = 1;
cloud.is_dense = false;
cloud.points.resize (cloud.width * cloud.height);
for (size_t i = 0; i < cloud.points.size (); ++i)
{
cloud.points[i].x = 1024 * rand () / (RAND_MAX + 1.0f);
cloud.points[i].y = 1024 * rand () / (RAND_MAX + 1.0f);
cloud.points[i].z = 1024 * rand () / (RAND_MAX + 1.0f);
}
pcl::visualization::CloudViewer viewer ("Simple Cloud Viewer");
viewer.showCloud (cloud);
while (!viewer.wasStopped ())
{
}
return (0);
}
但即使这样也无法编译:
error: no matching function for call to
‘pcl::visualization::CloudViewer::showCloud(pcl::PointCloud<pcl::PointXYZ>&)’
您的错误消息告诉您需要做什么:
error: no matching function for call to ‘pcl::visualization::CloudViewer::showCloud(pcl::PointCloud<pcl::PointXYZ>&)’
因此,请转到 CloudViewer 的文档并查看该成员函数采用哪些参数:http://docs.pointclouds.org/1.5.1/classpcl_1_1visualization_1_1_cloud_viewer.html http://docs.pointclouds.org/1.5.1/classpcl_1_1visualization_1_1_cloud_viewer.html
在那里我们看到需要一个const MonochromeCloud::ConstPtr &cloud
不是您传入的原始引用。这是来自 boost 的智能指针的 typedef:
typedef boost::shared_ptr<const PointCloud<PointT> > pcl::PointCloud< PointT >::ConstPtr
因此,当您创建云时,您需要将其包装在这些智能指针之一中,而不是使其成为局部变量。像(未经测试)的东西:
pcl::MonochromeCloud::ConstPtr cloud(new pcl::PointCloud<pcl::PointXYZ>());
然后,当您传入变量 cloud 时,它将具有正确的类型,并且您不会收到报告的错误。您还必须更改您的cloud.foo
s to cloud->foo
s.
看着第二个例子 http://pointclouds.org/documentation/tutorials/cloud_viewer.php#cloud-viewer你给予,他们也会这样做:
pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZRGBA>);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)