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