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



Page generated by Doxygen 1.8.14 for MRPT 1.5.9 Git: 690a4699f Wed Apr 15 19:29:53 2020 +0200 at miƩ abr 15 19:30:12 CEST 2020