• pcl之kdtree的使用


    pcl之kdtree的使用

    A k-d tree, or k-dimensional tree, is a data structure used in computer science for organizing some number of points in a space with k dimensions. It is a binary search tree with other constraints imposed on it. K-d trees are very useful for range and nearest neighbor searches.

    #include <pcl/point_cloud.h>
    #include <pcl/kdtree/kdtree_flann.h>
    
    #include <iostream>
    #include <vector>
    
    int main(int argc, char** argv)
    {
      pcl::PointCloud<pcl::PointXYZI>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZI>);
      ....
      pcl::KdTreeFLANN<pcl::PointXYZI> kdtree;
      kdtree.setIputCloud(cloud);
      pcl::PointXYZI search_point;
      ....
      // k nearest neighbor search
      int k = 10;
      std::vector<int> k_indices(k);
      std::vector<float> k_sqr_distances(k;)
      if (kdtree.nearestKSearch(search_point, k, k_indices, k_sqr_distances) > 0)
      {
        //do something
      }
      
      // neighbors within radius search
      float radius = 1.0;
      std::vector<int> 
      std::vector<float>
      if (kdtree.radiusSearch(search_point, radius, radius_indices, radius_sqr_distance) > 0)
      {
        //do something
      }
    
    }
    

    值得注意的是: 返回的是square_distance

    参考

    http://pointclouds.org/documentation/tutorials/kdtree_search.php

  • 相关阅读:
    用SQL语言操作数据
    用表组织数据
    第一个C#程序
    利用CSS3制作网页动画
    CSS3美化网页元素
    列表、表格与媒体元素
    表单
    HTML5基础
    使用Java编译思想
    Day06:方法 / 猜字母游戏
  • 原文地址:https://www.cnblogs.com/ChrisCoder/p/9937597.html
Copyright © 2020-2023  润新知