选取点组成点云

这段代码展示了如何根据特征点对点云进行分割,并按每10%的比例保存为不同编号的PCD文件。首先处理'featurebox[n]'中的点,然后是'curIndexGrad[i]',最后处理全局变量V的点。每个点云对应一个特定的范围,用于后续可能的数据分析或可视化。
摘要由CSDN通过智能技术生成
if (i == 0)
			{
				pcl::PointCloud<pcl::PointXYZ> cloud1;
				cloud1.width = featurebox[n].size(); //设置点云宽度
				cloud1.height = 1; //设置点云高度
				cloud1.is_dense = false; //非密集型
				cloud1.points.resize(cloud1.width * cloud1.height); //变形,无序
				for (size_t j = 0; j < featurebox[n].size() * (i + 1) * 0.1; j++)//computer the grad's Ex 0.1 point
				{
					int p0 = get<1>(featurebox[n][j]);
					cloud1.points[j].x = cloud->points[p0].x;
					cloud1.points[j].y = cloud->points[p0].y;
					cloud1.points[j].z = cloud->points[p0].z;
				}
				//保存到PCD文件

				pcl::io::savePCDFileASCII("test00.pcd", cloud1); //将点云保存到PCD文件中
			}
			if (i == 1)
			{
				pcl::PointCloud<pcl::PointXYZ> cloud1;
				cloud1.width = curIndexGrad[i].size(); //设置点云宽度
				cloud1.height = 1; //设置点云高度
				cloud1.is_dense = false; //非密集型
				cloud1.points.resize(cloud1.width * cloud1.height); //变形,无序
				for (size_t j = 0; j < featurebox[n].size() * (i + 1) * 0.1; j++)//computer the grad's Ex 0.1 point
				{
					int p0 = get<1>(featurebox[n][j]);
					cloud1.points[j].x = cloud->points[p0].x;
					cloud1.points[j].y = cloud->points[p0].y;
					cloud1.points[j].z = cloud->points[p0].z;
				}
				//保存到PCD文件

				pcl::io::savePCDFileASCII("test11.pcd", cloud1); //将点云保存到PCD文件中
			}
			if (i == 2)
			{
				pcl::PointCloud<pcl::PointXYZ> cloud1;
				cloud1.width = curIndexGrad[i].size(); //设置点云宽度
				cloud1.height = 1; //设置点云高度
				cloud1.is_dense = false; //非密集型
				cloud1.points.resize(cloud1.width * cloud1.height); //变形,无序
				for (size_t j = 0; j < featurebox[n].size() * (i + 1) * 0.1; j++)//computer the grad's Ex 0.1 point
				{
					int p0 = get<1>(featurebox[n][j]);
					cloud1.points[j].x = cloud->points[p0].x;
					cloud1.points[j].y = cloud->points[p0].y;
					cloud1.points[j].z = cloud->points[p0].z;
				}
				//保存到PCD文件

				pcl::io::savePCDFileASCII("test22.pcd", cloud1); //将点云保存到PCD文件中
			}
			if (i == 3)
			{
				pcl::PointCloud<pcl::PointXYZ> cloud1;
				cloud1.width = curIndexGrad[i].size(); //设置点云宽度
				cloud1.height = 1; //设置点云高度
				cloud1.is_dense = false; //非密集型
				cloud1.points.resize(cloud1.width * cloud1.height); //变形,无序
				for (size_t j = 0; j < featurebox[n].size() * (i + 1) * 0.1; j++)//computer the grad's Ex 0.1 point
				{
					int p0 = get<1>(featurebox[n][j]);
					cloud1.points[j].x = cloud->points[p0].x;
					cloud1.points[j].y = cloud->points[p0].y;
					cloud1.points[j].z = cloud->points[p0].z;
				}
				//保存到PCD文件

				pcl::io::savePCDFileASCII("test33.pcd", cloud1); //将点云保存到PCD文件中
			}
			if (i == 4)
			{
				pcl::PointCloud<pcl::PointXYZ> cloud1;
				cloud1.width = curIndexGrad[i].size(); //设置点云宽度
				cloud1.height = 1; //设置点云高度
				cloud1.is_dense = false; //非密集型
				cloud1.points.resize(cloud1.width * cloud1.height); //变形,无序
				for (size_t j = 0; j < featurebox[n].size() * (i + 1) * 0.1; j++)//computer the grad's Ex 0.1 point
				{
					int p0 = get<1>(featurebox[n][j]);
					cloud1.points[j].x = cloud->points[p0].x;
					cloud1.points[j].y = cloud->points[p0].y;
					cloud1.points[j].z = cloud->points[p0].z;
				}
				//保存到PCD文件

				pcl::io::savePCDFileASCII("test44.pcd", cloud1); //将点云保存到PCD文件中
			}
			if (i == 5)
			{
				pcl::PointCloud<pcl::PointXYZ> cloud1;
				cloud1.width = curIndexGrad[i].size(); //设置点云宽度
				cloud1.height = 1; //设置点云高度
				cloud1.is_dense = false; //非密集型
				cloud1.points.resize(cloud1.width * cloud1.height); //变形,无序
				for (size_t j = 0; j < featurebox[n].size() * (i + 1) * 0.1; j++)//computer the grad's Ex 0.1 point
				{
					int p0 = get<1>(featurebox[n][j]);
					cloud1.points[j].x = cloud->points[p0].x;
					cloud1.points[j].y = cloud->points[p0].y;
					cloud1.points[j].z = cloud->points[p0].z;
				}
				//保存到PCD文件

				pcl::io::savePCDFileASCII("test55.pcd", cloud1); //将点云保存到PCD文件中
			}
			if (i == 6)
			{
				pcl::PointCloud<pcl::PointXYZ> cloud1;
				cloud1.width = curIndexGrad[i].size(); //设置点云宽度
				cloud1.height = 1; //设置点云高度
				cloud1.is_dense = false; //非密集型
				cloud1.points.resize(cloud1.width * cloud1.height); //变形,无序
				for (size_t j = 0; j < featurebox[n].size() * (i + 1) * 0.1; j++)//computer the grad's Ex 0.1 point
				{
					int p0 = get<1>(featurebox[n][j]);
					cloud1.points[j].x = cloud->points[p0].x;
					cloud1.points[j].y = cloud->points[p0].y;
					cloud1.points[j].z = cloud->points[p0].z;
				}
				//保存到PCD文件

				pcl::io::savePCDFileASCII("test66.pcd", cloud1); //将点云保存到PCD文件中
			}
			if (i == 7)
			{
				pcl::PointCloud<pcl::PointXYZ> cloud1;
				cloud1.width = curIndexGrad[i].size(); //设置点云宽度
				cloud1.height = 1; //设置点云高度
				cloud1.is_dense = false; //非密集型
				cloud1.points.resize(cloud1.width * cloud1.height); //变形,无序
				for (size_t j = 0; j < featurebox[n].size() * (i + 1) * 0.1; j++)//computer the grad's Ex 0.1 point
				{
					int p0 = get<1>(featurebox[n][j]);
					cloud1.points[j].x = cloud->points[p0].x;
					cloud1.points[j].y = cloud->points[p0].y;
					cloud1.points[j].z = cloud->points[p0].z;
				}
				//保存到PCD文件

				pcl::io::savePCDFileASCII("test77.pcd", cloud1); //将点云保存到PCD文件中
			}
			if (i == 8)
			{
				pcl::PointCloud<pcl::PointXYZ> cloud1;
				cloud1.width = curIndexGrad[i].size(); //设置点云宽度
				cloud1.height = 1; //设置点云高度
				cloud1.is_dense = false; //非密集型
				cloud1.points.resize(cloud1.width * cloud1.height); //变形,无序
				for (size_t j = 0; j < featurebox[n].size() * (i + 1) * 0.1; j++)//computer the grad's Ex 0.1 point
				{
					int p0 = get<1>(featurebox[n][j]);
					cloud1.points[j].x = cloud->points[p0].x;
					cloud1.points[j].y = cloud->points[p0].y;
					cloud1.points[j].z = cloud->points[p0].z;
				}
				//保存到PCD文件

				pcl::io::savePCDFileASCII("test88.pcd", cloud1); //将点云保存到PCD文件中
			}
			if (i == 9)
			{
				pcl::PointCloud<pcl::PointXYZ> cloud1;
				cloud1.width = curIndexGrad[i].size(); //设置点云宽度
				cloud1.height = 1; //设置点云高度
				cloud1.is_dense = false; //非密集型
				cloud1.points.resize(cloud1.width * cloud1.height); //变形,无序
				for (size_t j = 0; j < featurebox[n].size() * (i + 1) * 0.1; j++)//computer the grad's Ex 0.1 point
				{
					int p0 = get<1>(featurebox[n][j]);
					cloud1.points[j].x = cloud->points[p0].x;
					cloud1.points[j].y = cloud->points[p0].y;
					cloud1.points[j].z = cloud->points[p0].z;
				}
				//保存到PCD文件

				pcl::io::savePCDFileASCII("test99.pcd", cloud1); //将点云保存到PCD文件中
			}
		if (i == 1)
		{
			pcl::PointCloud<pcl::PointXYZ> cloud1;
			cloud1.width = V.size(); //设置点云宽度
			cloud1.height = 1; //设置点云高度
			cloud1.is_dense = false; //非密集型
			cloud1.points.resize(cloud1.width * cloud1.height); //变形,无序
			for (size_t j = 0; j < V.size(); j++)//computer the grad's Ex 0.1 point
			{
				int p0 = V[j];
				cloud1.points[j].x = cloud->points[p0].x;
				cloud1.points[j].y = cloud->points[p0].y;
				cloud1.points[j].z = cloud->points[p0].z;
			}
			//保存到PCD文件

			pcl::io::savePCDFileASCII("test11.pcd", cloud1); //将点云保存到PCD文件中
		}
		if (i == 2)
		{
			pcl::PointCloud<pcl::PointXYZ> cloud1;
			cloud1.width = V.size(); //设置点云宽度
			cloud1.height = 1; //设置点云高度
			cloud1.is_dense = false; //非密集型
			cloud1.points.resize(cloud1.width * cloud1.height); //变形,无序
			for (size_t j = 0; j < V.size(); j++)//computer the grad's Ex 0.1 point
			{
				int p0 = V[j];
				cloud1.points[j].x = cloud->points[p0].x;
				cloud1.points[j].y = cloud->points[p0].y;
				cloud1.points[j].z = cloud->points[p0].z;
			}
			//保存到PCD文件

			pcl::io::savePCDFileASCII("test22.pcd", cloud1); //将点云保存到PCD文件中
		}
		if (i == 3)
		{
			pcl::PointCloud<pcl::PointXYZ> cloud1;
			cloud1.width = V.size(); //设置点云宽度
			cloud1.height = 1; //设置点云高度
			cloud1.is_dense = false; //非密集型
			cloud1.points.resize(cloud1.width* cloud1.height); //变形,无序
			for (size_t j = 0; j < V.size(); j++)//computer the grad's Ex 0.1 point
			{
				int p0 = V[j];
				cloud1.points[j].x = cloud->points[p0].x;
				cloud1.points[j].y = cloud->points[p0].y;
				cloud1.points[j].z = cloud->points[p0].z;
			}
			//保存到PCD文件

			pcl::io::savePCDFileASCII("test33.pcd", cloud1); //将点云保存到PCD文件中
		}
		if (i == 4)
		{
			pcl::PointCloud<pcl::PointXYZ> cloud1;
			cloud1.width = V.size(); //设置点云宽度
			cloud1.height = 1; //设置点云高度
			cloud1.is_dense = false; //非密集型
			cloud1.points.resize(cloud1.width* cloud1.height); //变形,无序
			for (size_t j = 0; j < V.size(); j++)//computer the grad's Ex 0.1 point
			{
				int p0 = V[j];
				cloud1.points[j].x = cloud->points[p0].x;
				cloud1.points[j].y = cloud->points[p0].y;
				cloud1.points[j].z = cloud->points[p0].z;
			}
			//保存到PCD文件

			pcl::io::savePCDFileASCII("test44.pcd", cloud1); //将点云保存到PCD文件中
		}
		if (i == 5)
		{
			pcl::PointCloud<pcl::PointXYZ> cloud1;
			cloud1.width = V.size(); //设置点云宽度
			cloud1.height = 1; //设置点云高度
			cloud1.is_dense = false; //非密集型
			cloud1.points.resize(cloud1.width* cloud1.height); //变形,无序
			for (size_t j = 0; j < V.size(); j++)//computer the grad's Ex 0.1 point
			{
				int p0 = V[j];
				cloud1.points[j].x = cloud->points[p0].x;
				cloud1.points[j].y = cloud->points[p0].y;
				cloud1.points[j].z = cloud->points[p0].z;
			}
			//保存到PCD文件

			pcl::io::savePCDFileASCII("test55.pcd", cloud1); //将点云保存到PCD文件中
		}
		if (i == 6)
		{
			pcl::PointCloud<pcl::PointXYZ> cloud1;
			cloud1.width = V.size(); //设置点云宽度
			cloud1.height = 1; //设置点云高度
			cloud1.is_dense = false; //非密集型
			cloud1.points.resize(cloud1.width* cloud1.height); //变形,无序
			for (size_t j = 0; j < V.size(); j++)//computer the grad's Ex 0.1 point
			{
				int p0 = V[j];
				cloud1.points[j].x = cloud->points[p0].x;
				cloud1.points[j].y = cloud->points[p0].y;
				cloud1.points[j].z = cloud->points[p0].z;
			}
			//保存到PCD文件

			pcl::io::savePCDFileASCII("test66.pcd", cloud1); //将点云保存到PCD文件中
		}
		if (i == 7)
		{
			pcl::PointCloud<pcl::PointXYZ> cloud1;
			cloud1.width = V.size(); //设置点云宽度
			cloud1.height = 1; //设置点云高度
			cloud1.is_dense = false; //非密集型
			cloud1.points.resize(cloud1.width* cloud1.height); //变形,无序
			for (size_t j = 0; j < V.size(); j++)//computer the grad's Ex 0.1 point
			{
				int p0 = V[j];
				cloud1.points[j].x = cloud->points[p0].x;
				cloud1.points[j].y = cloud->points[p0].y;
				cloud1.points[j].z = cloud->points[p0].z;
			}
			//保存到PCD文件

			pcl::io::savePCDFileASCII("test77.pcd", cloud1); //将点云保存到PCD文件中
		}
		if (i == 8)
		{
			pcl::PointCloud<pcl::PointXYZ> cloud1;
			cloud1.width = V.size(); //设置点云宽度
			cloud1.height = 1; //设置点云高度
			cloud1.is_dense = false; //非密集型
			cloud1.points.resize(cloud1.width* cloud1.height); //变形,无序
			for (size_t j = 0; j < V.size(); j++)//computer the grad's Ex 0.1 point
			{
				int p0 = V[j];
				cloud1.points[j].x = cloud->points[p0].x;
				cloud1.points[j].y = cloud->points[p0].y;
				cloud1.points[j].z = cloud->points[p0].z;
			}
			//保存到PCD文件

			pcl::io::savePCDFileASCII("test88.pcd", cloud1); //将点云保存到PCD文件中
		}
		if (i == 9)
		{
			pcl::PointCloud<pcl::PointXYZ> cloud1;
			cloud1.width = V.size(); //设置点云宽度
			cloud1.height = 1; //设置点云高度
			cloud1.is_dense = false; //非密集型
			cloud1.points.resize(cloud1.width* cloud1.height); //变形,无序
			for (size_t j = 0; j < V.size(); j++)//computer the grad's Ex 0.1 point
			{
				int p0 = V[j];
				cloud1.points[j].x = cloud->points[p0].x;
				cloud1.points[j].y = cloud->points[p0].y;
				cloud1.points[j].z = cloud->points[p0].z;
			}
			//保存到PCD文件

			pcl::io::savePCDFileASCII("test99.pcd", cloud1); //将点云保存到PCD文件中
		}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值