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



Page generated by Doxygen 1.8.8 for MRPT 1.2.2 SVN:Unversioned directory at Tue Oct 14 02:14:08 UTC 2014