shapes_from_aabbs.cpp
Go to the documentation of this file.
1 #include "shapes_from_aabbs.h"
2 
3 #include <SemanticObjectRelations/Shapes.h>
4 #include <SemanticObjectRelations/ShapeExtraction/util/SoftMinMax.h>
5 
7 
8 
9 using namespace semrel;
10 using namespace armarx;
11 
12 
13 namespace
14 {
15  template <class PointT>
16  ShapeList getShapesFromAABBs(const pcl::PointCloud<PointT>& pointCloud)
17  {
18  const std::map<uint32_t, pcl::PointIndices> segmentIndices = visionx::tools::getSegmentIndices(pointCloud, false);
19  const std::map<uint32_t, AxisAlignedBoundingBox> aabbs = semantic::getAABBs(pointCloud, segmentIndices);
20  return semantic::getShapesFromAABBs(aabbs);
21  }
22 }
23 
24 
25 ShapeList semantic::getShapesFromAABBs(const pcl::PointCloud<pcl::PointXYZL>& pointCloud)
26 {
27  return ::getShapesFromAABBs<pcl::PointXYZL>(pointCloud);
28 }
29 
30 ShapeList semantic::getShapesFromAABBs(const pcl::PointCloud<pcl::PointXYZRGBL>& pointCloud)
31 {
32  return ::getShapesFromAABBs<pcl::PointXYZRGBL>(pointCloud);
33 }
34 
35 ShapeList semantic::getShapesFromAABBs(const std::map<uint32_t, AxisAlignedBoundingBox>& segmentAABBs)
36 {
37  semrel::ShapeList shapes;
38  shapes.reserve(segmentAABBs.size());
39  for (const auto& [label, aabb] : segmentAABBs)
40  {
41  shapes.emplace_back(new semrel::Box(aabb, semrel::ShapeID(label)));
42  }
43  return shapes;
44 }
45 
46 namespace
47 {
48  template <class PointT>
49  ShapeList getShapesFromSoftAABBs(const pcl::PointCloud<PointT>& pointCloud, float outlierRatio)
50  {
51  const std::map<uint32_t, pcl::PointIndices> segmentIndices = visionx::tools::getSegmentIndices(pointCloud, false);
52 
53  std::map<uint32_t, AxisAlignedBoundingBox> segmentAABBs;
54  for (const auto& [label, indices] : segmentIndices)
55  {
56  segmentAABBs[label] = semantic::getSoftAABB(pointCloud, indices, outlierRatio);
57  }
58 
59  return semantic::getShapesFromAABBs(segmentAABBs);
60  }
61 }
62 
63 ShapeList semantic::getShapesFromSoftAABBs(const pcl::PointCloud<pcl::PointXYZL>& pointCloud, float outlierRatio)
64 {
65  return ::getShapesFromSoftAABBs(pointCloud, outlierRatio);
66 }
67 
68 ShapeList semantic::getShapesFromSoftAABBs(const pcl::PointCloud<pcl::PointXYZRGBL>& pointCloud, float outlierRatio)
69 {
70  return ::getShapesFromSoftAABBs(pointCloud, outlierRatio);
71 }
72 
73 
74 void armarx::semantic::detail::checkLessEqual(float a, float b, const std::string& msg)
75 {
76  ARMARX_CHECK_LESS_EQUAL(a, b) << msg;
77 }
armarx::semantic::getShapesFromSoftAABBs
semrel::ShapeList getShapesFromSoftAABBs(const pcl::PointCloud< pcl::PointXYZL > &pointCloud, float outlierRatio)
Return the AABBs of each point cloud segment in a pointCloud.
Definition: shapes_from_aabbs.cpp:63
visionx::tools::getSegmentIndices
std::map< uint32_t, pcl::PointIndices > getSegmentIndices(const pcl::PointCloud< LabeledPointT > &labeledCloud, bool excludeZero=false)
Get a map from segment labels to indices of segments' points.
Definition: segments.h:74
shapes_from_aabbs.h
armarx::semantic::getShapesFromAABBs
semrel::ShapeList getShapesFromAABBs(const pcl::PointCloud< pcl::PointXYZL > &pointCloud)
Get the AABBs of each point cloud segment in pointCloud.
Definition: shapes_from_aabbs.cpp:25
armarx::semantic::getAABBs
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.
Definition: shapes_from_aabbs.h:91
armarx::ctrlutil::a
double a(double t, double a0, double j)
Definition: CtrlUtil.h:45
pcl::graph::indices
pcl::PointIndices::Ptr indices(const PCG &g)
Retrieve the indices of the points of the point cloud stored in a point cloud graph that actually bel...
Definition: point_cloud_graph.h:737
ARMARX_CHECK_LESS_EQUAL
#define ARMARX_CHECK_LESS_EQUAL(lhs, rhs)
This macro evaluates whether lhs is less or equal (<=) rhs and if it turns out to be false it will th...
Definition: ExpressionException.h:109
ExpressionException.h
armarx::semantic::detail::checkLessEqual
void checkLessEqual(float a, float b, const std::string &msg="")
Definition: shapes_from_aabbs.cpp:74
semrel
This file is part of ArmarX.
Definition: forward_declarations.h:25
armarx::semantic::getSoftAABB
semrel::AxisAlignedBoundingBox getSoftAABB(const pcl::PointCloud< PointT > &pointCloud, const pcl::PointIndices &segmentIndices, float outlierRatio)
Get the soft AABB of the given point cloud segment.
Definition: shapes_from_aabbs.h:106
shapes
MiscLib::Vector< std::pair< MiscLib::RefCountPtr< PrimitiveShape >, size_t > > shapes
Definition: ReadMe.txt:92
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28