9 #ifndef CColouredPointsMap_H
10 #define CColouredPointsMap_H
40 virtual ~CColouredPointsMap();
54 virtual
void reserve(
size_t newLength);
60 virtual
void resize(
size_t newLength);
66 virtual
void setSize(
size_t newLength);
69 virtual
void setPointFast(
size_t index,
float x,
float y,
float z)
77 virtual void insertPointFast(
float x,
float y,
float z = 0 );
81 virtual void copyFrom(
const CPointsMap &obj);
87 virtual void getPointAllFieldsFast(
const size_t index, std::vector<float> & point_data )
const {
89 point_data[0] = x[index];
90 point_data[1] = y[index];
91 point_data[2] = z[index];
92 point_data[3] = m_color_R[index];
93 point_data[4] = m_color_G[index];
94 point_data[5] = m_color_B[index];
101 virtual void setPointAllFieldsFast(
const size_t index,
const std::vector<float> & point_data ) {
103 x[index] = point_data[0];
104 y[index] = point_data[1];
105 z[index] = point_data[2];
106 m_color_R[index] = point_data[3];
107 m_color_G[index] = point_data[4];
108 m_color_B[index] = point_data[5];
112 virtual void loadFromRangeScan(
117 virtual void loadFromRangeScan(
124 virtual void addFrom_classSpecific(
const CPointsMap &anotherMap,
const size_t nPreviousPoints);
137 bool save3D_and_colour_to_text_file(
const std::string &file)
const;
142 virtual void setPoint(
size_t index,
float x,
float y,
float z,
float R,
float G,
float B);
146 inline void setPoint(
size_t index,
float x,
float y,
float z) {
148 setPointFast(index,x,y,z);
152 inline
void setPoint(
size_t index,
mrpt::math::TPoint3Df &p) {
setPoint(index,p.x,p.y,p.z); }
158 virtual void insertPoint(
float x,
float y,
float z,
float R,
float G,
float B );
167 inline void insertPoint(
float x,
float y,
float z) { insertPointFast(x,y,z); mark_as_modified(); }
172 void setPointColor(
size_t index,
float R,
float G,
float B);
177 this->m_color_R[index]=R;
178 this->m_color_G[index]=G;
179 this->m_color_B[index]=B;
184 virtual void getPoint(
size_t index,
float &x,
float &y,
float &z,
float &R,
float &G,
float &B )
const;
187 unsigned long getPoint(
size_t index,
float &x,
float &y,
float &z)
const;
190 void getPointColor(
size_t index,
float &R,
float &G,
float &B )
const;
195 R = m_color_R[index];
196 G = m_color_G[index];
197 B = m_color_B[index];
206 virtual void getAs3DObject ( mrpt::opengl::CSetOfObjectsPtr &outObj )
const;
218 cmFromHeightRelativeToSensor = 0,
219 cmFromHeightRelativeToSensorJet = 0,
220 cmFromHeightRelativeToSensorGray = 1,
221 cmFromIntensityImage = 2
232 void loadFromConfigFile(
234 const std::string §ion);
247 void resetPointsMinDist(
float defValue = 2000.0f );
253 virtual bool savePCDFile(
const std::string &filename,
bool save_as_binary)
const;
265 template <
class POINTCLOUD>
266 void setFromPCLPointCloudRGB(
const POINTCLOUD &cloud)
268 const size_t N = cloud.points.size();
271 const float f = 1.0f/255.0f;
272 for (
size_t i=0;i<N;++i)
273 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);
277 template <
class POINTCLOUD>
280 const size_t nThis = this->
size();
281 this->getPCLPointCloud(cloud);
283 for (
size_t i = 0; i < nThis; ++i) {
285 this->getPointColor_fast(i,R,G,B);
286 cloud.points[i].r =
static_cast<uint8_t
>(R*255);
287 cloud.points[i].g =
static_cast<uint8_t
>(G*255);
288 cloud.points[i].b =
static_cast<uint8_t
>(B*255);
302 virtual void internal_clear();
312 virtual void PLY_import_set_vertex_count(
const size_t N);
320 virtual void PLY_export_get_vertex(
338 #include <mrpt/utils/adapters.h>
349 static const int HAS_RGB = 1;
350 static const int HAS_RGBf = 1;
351 static const int HAS_RGBu8 = 0;
356 inline size_t size()
const {
return m_obj.
size(); }
361 template <
typename T>
362 inline void getPointXYZ(
const size_t idx, T &x,T &y, T &z)
const {
366 inline void setPointXYZ(
const size_t idx,
const coords_t x,
const coords_t y,
const coords_t z) {
371 template <
typename T>
372 inline void getPointXYZ_RGBf(
const size_t idx, T &x,T &y, T &z,
float &r,
float &g,
float &b)
const {
376 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) {
381 template <
typename T>
382 inline void getPointXYZ_RGBu8(
const size_t idx, T &x,T &y, T &z, uint8_t &r,uint8_t &g,uint8_t &b)
const {
385 r=Rf*255; g=Gf*255; b=Bf*255;
388 inline 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) {
389 m_obj.
setPoint(idx,x,y,z,r/255.f,g/255.f,b/255.f);
398 inline void getPointRGBu8(
const size_t idx, uint8_t &r,uint8_t &g,uint8_t &b)
const {
401 r=R*255; g=G*255; b=B*255;
404 inline void setPointRGBu8(
const size_t idx,
const uint8_t r,
const uint8_t g,
const uint8_t b) {
Declares a class derived from "CObservation" that encapsules an image from a camera, whose relative pose to robot is also stored.
#define MAP_DEFINITION_END(_CLASS_NAME_, _LINKAGE_)
void getPointRGBu8(const size_t idx, uint8_t &r, uint8_t &g, uint8_t &b) const
Get RGBu8 color of i'th point.
void setPointRGBu8(const size_t idx, const uint8_t r, const uint8_t g, const uint8_t b)
Set RGBu8 coordinates of i'th point.
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])
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.
TColouringMethod
The choices for coloring schemes:
void setPoint(size_t index, mrpt::math::TPoint3Df &p)
void insertPoint(float x, float y, float z)
Declares a class derived from "CObservation" that encapsules a 3D range scan measurement, as from a time-of-flight range camera or any other RGBD sensor.
size_t size(const MATRIXLIKE &m, int dim)
void setPointColor_fast(size_t index, float R, float G, float B)
Like setPointColor but without checking for out-of-index erors.
double z
X,Y,Z coordinates.
void setPoint(size_t index, float x, float y)
void getPointXYZ(const size_t idx, T &x, T &y, T &z) const
Get XYZ coordinates of i'th point.
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.
TColourOptions colorScheme
The options employed when inserting laser scans in the map.
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.
This class allows loading and storing values and vectors of different types from a configuration text...
With this struct options are provided to the observation insertion process.
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
A cloud of points in 2D or 3D, which can be built from a sequence of laser scans or other sensors...
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...
#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...
double x() const
Common members of all points & poses classes.
mrpt::maps::CColouredPointsMap & m_obj
Lightweight 3D point (float version).
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)
Set XYZ_RGBf coordinates of i'th point.
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 insertPoint(const mrpt::math::TPoint3Df &p)
A map of 2D/3D points with individual colours (RGB).
A class used to store a 3D point.
void setPoint(size_t index, float x, float y, float z)
void setPointRGBf(const size_t idx, const float r, const float g, const float b)
Set XYZ_RGBf coordinates of i'th point.
virtual void setPoint(size_t index, float x, float y, float z, float R, float G, float B)
Changes a given point from map.
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...
A "CObservation"-derived class that represents a 2D range scan measurement (typically from a laser sc...
#define ASSERT_BELOW_(__A, __B)
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...
PointCloudAdapter(const mrpt::maps::CColouredPointsMap &obj)
Constructor (accept a const ref for convenience)
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Options used when evaluating "computeObservationLikelihood" in the derived classes.
size_t size() const
Returns the number of stored points in the map.
virtual ~TColourOptions()
virtual bool hasColorPoints() const
Returns true if the point map has a color field for each point.
void resize(const size_t N)
Set number of points (to uninitialized values)
A RGB color - floats in the range [0,1].
void insertPoint(const mrpt::poses::CPoint3D &p)
std::vector< float > m_color_R
The color data.
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...
The definition of parameters for generating colors from laser scans.
An adapter to different kinds of point cloud object.
void getPointRGBf(const size_t idx, float &r, float &g, float &b) const
Get RGBf color of i'th point.
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
void getPCLPointCloudXYZRGB(POINTCLOUD &cloud) const
Like CPointsMap::getPCLPointCloud() but for PointCloud
#define MAP_DEFINITION_START(_CLASS_NAME_, _LINKAGE_)
Add a MAP_DEFINITION_START() ...
This is a virtual base class for sets of options than can be loaded from and/or saved to configuratio...
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.