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
mrpt::pbmap::Plane::curvature
float curvature
Definition: Plane.h:146
mrpt::pbmap::Plane::compute2DPolygonalArea
float compute2DPolygonalArea()
Compute the area of a 2D planar polygon patch - using a given normal.
Definition: Plane.cpp:249
mrpt::pbmap::Plane::hasSimilarDominantColor
bool hasSimilarDominantColor(Plane &plane, const float colorThreshold)
Definition: Plane.cpp:1068
mrpt::pbmap::Plane::mergePlane2
void mergePlane2(Plane &plane)
Definition: Plane.cpp:1135
mrpt::pbmap::Plane::getPlaneNrgb
void getPlaneNrgb()
Definition: Plane.cpp:349
mrpt::pbmap::Plane::calcMainColor
void calcMainColor()
Definition: Plane.cpp:603
mrpt::pbmap::Plane::label_object
std::string label_object
Definition: Plane.h:135
mrpt::pbmap::Plane::dominantIntensity
float dominantIntensity
Definition: Plane.h:160
mrpt::pbmap::Plane::hist_H
std::vector< float > hist_H
Definition: Plane.h:165
mrpt::pbmap::Plane::bFromStructure
bool bFromStructure
Definition: Plane.h:153
mrpt::pbmap::Plane::areaVoxels
float areaVoxels
Definition: Plane.h:150
mrpt::pbmap::Plane::nFramesAreaIsStable
unsigned nFramesAreaIsStable
Definition: Plane.h:154
mrpt::pbmap::Plane::prog_hist_H
std::vector< std::vector< float > > prog_hist_H
Definition: Plane.h:175
DEFAULT_VECTOR
static std::vector< size_t > DEFAULT_VECTOR
Definition: Plane.h:32
mrpt::pbmap::Plane::intensity
std::vector< float > intensity
Definition: Plane.h:203
mrpt::pbmap::Plane::b
std::vector< float > b
Definition: Plane.h:202
mrpt::pbmap::Plane::bFullExtent
bool bFullExtent
Definition: Plane.h:152
mrpt::pbmap::Plane::bDominantColor
bool bDominantColor
Definition: Plane.h:161
mrpt::pbmap::Plane::Plane
Plane()
Definition: Plane.h:51
mrpt::pbmap::Plane::v3colorNrgb
Eigen::Vector3f v3colorNrgb
! Radiometric description
Definition: Plane.h:159
mrpt::pbmap::Plane::calcPlaneHistH
void calcPlaneHistH()
Definition: Plane.cpp:406
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::pbmap::Plane::forcePtsLayOnPlane
void forcePtsLayOnPlane()
Definition: Plane.cpp:220
mrpt::pbmap::Plane::inliers
std::vector< int32_t > inliers
! Convex Hull
Definition: Plane.h:181
mrpt::pbmap::Plane::areaHull
float areaHull
Definition: Plane.h:151
mrpt::pbmap::Plane::computeMassCenterAndArea
void computeMassCenterAndArea()
Compute the patch's convex-hull area and mass center.
Definition: Plane.cpp:285
mrpt::pbmap::Plane::calcConvexHullandParams
void calcConvexHullandParams(pcl::PointCloud< pcl::PointXYZRGBA >::Ptr &pointCloud, std::vector< size_t > &indices=DEFAULT_VECTOR)
Definition: Plane.cpp:829
mrpt::pbmap::Plane::numObservations
unsigned numObservations
Definition: Plane.h:128
mrpt::pbmap::Plane::prog_area
std::vector< double > prog_area
Definition: Plane.h:168
mrpt::pbmap::Plane::v3center
Eigen::Vector3f v3center
! Geometric description
Definition: Plane.h:141
mrpt::pbmap::Plane::outerPolygonPtr
pcl::PointCloud< pcl::PointXYZRGBA >::Ptr outerPolygonPtr
Definition: Plane.h:184
mrpt::pbmap::Plane::isPlaneNearby
bool isPlaneNearby(Plane &plane, const float distThreshold)
Definition: Plane.cpp:960
mrpt::pbmap::Plane::g
std::vector< float > g
Definition: Plane.h:201
mrpt::pbmap::Plane::elongation
float elongation
Definition: Plane.h:148
mrpt::pbmap::Plane
A class used to store a planar feature (Plane for short).
Definition: Plane.h:46
mrpt::serialization::CSerializable
The virtual base class which provides a unified interface for all persistent objects in MRPT.
Definition: CSerializable.h:32
mrpt::pbmap::Plane::prog_Nrgb
std::vector< Eigen::Vector3f > prog_Nrgb
Definition: Plane.h:173
mrpt::pbmap::Plane::polygonContourPtr
pcl::PointCloud< pcl::PointXYZRGBA >::Ptr polygonContourPtr
Definition: Plane.h:182
mrpt::pbmap::Plane::prog_C1C2C3
std::vector< Eigen::Vector3f > prog_C1C2C3
Definition: Plane.h:172
mrpt::pbmap::Plane::r
std::vector< float > r
Definition: Plane.h:200
mrpt::pbmap::Plane::d
float d
Definition: Plane.h:143
mrpt::pbmap::Plane::semanticGroup
unsigned semanticGroup
Definition: Plane.h:129
mrpt::pbmap::Plane::calcMainColor2
void calcMainColor2()
Definition: Plane.cpp:532
mrpt::pbmap::Plane::planePointCloudPtr
pcl::PointCloud< pcl::PointXYZRGBA >::Ptr planePointCloudPtr
Definition: Plane.h:186
mrpt::pbmap::Plane::prog_intensity
std::vector< float > prog_intensity
Definition: Plane.h:174
mrpt::pbmap::Plane::calcConvexHull
void calcConvexHull(pcl::PointCloud< pcl::PointXYZRGBA >::Ptr &pointCloud, std::vector< size_t > &indices=DEFAULT_VECTOR)
! Calculate the plane's convex hull with the monotone chain algorithm.
Definition: Plane.cpp:761
mrpt::pbmap::Plane::v3normal
Eigen::Vector3f v3normal
Definition: Plane.h:142
mrpt::pbmap::Plane::label_context
std::string label_context
Definition: Plane.h:136
mrpt::pbmap::Plane::prog_elongation
std::vector< double > prog_elongation
Definition: Plane.h:169
DEFINE_SERIALIZABLE
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
Definition: CSerializable.h:102
mrpt::pbmap::Plane::c2
std::vector< float > c2
Definition: Plane.h:210
mrpt::pbmap::Plane::mergePlane
void mergePlane(Plane &plane)
Definition: Plane.cpp:1082
mrpt::pbmap::Plane::c3
std::vector< float > c3
Definition: Plane.h:211
mrpt::pbmap::Plane::neighborPlanes
std::map< unsigned, unsigned > neighborPlanes
Definition: Plane.h:131
mrpt::pbmap::Plane::id
unsigned id
! Parameters to allow the plane-based representation of the map by a graph
Definition: Plane.h:127
mrpt::pbmap::Plane::v3PpalDir
Eigen::Vector3f v3PpalDir
Definition: Plane.h:147
mrpt::pbmap::Plane::information
Eigen::Matrix4f information
Definition: Plane.h:144
mrpt::pbmap::Plane::isSamePlane
bool isSamePlane(Plane &plane, const float &cosAngleThreshold, const float &distThreshold, const float &proxThreshold)
Definition: Plane.cpp:1011
string
GLsizei const GLchar ** string
Definition: glext.h:4101
mrpt::pbmap::Plane::c1
std::vector< float > c1
Definition: Plane.h:209
mrpt::pbmap::Plane::getPlaneC1C2C3
void getPlaneC1C2C3()
Definition: Plane.cpp:380
CSerializable.h
mrpt::pbmap::Plane::transform
void transform(Eigen::Matrix4f &Rt)
Definition: Plane.cpp:1179
mrpt::pbmap::Plane::v3colorC1C2C3
Eigen::Vector3f v3colorC1C2C3
Definition: Plane.h:164
indices
GLuint GLuint GLsizei GLenum const GLvoid * indices
Definition: glext.h:3529
mrpt::pbmap::Plane::label
std::string label
Definition: Plane.h:134
mrpt::pbmap::Plane::v3colorNrgbDev
Eigen::Vector3f v3colorNrgbDev
Definition: Plane.h:162
mrpt::pbmap::Plane::nearbyPlanes
std::set< unsigned > nearbyPlanes
Definition: Plane.h:130
mrpt::pbmap::Plane::calcElongationAndPpalDir
void calcElongationAndPpalDir()
Definition: Plane.cpp:331



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST