35 #ifndef CColouredPointsMap_H 36 #define CColouredPointsMap_H 51 class CObservation3DRangeScan;
70 virtual ~CColouredPointsMap();
84 virtual void reserve(
size_t newLength);
90 virtual void resize(
size_t newLength);
99 virtual void setPointFast(
size_t index,
float x,
float y,
float z)
107 virtual void insertPointFast(
float x,
float y,
float z = 0 );
111 virtual void copyFrom(
const CPointsMap &obj);
118 point_data.resize(6);
119 point_data[0] = x[index];
120 point_data[1] = y[index];
121 point_data[2] = z[index];
122 point_data[3] = m_color_R[index];
123 point_data[4] = m_color_G[index];
124 point_data[5] = m_color_B[index];
131 virtual void setPointAllFieldsFast(
const size_t index,
const std::vector<float> & point_data ) {
133 x[index] = point_data[0];
134 y[index] = point_data[1];
135 z[index] = point_data[2];
136 m_color_R[index] = point_data[3];
137 m_color_G[index] = point_data[4];
138 m_color_B[index] = point_data[5];
142 virtual void loadFromRangeScan(
143 const CObservation2DRangeScan &rangeScan,
144 const CPose3D *robotPose = NULL );
147 virtual void loadFromRangeScan(
148 const CObservation3DRangeScan &rangeScan,
149 const CPose3D *robotPose = NULL );
154 virtual void addFrom_classSpecific(
const CPointsMap &anotherMap,
const size_t nPreviousPoints);
170 bool save3D_and_colour_to_text_file(
const std::string &file)
const;
175 virtual void setPoint(
size_t index,
float x,
float y,
float z,
float R,
float G,
float B);
179 inline void setPoint(
size_t index,
float x,
float y,
float z) {
181 setPointFast(index,x,y,z);
185 inline
void setPoint(
size_t index,CPoint2D &p) { setPoint(index,p.x(),p.y(),0); }
193 virtual void insertPoint(
float x,
float y,
float z,
float R,
float G,
float B );
196 inline void insertPoint(
const CPoint3D &p ) { insertPoint(p.x(),p.y(),p.z()); }
200 inline void insertPoint(
float x,
float y,
float z) { insertPointFast(x,y,z); mark_as_modified(); }
205 void setPointColor(
size_t index,
float R,
float G,
float B);
210 this->m_color_R[index]=R;
211 this->m_color_G[index]=G;
212 this->m_color_B[index]=B;
217 virtual void getPoint(
size_t index,
float &x,
float &y,
float &z,
float &R,
float &G,
float &B )
const;
220 unsigned long getPoint(
size_t index,
float &x,
float &y,
float &z)
const;
223 void getPointColor(
size_t index,
float &R,
float &G,
float &B )
const;
228 R = m_color_R[index];
229 G = m_color_G[index];
230 B = m_color_B[index];
243 bool colourFromObservation(
const CObservationImage &obs,
const CPose3D &robotPose );
250 enum TColouringMethod
252 cmFromHeightRelativeToSensor = 0,
253 cmFromHeightRelativeToSensorJet = 0,
254 cmFromHeightRelativeToSensorGray = 1,
255 cmFromIntensityImage = 2
266 void loadFromConfigFile(
268 const std::string §ion);
281 void resetPointsMinDist(
float defValue = 2000.0f );
287 virtual bool savePCDFile(
const std::string &filename,
bool save_as_binary)
const;
299 template <
class POINTCLOUD>
302 const size_t N = cloud.points.size();
305 const float f = 1.0f/255.0f;
306 for (
size_t i=0;i<N;++i)
307 this->insertPoint(cloud.points[i].x,cloud.points[i].y,cloud.points[i].z,cloud.points[i].r*f,cloud.points[i].g*f,cloud.points[i].b*f);
315 std::vector<float> m_color_R,m_color_G,m_color_B;
322 virtual void internal_clear();
332 virtual void PLY_import_set_vertex_count(
const size_t N);
340 virtual void PLY_export_get_vertex(
362 static const int HAS_RGB = 1;
363 static const int HAS_RGBf = 1;
364 static const int HAS_RGBu8 = 0;
369 inline size_t size()
const {
return m_obj.
size(); }
374 template <
typename T>
375 inline void getPointXYZ(
const size_t idx, T &x,T &y, T &z)
const {
384 template <
typename T>
385 inline void getPointXYZ_RGBf(
const size_t idx, T &x,T &y, T &z,
float &r,
float &g,
float &b)
const {
389 inline void setPointXYZ_RGBf(
const size_t idx,
const coords_t x,
const coords_t y,
const coords_t z,
const float r,
const float g,
const float b) {
394 template <
typename T>
395 inline void getPointXYZ_RGBu8(
const size_t idx, T &x,T &y, T &z, uint8_t &r,uint8_t &g,uint8_t &b)
const {
398 r=Rf*255; g=Gf*255; b=Bf*255;
402 m_obj.
setPoint(idx,x,y,z,r/255.f,g/255.f,b/255.f);
411 inline void getPointRGBu8(
const size_t idx, uint8_t &r,uint8_t &g,uint8_t &b)
const {
414 r=R*255; g=G*255; b=B*255;
417 inline void setPointRGBu8(
const size_t idx,
const uint8_t r,
const uint8_t g,
const uint8_t b) {
void setPointRGBf(const size_t idx, const float r, const float g, const float b)
Set XYZ_RGBf coordinates of i'th point.
double x() const
Common members of all points & poses classes.
size_t size() const
Returns the number of stored points in the map.
void setFromPCLPointCloudRGB(const POINTCLOUD &cloud)
Loads a PCL point cloud (WITH RGB information) into this MRPT class (for clouds without RGB data...
void insertPoint(const mrpt::math::TPoint3D &p)
The definition of parameters for generating colors from laser scans.
void getPointXYZ_RGBu8(const size_t idx, T &x, T &y, T &z, uint8_t &r, uint8_t &g, uint8_t &b) const
Get XYZ_RGBu8 coordinates of i'th point.
virtual void getPointAllFieldsFast(const size_t index, std::vector< float > &point_data) const
Get all the data fields for one point as a vector: [X Y Z R G B] Unlike getPointAllFields(), this method does not check for index out of bounds.
void setPoint(size_t index, float x, float y, float z)
float coords_t
The type of each point XYZ coordinates.
void getPointColor_fast(size_t index, float &R, float &G, float &B) const
Like getPointColor but without checking for out-of-index erors.
void getPointRGBu8(const size_t idx, uint8_t &r, uint8_t &g, uint8_t &b) const
Get RGBu8 color of i'th point.
void setPoint(size_t index, CPoint3D &p)
void getPointXYZ_RGBf(const size_t idx, T &x, T &y, T &z, float &r, float &g, float &b) const
Get XYZ_RGBf coordinates of i'th point.
PointCloudAdapter(const mrpt::slam::CColouredPointsMap &obj)
Constructor (accept a const ref for convenience)
A map of 2D/3D points with individual colours (RGB).
size_t size(const MATRIXLIKE &m, int dim)
virtual void setPointFast(size_t index, float x, float y, float z)
Changes the coordinates of the given point (0-based index), without checking for out-of-bounds and wi...
#define ASSERT_BELOW_(__A, __B)
void getPointXYZ(const size_t idx, T &x, T &y, T &z) const
Get XYZ coordinates of i'th point.
void resize(const size_t N)
Set number of points (to uninitialized values)
virtual ~TColourOptions()
TColouringMethod
The choices for coloring schemes:
virtual bool hasColorPoints() const
Returns true if the point map has a color field for each point.
void setPointXYZ(const size_t idx, const coords_t x, const coords_t y, const coords_t z)
Set XYZ coordinates of i'th point.
void setPointXYZ_RGBu8(const size_t idx, const coords_t x, const coords_t y, const coords_t z, const uint8_t r, const uint8_t g, const uint8_t b)
Set XYZ_RGBu8 coordinates of i'th point.
This class allows loading and storing values and vectors of different types from a configuration text...
void insertPoint(float x, float y, float z)
#define DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
This declaration must be inserted in all CSerializable classes definition, before the class declarati...
Lightweight 3D point (float version).
TColourOptions colorScheme
The options employed when inserting laser scans in the map.
virtual void resize(size_t newLength)
Resizes all point buffers so they can hold the given number of points: newly created points are set t...
EIGEN_STRONG_INLINE void setSize(size_t row, size_t col)
Changes the size of matrix, maintaining its previous content as possible and padding with zeros where...
void getPointRGBf(const size_t idx, float &r, float &g, float &b) const
Get RGBf color of i'th point.
size_t size() const
Get number of points.
A class used to store a 3D point.
mrpt::slam::CColouredPointsMap & m_obj
class BASE_IMPEXP CStream
void setPointColor_fast(size_t index, float R, float G, float B)
Like setPointColor but without checking for out-of-index erors.
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 getPointFast(size_t index, float &x, float &y, float &z) const
Just like getPoint() but without checking out-of-bound index and without returning the point weight...
A RGB color - floats in the range [0,1].
virtual void getPoint(size_t index, float &x, float &y, float &z, float &R, float &G, float &B) const
Retrieves a point and its color (colors range is [0,1])
virtual void setPoint(size_t index, float x, float y, float z, float R, float G, float B)
Changes a given point from map.
void setPoint(size_t index, float x, float y)
This is a virtual base class for sets of options than can be loaded from and/or saved to configuratio...