这段代码是一个名为'Preprocessed::Main()'的函数,用于对输入的点云进行预处理。该函数使用PCL库中的功能对点云进行背景去除、土壤平面检测和半径滤波去噪。以下是函数的具体流程:

  1. 背景去除: 函数调用'background_remove'函数对输入点云进行背景去除,得到去除幕布后的点云'cloud_Remove_curtain'。
  2. 土壤平面检测: 函数调用'soil_plane_detect'函数对去除幕布后的点云进行土壤平面检测,得到植物点云'plant_cloud'。
  3. 半径滤波去噪: 函数调用'noise_removal'函数对植物点云进行半径滤波去噪,得到最终的预处理后的点云'cloud_after_preprocessed'。
  4. 时间统计: 函数使用'clock'函数计算预处理所花费的时间'preprocessed_times'并输出。

在函数中,定义了两个指向PointCloud类型的指针变量'cloud_Remove_curtain'和'plant_cloud',分别用于存储背景去除后的点云和土壤平面检测后的点云。

以下是代码示例:

void Preprocessed::Main()
{
	//Reading files
	cout << 'Loading ...................................' << endl;
	PointCloud<PointXYZRGB>::Ptr cloud_Remove_curtain(new PointCloud<PointXYZRGB>);//Point cloud after curtain removal
	PointCloud<PointXYZRGB>::Ptr plant_cloud(new PointCloud<PointXYZRGB>);//plant point cloud

	cout << 'Starting Filtering..............' << endl;
	cout << 'PointCloud before filtering has: ' << input_cloud->size() << ' data points. ' << endl;
	clock_t  start = clock();

	//1.background_remove
	PointXYZRGB minPt_br, maxPt_br;//找到最近最远的点;
	getMinMax3D(*input_cloud, minPt_br, maxPt_br); //Get the minimum and maximum values on each of the 3 (x-y-z) dimensions in a given pointcloud
	cloud_Remove_curtain = background_remove(input_cloud, minPt_br.z, 0.5*maxPt_br.z, 'z'); //输出min_pt为所有点中最小的x值,y值,z值,输出max_pt为为所有点中最大的x值,y值,z值。

	//2.Soil plane detection
	plant_cloud = soil_plane_detect(cloud_Remove_curtain);

	//3.Radius filtering removes noise
	cloud_after_preprocessed = noise_removal(plant_cloud);

	clock_t end = clock();
	float preprocessed_times = end - start;
	cout << 'Preprocessing spends: ' << preprocessed_times << ' ms' << endl;
}

该函数使用PCL库中的功能对输入点云进行预处理,为后续的点云处理提供了基础。

点云预处理函数Preprocessed::Main()详解

原文地址: https://www.cveoy.top/t/topic/ntR0 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录