数据类型
std::vector<pcl::PointCloud<pcl::PointXYZ>::Ptr> hulls_k_upper
std::vector<pcl::PointCloud<pcl::PointXYZ>::Ptr> hulls_k_lower
std::vector<pcl::PointCloud<pcl::PointXYZ>::Ptr> hulls_underk_upper
std::vector<pcl::PointCloud<pcl::PointXYZ>::Ptr> hulls_underk_lower
// 创建一个 PCLVisualizer 对象
pcl::visualization::PCLVisualizer viewer("Convex Hull Visualization");int hull_id = 0;
// 为 hulls_k_upper 中的每个凸包添加多边形
for (const auto& hull : hulls_k_upper) {std::string poly_id = "hull_k_upper" + std::to_string(hull_id);viewer.addPolygon<pcl::PointXYZ>(hull, 255, 0, 0, poly_id); // 红色viewer.setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_LINE_WIDTH, 2, poly_id);hull_id++;
}// 为 hulls_k_lower 中的每个凸包添加多边形
for (const auto& hull : hulls_k_lower) {std::string poly_id = "hull_k_lower" + std::to_string(hull_id);viewer.addPolygon<pcl::PointXYZ>(hull, 0, 255, 0, poly_id); // 绿色viewer.setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_LINE_WIDTH, 2, poly_id);hull_id++;
}// 为 hulls_underk_upper 中的每个凸包添加多边形
for (const auto& hull : hulls_underk_upper) {std::string poly_id = "hull_underk_upper" + std::to_string(hull_id);viewer.addPolygon<pcl::PointXYZ>(hull, 0, 0, 255, poly_id); // 蓝色viewer.setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_LINE_WIDTH, 2, poly_id);hull_id++;
}// 为 hulls_underk_lower 中的每个凸包添加多边形
for (const auto& hull : hulls_underk_lower) {std::string poly_id = "hull_underk_lower" + std::to_string(hull_id);viewer.addPolygon<pcl::PointXYZ>(hull, 255, 255, 0, poly_id); // 黄色viewer.setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_LINE_WIDTH, 2, poly_id);hull_id++;
}// 设置视窗的背景颜色
viewer.setBackgroundColor(0, 0, 0);// 循环直到视窗关闭
while (!viewer.wasStopped()) {viewer.spinOnce();
}
