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-2018, 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 
24 #include <pcl/point_types.h>
25 #include <pcl/common/pca.h>
26 #include <set>
27 #include <map>
28 
29 #define USE_COMPLETNESS_HEURISTICS 1
30 #define USE_INFERRED_STRUCTURE 1
31 
32 static std::vector<size_t> DEFAULT_VECTOR;
33 
34 namespace mrpt
35 {
36 namespace pbmap
37 {
38 /** A class used to store a planar feature (Plane for short).
39  * It is described with geometric features representing the shape and relative
40  * location of the patch (area, normal vector, elongation, 3D-convex hull,
41  * etc.)
42  * and radiometric features (the most representative color).
43  *
44  * \ingroup mrpt_pbmap_grp
45  */
47 {
49 
50  public:
52  : elongation(1.0),
53  bFullExtent(false),
54  bFromStructure(false),
55  // contourPtr(new pcl::PointCloud<pcl::PointXYZRGBA>),
56  polygonContourPtr(new pcl::PointCloud<pcl::PointXYZRGBA>),
57  planePointCloudPtr(new pcl::PointCloud<pcl::PointXYZRGBA>)
58  {
59  // vector< vector<int> > vec(4, vector<int>(4));
60  }
61 
62  /*!
63  * Force the plane inliers to lay on the plane
64  */
65  void forcePtsLayOnPlane();
66 
67  /**!
68  * Calculate the plane's convex hull with the monotone chain algorithm.
69  */
70  // void calcConvexHull(pcl::PointCloud<pcl::PointXYZRGBA>::Ptr
71  // &pointCloud );
72  void calcConvexHull(
73  pcl::PointCloud<pcl::PointXYZRGBA>::Ptr& pointCloud,
74  std::vector<size_t>& indices = DEFAULT_VECTOR);
75 
77  pcl::PointCloud<pcl::PointXYZRGBA>::Ptr& pointCloud,
78  std::vector<size_t>& indices = DEFAULT_VECTOR);
79 
80  /** \brief Compute the area of a 2D planar polygon patch - using a given
81 normal
82 // * \param polygonContourPtr the point cloud (planar)
83 // * \param normal the plane normal
84  */
86  /*pcl::PointCloud<pcl::PointXYZRGBA>::Ptr &polygonContourPtr, Vector<3> &normal*/);
87 
88  /** \brief Compute the patch's convex-hull area and mass center
89  */
91 
92  /*!
93  * Calculate plane's elongation and principal direction
94  */
96 
97  /*!Returns true when the closest distance between the patches "this" and
98  * "plane" is under distThreshold.*/
99  bool isPlaneNearby(Plane& plane, const float distThreshold);
100 
101  /*! Returns true if the two input planes represent the same physical surface
102  * for some given angle and distance thresholds.
103  * If the planes are the same they are merged in this and the function
104  * returns true. Otherwise it returns false.*/
105  bool isSamePlane(
106  Plane& plane, const float& cosAngleThreshold,
107  const float& distThreshold, const float& proxThreshold);
108 
109  bool isSamePlane(
110  Eigen::Matrix4f& Rt, Plane& plane_, const float& cosAngleThreshold,
111  const float& distThreshold, const float& proxThreshold);
112 
113  bool hasSimilarDominantColor(Plane& plane, const float colorThreshold);
114 
115  /*! Merge the two input patches into "updatePlane".
116  * Recalculate center, normal vector, area, inlier points (filtered),
117  * convex hull, etc.
118  */
119  void mergePlane(Plane& plane);
120  void mergePlane2(Plane& plane); // Adaptation for RGBD360
121 
122  void transform(Eigen::Matrix4f& Rt);
123 
124  /**!
125  * Parameters to allow the plane-based representation of the map by a graph
126  */
127  unsigned id;
128  unsigned numObservations;
129  unsigned semanticGroup;
130  std::set<unsigned> nearbyPlanes;
131  std::map<unsigned, unsigned> neighborPlanes;
132 
133  /*!Labels to store semantic attributes*/
137 
138  /**!
139  * Geometric description
140  */
141  Eigen::Vector3f v3center;
142  Eigen::Vector3f v3normal;
143  float d;
144  Eigen::Matrix4f information; // Fisher information matrix (the inverse of
145  // the plane covariance)
146  float curvature;
147  Eigen::Vector3f v3PpalDir;
148  float elongation; // This is the reatio between the lengths of the plane in
149  // the two principal directions
150  float areaVoxels;
151  float areaHull;
155 
156  /**!
157  * Radiometric description
158  */
159  Eigen::Vector3f v3colorNrgb;
162  Eigen::Vector3f v3colorNrgbDev;
163 
164  Eigen::Vector3f v3colorC1C2C3; // Color paper
165  std::vector<float> hist_H; // Normalized, Saturated Hue histogram
166  // (including 2 bins for black and white)
167 
168  std::vector<double> prog_area;
169  std::vector<double> prog_elongation; // This is the reatio between the
170  // lengths of the plane in the two
171  // principal directions
172  std::vector<Eigen::Vector3f> prog_C1C2C3;
173  std::vector<Eigen::Vector3f> prog_Nrgb;
174  std::vector<float> prog_intensity;
175  std::vector<std::vector<float>> prog_hist_H;
176 
177  /**!
178  * Convex Hull
179  */
180  // pcl::PointCloud<pcl::PointXYZRGBA>::Ptr contour::Ptr;
181  std::vector<int32_t> inliers;
182  pcl::PointCloud<pcl::PointXYZRGBA>::Ptr polygonContourPtr;
183  pcl::PointCloud<pcl::PointXYZRGBA>::Ptr
184  outerPolygonPtr; // This is going to be deprecated
185  pcl::PointCloud<pcl::PointXYZRGBA>::Ptr
186  planePointCloudPtr; // This is going to be deprecated
187 
188  /*!
189  * Calculate plane's main color using "MeanShift" method
190  */
191  void calcMainColor();
192  void calcMainColor2();
193  void calcPlaneHistH();
194 
195  private:
196  /*!
197  * Calculate plane's main color in normalized rgb space
198  */
199  void getPlaneNrgb();
200  std::vector<float> r;
201  std::vector<float> g;
202  std::vector<float> b;
203  std::vector<float> intensity;
204 
205  // Color paper
206  /*!
207  * Calculate plane's main color in C1C2C3 representation
208  */
209  std::vector<float> c1;
210  std::vector<float> c2;
211  std::vector<float> c3;
212  void getPlaneC1C2C3();
213 
214  /*!
215  * Calculate plane's main color in HSV representation
216  */
217  // vector<float> H;
218  // vector<float> S;
219  // vector<vector<float> > HSV;
220 };
221 }
222 } // End of namespaces
223 
224 #endif
225 
226 #endif
std::vector< float > c3
Definition: Plane.h:211
std::vector< double > prog_area
Definition: Plane.h:168
std::string label_context
Definition: Plane.h:136
std::vector< float > c2
Definition: Plane.h:210
std::vector< Eigen::Vector3f > prog_Nrgb
Definition: Plane.h:173
pcl::PointCloud< pcl::PointXYZRGBA >::Ptr polygonContourPtr
Definition: Plane.h:182
void transform(Eigen::Matrix4f &Rt)
Definition: Plane.cpp:1179
A class used to store a planar feature (Plane for short).
Definition: Plane.h:46
Eigen::Vector3f v3PpalDir
Definition: Plane.h:147
Eigen::Vector3f v3colorNrgbDev
Definition: Plane.h:162
float dominantIntensity
Definition: Plane.h:160
std::map< unsigned, unsigned > neighborPlanes
Definition: Plane.h:131
void mergePlane2(Plane &plane)
Definition: Plane.cpp:1135
float elongation
Definition: Plane.h:148
static std::vector< size_t > DEFAULT_VECTOR
Definition: Plane.h:32
GLuint GLuint GLsizei GLenum const GLvoid * indices
Definition: glext.h:3528
void mergePlane(Plane &plane)
Definition: Plane.cpp:1082
Eigen::Vector3f v3colorNrgb
! Radiometric description
Definition: Plane.h:159
void calcConvexHullandParams(pcl::PointCloud< pcl::PointXYZRGBA >::Ptr &pointCloud, std::vector< size_t > &indices=DEFAULT_VECTOR)
Definition: Plane.cpp:829
std::vector< float > g
Definition: Plane.h:201
void calcElongationAndPpalDir()
Definition: Plane.cpp:331
std::vector< Eigen::Vector3f > prog_C1C2C3
Definition: Plane.h:172
std::vector< float > prog_intensity
Definition: Plane.h:174
bool bFullExtent
Definition: Plane.h:152
float areaVoxels
Definition: Plane.h:150
void calcPlaneHistH()
Definition: Plane.cpp:406
Eigen::Vector3f v3normal
Definition: Plane.h:142
bool bFromStructure
Definition: Plane.h:153
std::set< unsigned > nearbyPlanes
Definition: Plane.h:130
pcl::PointCloud< pcl::PointXYZRGBA >::Ptr planePointCloudPtr
Definition: Plane.h:186
unsigned semanticGroup
Definition: Plane.h:129
std::vector< float > intensity
Definition: Plane.h:203
float areaHull
Definition: Plane.h:151
std::string label
Definition: Plane.h:134
void forcePtsLayOnPlane()
Definition: Plane.cpp:220
std::vector< double > prog_elongation
Definition: Plane.h:169
std::vector< float > c1
Definition: Plane.h:209
GLsizei const GLchar ** string
Definition: glext.h:4101
bool isSamePlane(Plane &plane, const float &cosAngleThreshold, const float &distThreshold, const float &proxThreshold)
Definition: Plane.cpp:1011
bool isPlaneNearby(Plane &plane, const float distThreshold)
Definition: Plane.cpp:960
std::string label_object
Definition: Plane.h:135
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:380
void calcMainColor()
Definition: Plane.cpp:603
float compute2DPolygonalArea()
Compute the area of a 2D planar polygon patch - using a given normal.
Definition: Plane.cpp:249
std::vector< std::vector< float > > prog_hist_H
Definition: Plane.h:175
pcl::PointCloud< pcl::PointXYZRGBA >::Ptr outerPolygonPtr
Definition: Plane.h:184
std::vector< float > b
Definition: Plane.h:202
unsigned id
! Parameters to allow the plane-based representation of the map by a graph
Definition: Plane.h:127
void computeMassCenterAndArea()
Compute the patch&#39;s convex-hull area and mass center.
Definition: Plane.cpp:285
std::vector< int32_t > inliers
! Convex Hull
Definition: Plane.h:181
std::vector< float > hist_H
Definition: Plane.h:165
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:32
Eigen::Vector3f v3center
! Geometric description
Definition: Plane.h:141
std::vector< float > r
Definition: Plane.h:200
void calcMainColor2()
Definition: Plane.cpp:532
unsigned numObservations
Definition: Plane.h:128
void getPlaneNrgb()
Definition: Plane.cpp:349
Eigen::Matrix4f information
Definition: Plane.h:144
float curvature
Definition: Plane.h:146
bool bDominantColor
Definition: Plane.h:161
unsigned nFramesAreaIsStable
Definition: Plane.h:154
bool hasSimilarDominantColor(Plane &plane, const float colorThreshold)
Definition: Plane.cpp:1068
Eigen::Vector3f v3colorC1C2C3
Definition: Plane.h:164
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:761



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at lun oct 28 00:14:14 CET 2019