29 #include <type_traits>
31 #include <pcl/point_types.h>
32 #include <pcl/point_cloud.h>
33 #include <pcl/common/io.h>
34 #include <pcl/io/pcd_io.h>
36 #include <pcl/common/colors.h>
38 #include <VisionX/interface/core/DataTypes.h>
47 template <
typename Po
intCloudPtrT>
50 const uint8_t r = rand() % 255;
51 const uint8_t g = rand() % 255;
52 const uint8_t b = rand() % 255;
54 for (
auto& p : segment->points)
61 return std::make_tuple(r, g, b);
66 pcl::PointCloud<pcl::PointXYZRGBA>::Ptr targetCloudPtr)
68 pcl::copyPointCloud(*sourceCloudPtr, *targetCloudPtr);
70 std::map<uint32_t, float> colorMap;
72 for (
size_t i = 0; i < sourceCloudPtr->points.size(); i++)
74 pcl::PointXYZL p = sourceCloudPtr->points[i];
76 if (!colorMap.count(p.label))
78 pcl::RGB
c = pcl::GlasbeyLUT::at(p.label % pcl::GlasbeyLUT::size());
79 colorMap.insert(std::make_pair(p.label,
c.rgb));
82 targetCloudPtr->points[i].rgb = colorMap[p.label];
95 template <
class Po
intCloudT>
96 void fillLabelMap(
const PointCloudT& labeledCloud, std::map<uint32_t, pcl::PointIndices>& labelIndicesMap,
bool excludeZero)
98 for (
size_t i = 0; i < labeledCloud.points.size(); i++)
100 uint32_t currentLabel = labeledCloud.points[i].label;
102 if (excludeZero && currentLabel == 0)
110 labelIndicesMap[currentLabel].indices.push_back(
static_cast<int>(i));
122 template <
class LabeledPo
intCloudPtrT>
125 std::map<uint32_t, pcl::PointIndices>& labelIndicesMap,
126 bool excludeZero =
true)
133 template <
class Po
intCloudT>
136 std::map<uint32_t, pcl::PointIndices>& labelIndicesMap,
137 bool excludeZero =
true)
143 template <
class Po
intCloudT>
145 const PointCloudT& labeledCloud,
bool excludeZero =
true)
147 std::map<uint32_t, pcl::PointIndices> labelIndicesMap;
149 return labelIndicesMap;