6 #include <pcl/PointIndices.h>
7 #include <pcl/point_cloud.h>
9 #include <SimoxUtility/shapes/AxisAlignedBoundingBox.h>
11 #include <VisionX/interface/core/DataTypes.h>
18 void addSegmentIndex(std::map<uint32_t, pcl::PointIndices>& segmentIndices,
22 void addSegmentIndex(std::map<uint32_t, pcl::PointIndices::Ptr>& segmentIndices,
26 template <
class LabeledPo
intT,
class MapValueT>
29 std::map<uint32_t, MapValueT>& segmentIndices,
30 bool excludeZero =
false)
32 for (std::size_t i = 0; i < labeledCloud.points.size(); i++)
34 const uint32_t currentLabel = labeledCloud.points[i].label;
35 if (!(excludeZero && currentLabel == 0))
53 template <
class LabeledPo
intT>
56 const pcl::PointCloud<LabeledPointT>& labeledCloud,
57 bool excludeZero =
false)
62 template <
class LabeledPo
intT>
65 const pcl::PointCloud<LabeledPointT>& labeledCloud,
66 bool excludeZero =
false)
77 template <
class LabeledPo
intT>
78 std::map<uint32_t, pcl::PointIndices>
79 getSegmentIndices(
const pcl::PointCloud<LabeledPointT>& labeledCloud,
bool excludeZero =
false)
81 std::map<uint32_t, pcl::PointIndices> segmentIndices;
83 return segmentIndices;
88 template <
class LabeledPo
intT>
89 std::map<uint32_t, pcl::PointIndices::Ptr>
91 bool excludeZero =
false)
93 std::map<uint32_t, pcl::PointIndices::Ptr> segmentIndices;
95 return segmentIndices;
99 template <
typename LabeledPo
intT>
103 std::set<uint32_t> labels;
104 for (
const auto& point : pointCloud)
106 labels.insert(point.label);
112 template <
class ValueT>
116 std::set<uint32_t> labels;
117 for (
const auto& [label, _] : segmentIndices)
119 labels.insert(label);
125 template <
class ValueT>
126 std::vector<uint32_t>
129 std::vector<uint32_t> labels;
130 labels.reserve(segmentIndices.size());
131 for (
const auto& [label, _] : segmentIndices)
133 labels.push_back(label);
138 template <
class Po
intT>
141 const std::map<uint32_t, pcl::PointIndices>& segmentIndices)
143 for (
const auto& [label,
indices] : segmentIndices)
147 pointCloud.at(
index).label = label;
152 template <
class Po
intT>
155 const std::map<uint32_t, pcl::PointIndices::Ptr>& segmentIndices)
157 for (
const auto& [label,
indices] : segmentIndices)
161 pointCloud.at(
index).label = label;
166 template <
class Po
intT,
class IndicesT = pcl::Po
intIndices>
167 std::vector<simox::AxisAlignedBoundingBox>
169 const std::vector<IndicesT>& segmentIndices)
171 std::vector<simox::AxisAlignedBoundingBox> aabbs;
172 aabbs.reserve(segmentIndices.size());
173 for (
const auto&
indices : segmentIndices)
180 template <
class Po
intT,
class IndicesT = pcl::Po
intIndices>
181 std::map<uint32_t, simox::AxisAlignedBoundingBox>
183 const std::map<uint32_t, IndicesT>& segmentIndices)
185 std::map<uint32_t, simox::AxisAlignedBoundingBox> aabbs;
186 for (
const auto& [label,
indices] : segmentIndices)