7#include <pcl/PointIndices.h>
8#include <pcl/point_cloud.h>
9#include <pcl/point_types.h>
11#include <SimoxUtility/math/SoftMinMax.h>
12#include <SimoxUtility/shapes/AxisAlignedBoundingBox.h>
16#include <SemanticObjectRelations/Shapes/AxisAlignedBoundingBox.h>
17#include <SemanticObjectRelations/Shapes/shape_containers.h>
23 semrel::ShapeList
getShapesFromAABBs(
const pcl::PointCloud<pcl::PointXYZL>& pointCloud);
25 semrel::ShapeList
getShapesFromAABBs(
const pcl::PointCloud<pcl::PointXYZRGBL>& pointCloud);
40 template <
class Po
intT,
class IndicesT = pcl::Po
intIndices>
41 semrel::AxisAlignedBoundingBox
getAABB(
const pcl::PointCloud<PointT>& pointCloud,
42 const IndicesT& segmentIndices);
48 template <
class Po
intT,
class IndicesT = pcl::Po
intIndices>
49 std::map<uint32_t, semrel::AxisAlignedBoundingBox>
50 getAABBs(
const pcl::PointCloud<PointT>& pointCloud,
51 const std::map<uint32_t, IndicesT>& segmentIndices);
58 template <
class Po
intT>
59 semrel::AxisAlignedBoundingBox
getSoftAABB(
const pcl::PointCloud<PointT>& pointCloud,
60 const pcl::PointIndices& segmentIndices,
67 template <
class Po
intT>
68 std::map<uint32_t, semrel::AxisAlignedBoundingBox>
70 const std::map<uint32_t, pcl::PointIndices>& segmentIndices,
78 void checkLessEqual(
float a,
float b,
const std::string& msg =
"");
81template <
class Po
intT,
class IndicesT>
82semrel::AxisAlignedBoundingBox
88template <
class Po
intT,
class IndicesT>
89std::map<uint32_t, semrel::AxisAlignedBoundingBox>
91 const std::map<uint32_t, IndicesT>& segmentIndices)
93 std::map<uint32_t, semrel::AxisAlignedBoundingBox> aabbs;
96 aabbs.emplace(label, semrel::AxisAlignedBoundingBox(aabb.limits()));
101template <
class Po
intT>
102semrel::AxisAlignedBoundingBox
104 const pcl::PointIndices& indices,
110 simox::math::SoftMinMax minMaxX(outlierRatio, indices.indices.size());
111 simox::math::SoftMinMax minMaxY(outlierRatio, indices.indices.size());
112 simox::math::SoftMinMax minMaxZ(outlierRatio, indices.indices.size());
114 for (
int index : indices.indices)
116 const PointT& point = pointCloud[
static_cast<std::size_t
>(
index)];
118 minMaxX.add(point.x);
119 minMaxY.add(point.y);
120 minMaxZ.add(point.z);
123 semrel::AxisAlignedBoundingBox aabb;
124 aabb.minX() = minMaxX.getSoftMin();
125 aabb.maxX() = minMaxX.getSoftMax();
126 aabb.minY() = minMaxY.getSoftMin();
127 aabb.maxY() = minMaxY.getSoftMax();
128 aabb.minZ() = minMaxZ.getSoftMin();
129 aabb.maxZ() = minMaxZ.getSoftMax();
134template <
class Po
intT>
135std::map<uint32_t, semrel::AxisAlignedBoundingBox>
137 const std::map<uint32_t, pcl::PointIndices>& segmentIndices,
140 std::map<uint32_t, semrel::AxisAlignedBoundingBox> segmentAABBs;
141 for (
const auto& [label, indices] : segmentIndices)
143 segmentAABBs[label] =
getSoftAABB(pointCloud, indices, outlierRatio);
void checkLessEqual(float a, float b, const std::string &msg="")
semrel::ShapeList getShapesFromSoftAABBs(const pcl::PointCloud< pcl::PointXYZL > &pointCloud, float outlierRatio)
Return the AABBs of each point cloud segment in a pointCloud.
std::map< uint32_t, semrel::AxisAlignedBoundingBox > getSoftAABBs(const pcl::PointCloud< PointT > &pointCloud, const std::map< uint32_t, pcl::PointIndices > &segmentIndices, float outlierRatio)
Get the soft AABBs of each point cloud segment.
semrel::ShapeList getShapesFromAABBs(const pcl::PointCloud< pcl::PointXYZL > &pointCloud)
Get the AABBs of each point cloud segment in pointCloud.
semrel::AxisAlignedBoundingBox getAABB(const pcl::PointCloud< PointT > &pointCloud, const IndicesT &segmentIndices)
Get the AABB of the given point cloud segment.
std::map< uint32_t, semrel::AxisAlignedBoundingBox > getAABBs(const pcl::PointCloud< PointT > &pointCloud, const std::map< uint32_t, IndicesT > &segmentIndices)
Get the AABB of each point cloud segment.
semrel::AxisAlignedBoundingBox getSoftAABB(const pcl::PointCloud< PointT > &pointCloud, const pcl::PointIndices &segmentIndices, float outlierRatio)
Get the soft AABB of the given point cloud segment.