gpt4 book ai didi

PointCloud 库中的 C++ : No matching function to call to

转载 作者:行者123 更新时间:2023-11-28 05:06:31 26 4
gpt4 key购买 nike

所以我有这段代码,我在其中尝试使用点云库来匹配我之前计算的一些描述符和其他描述符:

pcl::KdTreeFLANN<pcl::Narf36> matching = new pcl::KdTreeFLANN<pcl::Narf36>(false);
pcl::KdTree<pcl::Narf36>::PointCloudConstPtr ptr_narf_descriptors(&narf_descriptors);
matching.setInputCloud(ptr_narf_descriptors,NULL);

std::vector<int> correspondence;

// Check every descriptor computed for the scene.
for (size_t i = 0; i < narf_descriptors2.size(); ++i)
{
std::vector<int> neighbors(1);
std::vector<float> squaredDistances(1);
// Ignore NaNs.
if (pcl_isfinite(narf_descriptors2.at(i).descriptor[0]))
{
// Find the nearest neighbor (in descriptor space)...
int neighborCount = matching.nearestKSearch(narf_descriptors2.at(i), 1, neighbors, squaredDistances);
// ...and add a new correspondence if the distance is less than a threshold
// (SHOT distances are between 0 and 1, other descriptors use different metrics).
if (neighborCount == 1 && squaredDistances[0] < 0.25f)
{
//correspondence.push_back(neighbors[0], static_cast<int>(i), squaredDistances[0]);
correspondence.push_back(neighbors[0]);
}
}
}

但是编译器(make)说:

/home/adrian/PointCloudComparator/src/comparator.cpp: In function ‘void processNARF(std::string, std::string)’:
/home/adrian/PointCloudComparator/src/comparator.cpp:270:50: error: no
matching function for call to ‘pcl::KdTreeFLANN<pcl::Narf36>::setInputCloud(pcl::KdTree<pcl::Narf36>::PointCloudConstPtr&, NULL)’
matching.setInputCloud(ptr_narf_descriptors,NULL);
^
/home/adrian/PointCloudComparator/src/comparator.cpp:270:50: note: candidate is:
In file included from /usr/include/pcl-1.7/pcl/search/kdtree.h:44:0,
from /usr/include/pcl-1.7/pcl/search/pcl_search.h:44,
from /usr/include/pcl-1.7/pcl/features/impl/feature.hpp:44,
from /usr/include/pcl-1.7/pcl/features/feature.h:498,
from /usr/include/pcl-1.7/pcl/features/range_image_border_extractor.h:42,
from /home/adrian/PointCloudComparator/src/comparator.cpp:9:
/usr/include/pcl-1.7/pcl/kdtree/kdtree_flann.h:146:7: note:
void pcl::KdTreeFLANN<PointT, Dist>::setInputCloud(const PointCloudConstPtr&, const IndicesConstPtr&) [with PointT = pcl::Narf36; Dist = flann::L2_Simple<float>; pcl::KdTreeFLANN<PointT,
Dist>::PointCloudConstPtr = boost::shared_ptr<const
pcl::PointCloud<pcl::Narf36> >; pcl::KdTreeFLANN<PointT,
Dist>::IndicesConstPtr = boost::shared_ptr<const std::vector<int> >]
setInputCloud (const PointCloudConstPtr &cloud, const
IndicesConstPtr &indices = IndicesConstPtr ());
^
^
make[2]: *** [CMakeFiles/comparator.dir/src/comparator.cpp.o] Error 1
make[1]: *** [CMakeFiles/comparator.dir/all] Error 2
make: *** [all] Error 2

这有点奇怪,因为在类 kdtree_Flann 中函数的定义是:

 /** \brief Provide a pointer to the input dataset.
* \param[in] cloud the const boost shared pointer to a PointCloud message
* \param[in] indices the point indices subset that is to be used from \a cloud - if NULL the whole cloud is used
*/
void
setInputCloud (const PointCloudConstPtr &cloud, const IndicesConstPtr &indices = IndicesConstPtr ());

难道是我代码写错了吗?还是编译器不知道实际的函数定义应该从哪里来?

谢谢和问候!


工作代码 - 适用于 1.7 版 PCL 库:

pcl::KdTreeFLANN<pcl::Narf36> matching = new pcl::KdTreeFLANN<pcl::Narf36>(false);
pcl::KdTree<pcl::Narf36>::PointCloudConstPtr ptr_narf_descriptors(&narf_descriptors);
matching.setInputCloud(ptr_narf_descriptors);

std::vector<int> correspondence;

最佳答案

您声明了 std::vector<int> correspondence(); - 编译器将其视为函数前向声明。

如果你想定义变量 - 不用()定义它最后:

std::vector<int> correspondence;

第二个问题是你通过了NULL作为似乎属于 boost::shared_ptr 类型的参数. NULL是 C 风格的宏(参见 http://www.cplusplus.com/reference/cstddef/NULL/?kw=NULL )并且不可能构造 boost::shared_ptr (还有 std:: 智能指针)来自它。

替换NULLnullptr (或使用 boost::shared_ptr<const std::vector<int> >() )编译器将能够构造 boost::shared_ptr从那个值。

关于PointCloud 库中的 C++ : No matching function to call to,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44626139/

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