25 #include <pcl/common/io.h>
41 const std::string& name,
42 pcl::PointCloud<PointL>::ConstPtr inputCloud,
46 ARMARX_CHECK(inputCloud) <<
"Passed input cloud must not be null (name: " << name <<
").";
50 inputLabeledClouds[name] = inputCloud;
55 pcl::PointCloud<PointT>::Ptr unlabeled(
new pcl::PointCloud<PointT>);
56 pcl::copyPointCloud(*inputCloud, *unlabeled);
62 const std::string& name,
63 pcl::PointCloud<PointL>::ConstPtr inputCloud,
64 visionx::PointContentType originalType)
70 const std::string& name, pcl::PointCloud<PointT>::ConstPtr inputCloud)
73 ARMARX_CHECK(inputCloud) <<
"Passed input cloud must not be null (name: " << name <<
").";
75 inputUnlabeledClouds[name] = inputCloud;
78 inputLabeledClouds.erase(name);
88 if (!inputUnlabeledClouds.empty())
91 labelUnlabeledClouds(getUsedLabels());
102 auto MergedLabeledPointCloud::getUsedLabels() const ->
std::
set<
Label>
105 std::set<Label> usedLabels;
106 for (
const auto& [name, cloud] : inputLabeledClouds)
108 for (
const auto& point : cloud->points)
110 usedLabels.insert(point.label);
117 void MergedLabeledPointCloud::labelUnlabeledClouds(
const std::set<Label>& usedLabels)
121 for (
const auto& [name, unlabeled] : inputUnlabeledClouds)
124 while (usedLabels.count(label) > 0)
130 pcl::PointCloud<PointL>::Ptr labeled(
new pcl::PointCloud<PointL>);
131 pcl::copyPointCloud(*unlabeled, *labeled);
132 for (
auto& point : labeled->points)
138 inputLabeledClouds[name] = labeled;
141 inputUnlabeledClouds.clear();
145 void MergedLabeledPointCloud::mergeLabeledClouds()
148 resultCloud->clear();
149 uint64_t timestamp = 0;
150 for (
const auto& [name, cloud] : inputLabeledClouds)
155 (*resultCloud) += *cloud;
157 timestamp =
std::max(timestamp, cloud->header.stamp);
159 resultCloud->header.stamp = timestamp;