std::vector<std::vector> planes;
std::vector<PointCloud::Ptr> pts_pipeishiyan; // 使用 PointCloud 类型来表示带有颜色信息的点云
pts_pipeishiyan.resize(planes.size());
for (int i = 0; i < planes.size(); i++)
{
for (int j = 0; j < planes[i].size(); j++)
{
PointXYZRGB point;
point.x = planes[i][j].x;
point.y = planes[i][j].y;
point.z = planes[i][j].z;
point.r = 255; // 红色
point.g = 0;
point.b = 0;
pts_pipeishiyan[i]->push_back(point);
}
}
注意,我们使用 PointCloud::Ptr 类型来表示带有颜色信息的点云,而不是 Point_set 类型。此外,我们在插入点云时,为每个点设置了红色 (R = 255, G = 0, B = 0)。