PointCloud 库中的 C++:没有要调用的匹配函数

C++ in PointCloud library: No matching function to call to

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

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

这有点奇怪,因为在 class 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<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:: 智能指针)。

NULL 替换为 nullptr(或 boost::shared_ptr<const std::vector<int> >()),编译器将能够从该值构造 boost::shared_ptr