码迷,mamicode.com
首页 > 其他好文 > 详细

点云密度计算

时间:2016-05-19 16:31:29      阅读:3575      评论:0      收藏:0      [点我收藏+]

标签:

1.计算点云最近点的平均距离(点云的平均距离)http://pointclouds.org/documentation/tutorials/correspondence_grouping.php

 1 double computeCloudResolution (const pcl::PointCloud<PointType>::ConstPtr &cloud)
 2 {
 3   double res = 0.0;
 4   int n_points = 0;
 5   int nres;
 6   std::vector<int> indices (2);
 7   std::vector<float> sqr_distances (2);
 8   pcl::search::KdTree<PointType> tree;
 9   tree.setInputCloud (cloud);
10 
11   for (size_t i = 0; i < cloud->size (); ++i)
12   {
13     if (! pcl_isfinite ((*cloud)[i].x))
14     {
15       continue;
16     }
17     //Considering the second neighbor since the first is the point itself.
18     nres = tree.nearestKSearch (i, 2, indices, sqr_distances);
19     if (nres == 2)
20     {
21       res += sqrt (sqr_distances[1]);
22       ++n_points;
23     }
24   }
25   if (n_points != 0)
26   {
27     res /= n_points;
28   }
29   return res;
30 }

 

点云密度计算

标签:

原文地址:http://www.cnblogs.com/yhlx125/p/5509041.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!