Main MRPT website > C++ reference for MRPT 1.9.9
Plane.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 /* Plane-based Map (PbMap) library
11  * Construction of plane-based maps and localization in it from RGBD Images.
12  * Writen by Eduardo Fernandez-Moral. See docs for <a
13  * href="group__mrpt__pbmap__grp.html" >mrpt-pbmap</a>
14  */
15 
16 #ifndef __PBMAP_PLANE_H
17 #define __PBMAP_PLANE_H
18 
19 #include <mrpt/config.h>
20 
21 #if MRPT_HAS_PCL
22 
23 #include <mrpt/utils/utils_defs.h>
24 
26 #include <pcl/point_types.h>
27 #include <pcl/common/pca.h>
28 #include <set>
29 #include <map>
30 
31 #define USE_COMPLETNESS_HEURISTICS 1
32 #define USE_INFERRED_STRUCTURE 1
33 
34 static std::vector<size_t> DEFAULT_VECTOR;
35 
36 namespace mrpt
37 {
38 namespace pbmap
39 {
40 /** A class used to store a planar feature (Plane for short).
41  * It is described with geometric features representing the shape and relative
42  * location of the patch (area, normal vector, elongation, 3D-convex hull,
43  * etc.)
44  * and radiometric features (the most representative color).
45  *
46  * \ingroup mrpt_pbmap_grp
47  */
49 {
51 
52  public:
54  : elongation(1.0),
55  bFullExtent(false),
56  bFromStructure(false),
57  // contourPtr(new pcl::PointCloud<pcl::PointXYZRGBA>),
58  polygonContourPtr(new pcl::PointCloud<pcl::PointXYZRGBA>),
59  planePointCloudPtr(new pcl::PointCloud<pcl::PointXYZRGBA>)
60  {
61  // vector< vector<int> > vec(4, vector<int>(4));
62  }
63 
64  /*!
65  * Force the plane inliers to lay on the plane
66  */
67  void forcePtsLayOnPlane();
68 
69  /**!
70  * Calculate the plane's convex hull with the monotone chain algorithm.
71  */
72  // void calcConvexHull(pcl::PointCloud<pcl::PointXYZRGBA>::Ptr
73  // &pointCloud );
74  void calcConvexHull(
75  pcl::PointCloud<pcl::PointXYZRGBA>::Ptr& pointCloud,
76  std::vector<size_t>& indices = DEFAULT_VECTOR);
77 
79  pcl::PointCloud<pcl::PointXYZRGBA>::Ptr& pointCloud,
80  std::vector<size_t>& indices = DEFAULT_VECTOR);
81 
82  /** \brief Compute the area of a 2D planar polygon patch - using a given
83 normal
84 // * \param polygonContourPtr the point cloud (planar)
85 // * \param normal the plane normal
86  */
88  /*pcl::PointCloud<pcl::PointXYZRGBA>::Ptr &polygonContourPtr, Vector<3> &normal*/);
89 
90  /** \brief Compute the patch's convex-hull area and mass center
91  */
93 
94  /*!
95  * Calculate plane's elongation and principal direction
96  */
98 
99  /*!Returns true when the closest distance between the patches "this" and
100  * "plane" is under distThreshold.*/
101  bool isPlaneNearby(Plane& plane, const float distThreshold);
102 
103  /*! Returns true if the two input planes represent the same physical surface
104  * for some given angle and distance thresholds.
105  * If the planes are the same they are merged in this and the function
106  * returns true. Otherwise it returns false.*/
107  bool isSamePlane(
108  Plane& plane, const float& cosAngleThreshold,
109  const float& distThreshold, const float& proxThreshold);
110 
111  bool isSamePlane(
112  Eigen::Matrix4f& Rt, Plane& plane_, const float& cosAngleThreshold,
113  const float& distThreshold, const float& proxThreshold);
114 
115  bool hasSimilarDominantColor(Plane& plane, const float colorThreshold);
116 
117  /*! Merge the two input patches into "updatePlane".
118  * Recalculate center, normal vector, area, inlier points (filtered),
119  * convex hull, etc.
120  */
121  void mergePlane(Plane& plane);
122  void mergePlane2(Plane& plane); // Adaptation for RGBD360
123 
124  void transform(Eigen::Matrix4f& Rt);
125 
126  /**!
127  * Parameters to allow the plane-based representation of the map by a graph
128  */
129  unsigned id;
130  unsigned numObservations;
131  unsigned semanticGroup;
132  std::set<unsigned> nearbyPlanes;
133  std::map<unsigned, unsigned> neighborPlanes;
134 
135  /*!Labels to store semantic attributes*/
139 
140  /**!
141  * Geometric description
142  */
143  Eigen::Vector3f v3center;
144  Eigen::Vector3f v3normal;
145  float d;
146  Eigen::Matrix4f information; // Fisher information matrix (the inverse of
147  // the plane covariance)
148  float curvature;
149  Eigen::Vector3f v3PpalDir;
150  float elongation; // This is the reatio between the lengths of the plane in
151  // the two principal directions
152  float areaVoxels;
153  float areaHull;
157 
158  /**!
159  * Radiometric description
160  */
161  Eigen::Vector3f v3colorNrgb;
164  Eigen::Vector3f v3colorNrgbDev;
165 
166  Eigen::Vector3f v3colorC1C2C3; // Color paper
167  std::vector<float> hist_H; // Normalized, Saturated Hue histogram
168  // (including 2 bins for black and white)
169 
170  std::vector<double> prog_area;
171  std::vector<double> prog_elongation; // This is the reatio between the
172  // lengths of the plane in the two
173  // principal directions
174  std::vector<Eigen::Vector3f> prog_C1C2C3;
175  std::vector<Eigen::Vector3f> prog_Nrgb;
176  std::vector<float> prog_intensity;
177  std::vector<std::vector<float>> prog_hist_H;
178 
179  /**!
180  * Convex Hull
181  */
182  // pcl::PointCloud<pcl::PointXYZRGBA>::Ptr contour::Ptr;
183  std::vector<int32_t> inliers;
184  pcl::PointCloud<pcl::PointXYZRGBA>::Ptr polygonContourPtr;
185  pcl::PointCloud<pcl::PointXYZRGBA>::Ptr
186  outerPolygonPtr; // This is going to be deprecated
187  pcl::PointCloud<pcl::PointXYZRGBA>::Ptr
188  planePointCloudPtr; // This is going to be deprecated
189 
190  /*!
191  * Calculate plane's main color using "MeanShift" method
192  */
193  void calcMainColor();
194  void calcMainColor2();
195  void calcPlaneHistH();
196 
197  private:
198  /*!
199  * Calculate plane's main color in normalized rgb space
200  */
201  void getPlaneNrgb();
202  std::vector<float> r;
203  std::vector<float> g;
204  std::vector<float> b;
205  std::vector<float> intensity;
206 
207  // Color paper
208  /*!
209  * Calculate plane's main color in C1C2C3 representation
210  */
211  std::vector<float> c1;
212  std::vector<float> c2;
213  std::vector<float> c3;
214  void getPlaneC1C2C3();
215 
216  /*!
217  * Calculate plane's main color in HSV representation
218  */
219  // vector<float> H;
220  // vector<float> S;
221  // vector<vector<float> > HSV;
222 };
223 }
224 } // End of namespaces
225 
226 #endif
227 
228 #endif
std::vector< float > c3
Definition: Plane.h:213
std::vector< double > prog_area
Definition: Plane.h:170
std::string label_context
Definition: Plane.h:138
std::vector< float > c2
Definition: Plane.h:212
std::vector< Eigen::Vector3f > prog_Nrgb
Definition: Plane.h:175
pcl::PointCloud< pcl::PointXYZRGBA >::Ptr polygonContourPtr
Definition: Plane.h:184
void transform(Eigen::Matrix4f &Rt)
Definition: Plane.cpp:1320
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:44
A class used to store a planar feature (Plane for short).
Definition: Plane.h:48
Eigen::Vector3f v3PpalDir
Definition: Plane.h:149
Eigen::Vector3f v3colorNrgbDev
Definition: Plane.h:164
float dominantIntensity
Definition: Plane.h:162
std::map< unsigned, unsigned > neighborPlanes
Definition: Plane.h:133
void mergePlane2(Plane &plane)
Definition: Plane.cpp:1276
float elongation
Definition: Plane.h:150
static std::vector< size_t > DEFAULT_VECTOR
Definition: Plane.h:34
GLuint GLuint GLsizei GLenum const GLvoid * indices
Definition: glext.h:3528
void mergePlane(Plane &plane)
Definition: Plane.cpp:1223
Eigen::Vector3f v3colorNrgb
! Radiometric description
Definition: Plane.h:161
void calcConvexHullandParams(pcl::PointCloud< pcl::PointXYZRGBA >::Ptr &pointCloud, std::vector< size_t > &indices=DEFAULT_VECTOR)
Definition: Plane.cpp:970
std::vector< float > g
Definition: Plane.h:203
void calcElongationAndPpalDir()
Definition: Plane.cpp:472
std::vector< Eigen::Vector3f > prog_C1C2C3
Definition: Plane.h:174
std::vector< float > prog_intensity
Definition: Plane.h:176
bool bFullExtent
Definition: Plane.h:154
float areaVoxels
Definition: Plane.h:152
void calcPlaneHistH()
Definition: Plane.cpp:547
Eigen::Vector3f v3normal
Definition: Plane.h:144
bool bFromStructure
Definition: Plane.h:155
std::set< unsigned > nearbyPlanes
Definition: Plane.h:132
pcl::PointCloud< pcl::PointXYZRGBA >::Ptr planePointCloudPtr
Definition: Plane.h:188
unsigned semanticGroup
Definition: Plane.h:131
std::vector< float > intensity
Definition: Plane.h:205
float areaHull
Definition: Plane.h:153
std::string label
Definition: Plane.h:136
void forcePtsLayOnPlane()
Definition: Plane.cpp:361
std::vector< double > prog_elongation
Definition: Plane.h:171
std::vector< float > c1
Definition: Plane.h:211
GLsizei const GLchar ** string
Definition: glext.h:4101
bool isSamePlane(Plane &plane, const float &cosAngleThreshold, const float &distThreshold, const float &proxThreshold)
Definition: Plane.cpp:1152
bool isPlaneNearby(Plane &plane, const float distThreshold)
Definition: Plane.cpp:1101
std::string label_object
Definition: Plane.h:137
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
void getPlaneC1C2C3()
Definition: Plane.cpp:521
void calcMainColor()
Definition: Plane.cpp:744
float compute2DPolygonalArea()
Compute the area of a 2D planar polygon patch - using a given normal.
Definition: Plane.cpp:390
std::vector< std::vector< float > > prog_hist_H
Definition: Plane.h:177
pcl::PointCloud< pcl::PointXYZRGBA >::Ptr outerPolygonPtr
Definition: Plane.h:186
std::vector< float > b
Definition: Plane.h:204
unsigned id
! Parameters to allow the plane-based representation of the map by a graph
Definition: Plane.h:129
void computeMassCenterAndArea()
Compute the patch&#39;s convex-hull area and mass center.
Definition: Plane.cpp:426
std::vector< int32_t > inliers
! Convex Hull
Definition: Plane.h:183
std::vector< float > hist_H
Definition: Plane.h:167
Eigen::Vector3f v3center
! Geometric description
Definition: Plane.h:143
std::vector< float > r
Definition: Plane.h:202
void calcMainColor2()
Definition: Plane.cpp:673
unsigned numObservations
Definition: Plane.h:130
void getPlaneNrgb()
Definition: Plane.cpp:490
Eigen::Matrix4f information
Definition: Plane.h:146
float curvature
Definition: Plane.h:148
bool bDominantColor
Definition: Plane.h:163
unsigned nFramesAreaIsStable
Definition: Plane.h:156
bool hasSimilarDominantColor(Plane &plane, const float colorThreshold)
Definition: Plane.cpp:1209
Eigen::Vector3f v3colorC1C2C3
Definition: Plane.h:166
void calcConvexHull(pcl::PointCloud< pcl::PointXYZRGBA >::Ptr &pointCloud, std::vector< size_t > &indices=DEFAULT_VECTOR)
! Calculate the plane&#39;s convex hull with the monotone chain algorithm.
Definition: Plane.cpp:902



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019