复制需要的点云索引
方法函数:pcl::copyPointCloud
使用示例
vector<int> redPointIndex;
pcl::PointCloud<pcl::PointXYZ>::Ptr redcloud(new pcl::PointCloud<pcl::PointXYZ>);
for (int i = 0; i < cloud->size(); i++)
{
int redNum = cloud->points[i].r;
if (redNum == 255) {
redPointIndex.push_back(i);
}
}
pcl::copyPointCloud(*cloud, redPoiredntIndex, *redcloud);
其中cloud表示原始点云
redPoiredntIndex 表示需要复制的索引
*redcloud表示存储cloud的index 部分
将普通点云转换为RGB点云
pcl::PointCloud<pcl::PointXYZ>::Ptr yuantu(new pcl::PointCloud<pcl::PointXYZ>);
//存的XYZRGB的格式的特征点
pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZRGB>);
//xyz转化为xyzrgba,可以看到原图是xyz的格式的,直接使用拷贝函数进行拷贝到xyzRGB,方便后面提取时候设置特征点和非特征点的颜色
pcl::copyPointCloud(*yuantu, *cloud);
其中yuntuan是读入的XYZ格式的点云
cloud 是将yuntuan 转换为rgb 格式的点云 方便后续处理