点云随笔(一)单个格网滤波

单个格网滤波主要跟格网滤波原理基本一致,主要是将格网滤波的八邻域坡度平均值作为中心格网坡度替换为了基于当前检索格网最低点与其他检索点计算坡度。


//int grid_size{ 5 };
//pcl::PCDReader reader;
//pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZRGB>),
//cloud2(new pcl::PointCloud<pcl::PointXYZRGB>), cloud3(new pcl::PointCloud<pcl::PointXYZRGB>);
//reader.read("D:\\c++\\dumb_ridge.pcd", *cloud);
//std::cout << "The cloud size is: " << cloud->points.size() << " data points." << std::endl;
//pcl::PointXYZRGB minPt, maxPt;
//pcl::getMinMax3D(*cloud, minPt, maxPt);
//
//int row = ((maxPt.y - minPt.y + 4 * grid_size) / grid_size);
//int col = ((maxPt.x - minPt.x + 4 * grid_size) / grid_size);
//int grid_count = { row * col };
//
//multimap<int, int>hashmap;
//for (int i = 0; i < cloud->size(); i++)
//{
//	int row_number = int((cloud->points[i].y - minPt.y) / grid_size) + 1;
//	int col_number = int((cloud->points[i].x - minPt.x) / grid_size) + 1;
//	int rank = (row_number - 1) * col + col_number;
//	hashmap.insert(make_pair(rank, i));
//}
//pcl::PointCloud<pcl::PointXYZRGB>::Ptr non_ground(new pcl::PointCloud<pcl::PointXYZRGB>), ground(new pcl::PointCloud<pcl::PointXYZRGB>);
//int non{ 0 }, yes{ 0 };
//for (int i = 0; i < grid_count; i++)
//{
//	pcl::PointCloud<pcl::PointXYZRGB>::Ptr grid_cloud(new pcl::PointCloud<pcl::PointXYZRGB>);
//	int k{ 0 };
//	multimap<int, int>::iterator m;
//	m = hashmap.find(i);
//	for (k = 0; k != hashmap.count(i); k++, m++)
//	{
//		grid_cloud->push_back(cloud->points[m->second]);
//	}
//	if (grid_cloud->size() > 0) {
//
//		pcl::PointXYZRGB grid_min, grid_max;
//		pcl::getMinMax3D(*grid_cloud, grid_min, grid_max);
//		for (int c = 0; c < grid_cloud->size(); c++) {
//			double slope = (grid_cloud->points[c].z - grid_min.z) /
//				sqrt(pow((grid_cloud->points[c].x - grid_min.x), 2)) + pow((grid_cloud->points[c].y - grid_min.y), 2);
//			if (slope < 1) {
//				ground->push_back(grid_cloud->points[c]);
//				yes += 1;
//			}
//			else {
//				non_ground->push_back(grid_cloud->points[c]);
//				non += 1;
//			}
//		}
//	}
//	else
//	{
//		continue;
//	}
//}
//cout << "地面点有: " << ground->size() << endl;
//cout << "非地面点有: " << non_ground->size() << endl;
//ground->width = yes;
//ground->height = 1;
//ground->points.resize(ground->width * ground->height);
//pcl::io::savePCDFileASCII("D:\\c++\\ground.pcd", *ground);
//
//non_ground->width = non;
//non_ground->height = 1;
//non_ground->points.resize(non_ground->width * non_ground->height);
//pcl::io::savePCDFileASCII("D:\\c++\\non_ground.pcd", *non_ground);

  • 4
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值