57 void reserve(
size_t newLength)
override;
58 void resize(
size_t newLength)
override;
59 void setSize(
size_t newLength)
override;
71 const size_t index, std::vector<float>& point_data)
const override 74 point_data[0] =
m_x[index];
75 point_data[1] =
m_y[index];
76 point_data[2] =
m_z[index];
88 const size_t index,
const std::vector<float>& point_data)
override 91 m_x[index] = point_data[0];
92 m_y[index] = point_data[1];
93 m_z[index] = point_data[2];
111 const CPointsMap& anotherMap,
const size_t nPreviousPoints)
override;
114 template <
class Derived>
116 template <
class Derived>
132 size_t index,
float x,
float y,
float z,
float R,
float G,
138 float x,
float y,
float z,
float R,
float G,
float B)
override;
156 size_t index,
float& x,
float& y,
float& z,
float&
R,
float&
G,
157 float& B)
const override;
164 size_t index,
float&
R,
float&
G,
float& B)
const 209 const std::string& section)
override;
211 std::ostream&
out)
const override;
228 #if defined(PCL_LINEAR_VERSION) 231 inline bool savePCDFile(
232 const std::string& filename,
bool save_as_binary)
const 234 pcl::PointCloud<pcl::PointXYZRGB> cloud;
236 const size_t nThis = this->
size();
241 cloud.is_dense =
false;
242 cloud.points.resize(cloud.width * cloud.height);
244 const float f = 255.f;
251 for (
size_t i = 0; i < nThis; ++i)
253 cloud.points[i].x =
m_x[i];
254 cloud.points[i].y =
m_y[i];
255 cloud.points[i].z =
m_z[i];
257 aux_val.rgb[0] =
static_cast<uint8_t
>(this->
m_color_B[i] * f);
258 aux_val.rgb[1] =
static_cast<uint8_t
>(this->
m_color_G[i] * f);
259 aux_val.rgb[2] =
static_cast<uint8_t
>(this->
m_color_R[i] * f);
261 cloud.points[i].rgb = aux_val.f;
264 return 0 == pcl::io::savePCDFile(filename, cloud, save_as_binary);
279 template <
class POINTCLOUD>
282 const size_t N = cloud.points.size();
285 const float f = 1.0f / 255.0f;
286 for (
size_t i = 0; i < N; ++i)
288 cloud.points[i].x, cloud.points[i].y, cloud.points[i].z,
289 cloud.points[i].r * f, cloud.points[i].g * f,
290 cloud.points[i].b * f);
294 template <
class POINTCLOUD>
297 const size_t nThis = this->
size();
300 for (
size_t i = 0; i < nThis; ++i)
304 cloud.points[i].r =
static_cast<uint8_t
>(
R * 255);
305 cloud.points[i].g =
static_cast<uint8_t
>(
G * 255);
306 cloud.points[i].b =
static_cast<uint8_t
>(B * 255);
354 #include <mrpt/opengl/pointcloud_adapters.h> 370 static constexpr
bool HAS_RGB =
true;
372 static constexpr
bool HAS_RGBf =
true;
374 static constexpr
bool HAS_RGBu8 =
false;
382 inline size_t size()
const {
return m_obj.
size(); }
388 template <
typename T>
401 template <
typename T>
403 const size_t idx, T& x, T& y, T& z,
float& r,
float& g,
float& b,
412 const float r,
const float g,
const float b,
413 [[maybe_unused]]
const float a)
419 template <
typename T>
421 const size_t idx, T& x, T& y, T& z, uint8_t& r, uint8_t& g,
433 const uint8_t r,
const uint8_t g,
const uint8_t b)
435 m_obj.
setPointRGB(idx, x, y, z, r / 255.f, g / 255.f, b / 255.f);
440 const size_t idx,
float& r,
float& g,
float& b)
const 446 const size_t idx,
const float r,
const float g,
const float b)
453 const size_t idx, uint8_t& r, uint8_t& g, uint8_t& b)
const 463 const size_t idx,
const uint8_t r,
const uint8_t g,
const uint8_t b)
481 cmFromHeightRelativeToSensor);
484 cmFromHeightRelativeToSensorJet);
487 cmFromHeightRelativeToSensorGray);
PointCloudAdapter(const mrpt::maps::CColouredPointsMap &obj)
Constructor (accept a const ref for convenience)
void clear()
Erase all the contents of the map.
void setSize(size_t newLength) override
Resizes all point buffers so they can hold the given number of points, erasing all previous contents ...
void addFrom_classSpecific(const CPointsMap &anotherMap, const size_t nPreviousPoints) override
Auxiliary method called from within addFrom() automatically, to finish the copying of class-specific ...
TColouringMethod
The choices for coloring schemes:
Declares a class derived from "CObservation" that encapsules an image from a camera, whose relative pose to robot is also stored.
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...
void insertPointFast(float x, float y, float z=0) override
The virtual method for insertPoint() without calling mark_as_modified()
This is a virtual base class for sets of options than can be loaded from and/or saved to configuratio...
CPointsMap & operator=(const CPointsMap &o)
void setPointXYZ_RGBAf(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, [[maybe_unused]] const float a)
Set XYZ_RGBf coordinates of i'th point.
bool save3D_and_colour_to_text_file(const std::string &file) const
Save to a text file.
void dumpToTextStream(std::ostream &out) const override
This method should clearly display all the contents of the structure in textual form, sending it to a std::ostream.
void getPointRGBu8(const size_t idx, uint8_t &r, uint8_t &g, uint8_t &b) const
Get RGBu8 color of i'th point.
TColourOptions()
Initilization of default parameters.
void getPointAllFieldsFast(const size_t index, std::vector< float > &point_data) const override
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 internal_clear() override
Minimum distance from where the points have been seen.
#define MAP_DEFINITION_START(_CLASS_NAME_)
Add a MAP_DEFINITION_START() ...
void loadFromConfigFile(const mrpt::config::CConfigFileBase &source, const std::string §ion) override
This method load the options from a ".ini"-like file or memory-stored string list.
void setPointAllFieldsFast(const size_t index, const std::vector< float > &point_data) override
Set all the data fields for one point as a vector: [X Y Z R G B] Unlike setPointAllFields(), this method does not check for index out of bounds.
A range or depth 3D scan measurement, as from a time-of-flight range camera or a structured-light dep...
mrpt::aligned_std_vector< float > m_color_R
The color data.
CColouredPointsMap & operator=(const CColouredPointsMap &o)
void setPointColor_fast(size_t index, float R, float G, float B)
Like setPointColor but without checking for out-of-index erors.
void insertPoint(float x, float y, float z=0)
Provides a way to insert (append) individual points into the map: the missing fields of child classes...
void getPointRGBf(const size_t idx, float &r, float &g, float &b) const
Get RGBf color of i'th point.
void setFromPCLPointCloudRGB(const POINTCLOUD &cloud)
Loads a PCL point cloud (WITH RGB information) into this MRPT class (for clouds without RGB data...
mrpt::maps::CColouredPointsMap & m_obj
float coords_t
The type of each point XYZ coordinates.
std::vector< T, mrpt::aligned_allocator_cpp11< T > > aligned_std_vector
TColourOptions colorScheme
The options employed when inserting laser scans in the map.
void resize(const size_t N)
Set number of points (to uninitialized values)
void reserve(size_t newLength) override
Reserves memory for a given number of points: the size of the map does not change, it only reserves the memory.
CColouredPointsMap()=default
With this struct options are provided to the observation insertion process.
A cloud of points in 2D or 3D, which can be built from a sequence of laser scans or other sensors...
This class allows loading and storing values and vectors of different types from a configuration text...
mrpt::aligned_std_vector< float > m_color_B
MRPT_FILL_ENUM_MEMBER(mrpt::maps::CColouredPointsMap::TColouringMethod, cmFromHeightRelativeToSensor)
An adapter to different kinds of point cloud object.
void setPointRGB(size_t index, float x, float y, float z, float R, float G, float B) override
Changes a given point from map.
void PLY_import_set_vertex_count(const size_t N) override
In a base class, reserve memory to prepare subsequent calls to PLY_import_set_vertex.
void insertPointRGB(float x, float y, float z, float R, float G, float B) override
Adds a new point given its coordinates and color (colors range is [0,1])
#define MRPT_ENUM_TYPE_END()
void getPCLPointCloud(POINTCLOUD &cloud) const
Use to convert this MRPT point cloud object into a PCL point cloud object (PointCloud<PointXYZ>).
A map of 2D/3D points with individual colours (RGB).
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...
mrpt::aligned_std_vector< float > m_color_G
void setInvalidPoint(const size_t idx)
Set XYZ coordinates of i'th point.
void getPCLPointCloudXYZRGB(POINTCLOUD &cloud) const
Like CPointsMap::getPCLPointCloud() but for PointCloud<PointXYZRGB>
void setPointRGBf(const size_t idx, const float r, const float g, const float b)
Set XYZ_RGBf coordinates of i'th point.
void getPointXYZ(const size_t idx, T &x, T &y, T &z) const
Get XYZ coordinates of i'th point.
mrpt::aligned_std_vector< float > m_z
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 getPointRGB(size_t index, float &x, float &y, float &z, float &R, float &G, float &B) const override
Retrieves a point and its color (colors range is [0,1])
uint8_t f2u8(const float f)
converts a float [0,1] into an uint8_t [0,255] (without checking for out of bounds) ...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
A "CObservation"-derived class that represents a 2D range scan measurement (typically from a laser sc...
void setDimensions(size_t height, size_t width)
Does nothing as of now.
mrpt::aligned_std_vector< float > m_y
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.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
mrpt::vision::TStereoCalibResults out
bool hasColorPoints() const override
Returns true if the point map has a color field for each point.
void resetPointsMinDist(float defValue=2000.0f)
Reset the minimum-observed-distance buffer for all the points to a predefined value.
Options used when evaluating "computeObservationLikelihood" in the derived classes.
CColouredPointsMap & operator=(const CPointsMap &o)
#define ASSERTDEB_(f)
Defines an assertion mechanism - only when compiled in debug.
void PLY_export_get_vertex(const size_t idx, mrpt::math::TPoint3Df &pt, bool &pt_has_color, mrpt::img::TColorf &pt_color) const override
In a base class, will be called after PLY_export_get_vertex_count() once for each exported point...
void loadFromRangeScan(const mrpt::obs::CObservation2DRangeScan &rangeScan, const mrpt::poses::CPose3D *robotPose=nullptr) override
See CPointsMap::loadFromRangeScan()
An RGBA color - floats in the range [0,1].
void PLY_import_set_vertex(const size_t idx, const mrpt::math::TPoint3Df &pt, const mrpt::img::TColorf *pt_color=nullptr) override
In a base class, will be called after PLY_import_set_vertex_count() once for each loaded point...
CColouredPointsMap(const CPointsMap &o)
void getPointXYZ_RGBAf(const size_t idx, T &x, T &y, T &z, float &r, float &g, float &b, float &a) const
Get XYZ_RGBf coordinates of i'th point.
void resize(size_t newLength) override
Resizes all point buffers so they can hold the given number of points: newly created points are set t...
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.
CColouredPointsMap(const CColouredPointsMap &o)
#define DEFINE_SERIALIZABLE(class_name, NS)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
The definition of parameters for generating colors from laser scans.
size_t size() const
Get number of points.
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.
void getAs3DObject(mrpt::opengl::CSetOfObjects::Ptr &outObj) const override
Override of the default 3D scene builder to account for the individual points' color.
void impl_copyFrom(const CPointsMap &obj) override
Virtual assignment operator, copies as much common data (XYZ, color,...) as possible from the source ...
#define MRPT_ENUM_TYPE_BEGIN(_ENUM_TYPE_WITH_NS)
mrpt::aligned_std_vector< float > m_x
The point coordinates.
bool colourFromObservation(const mrpt::obs::CObservationImage &obs, const mrpt::poses::CPose3D &robotPose)
Colour a set of points from a CObservationImage and the global pose of the robot. ...
#define MAP_DEFINITION_END(_CLASS_NAME_)
size_t size() const
Save the point cloud as a PCL PCD file, in either ASCII or binary format.
void getPointColor_fast(size_t index, float &R, float &G, float &B) const
Like getPointColor but without checking for out-of-index erors.
void getPointColor(size_t index, float &R, float &G, float &B) const
Retrieves a point color (colors range is [0,1])
void setPointColor(size_t index, float R, float G, float B)
Changes just the color of a given point from the map.