,所以我有这样的代码中,我试图用点云库匹配一些描述我以前用其他的计算:C++中的点云库:没有匹配函数来调用到
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]);
}
}
}
但compilator(令)说:
/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());
是我写代码错了吗? 或者它是不知道实际函数定义应来自哪里的编译器?
感谢和问候!
工作代码 - PCL库的1.7版本:
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函数();'remove'()' - 编译器将它视为函数声明,而不是变量。 –
谢谢,我没有注意到的(),也可能尝试我想 更新后现在 –
更新,并与第二个问题的解释回答 –