39 #ifndef PCL_TYPE_CONVERSIONS_H
40 #define PCL_TYPE_CONVERSIONS_H
44 #include <pcl/point_cloud.h>
45 #include <pcl/point_types.h>
62 out.x = in.x; out.y = in.y; out.z = in.z;
63 out.
intensity = 0.299f * static_cast <
float> (in.r) + 0.587f * static_cast <float> (in.g) + 0.114f * static_cast <
float> (in.b);
74 out.intensity = 0.299f * static_cast <
float> (in.r) + 0.587f * static_cast <float> (in.g) + 0.114f * static_cast <
float> (in.b);
85 out.intensity =
static_cast<uint8_t
>(0.299f * static_cast <
float> (in.r)
86 + 0.587f * static_cast <float> (in.g) + 0.114f * static_cast <
float> (in.b));
97 out.intensity =
static_cast<uint32_t
>(0.299f * static_cast <
float> (in.r)
98 + 0.587f * static_cast <float> (in.g) + 0.114f * static_cast <
float> (in.b));
109 const unsigned char max = std::max (in.r, std::max (in.g, in.b));
110 const unsigned char min = std::min (in.r, std::min (in.g, in.b));
112 out.x = in.x; out.y = in.y; out.z = in.z;
113 out.
v = static_cast <
float> (max) / 255.f;
122 const float diff = static_cast <
float> (max - min);
123 out.
s = diff / static_cast <
float> (max);
131 if (max == in.r) out.
h = 60.f * ( static_cast <
float> (in.g - in.b) / diff);
132 else if (max == in.g) out.
h = 60.f * (2.f + static_cast <
float> (in.b - in.r) / diff);
133 else out.
h = 60.f * (4.f + static_cast <
float> (in.r - in.g) / diff);
135 if (out.
h < 0.f) out.
h += 360.f;
147 const unsigned char max = std::max (in.r, std::max (in.g, in.b));
148 const unsigned char min = std::min (in.r, std::min (in.g, in.b));
150 out.x = in.x; out.y = in.y; out.z = in.z;
151 out.
v = static_cast <
float> (max) / 255.f;
160 const float diff = static_cast <
float> (max - min);
161 out.
s = diff / static_cast <
float> (max);
169 if (max == in.r) out.
h = 60.f * ( static_cast <
float> (in.g - in.b) / diff);
170 else if (max == in.g) out.
h = 60.f * (2.f + static_cast <
float> (in.b - in.r) / diff);
171 else out.
h = 60.f * (4.f + static_cast <
float> (in.r - in.g) / diff);
173 if (out.
h < 0.f) out.
h += 360.f;
184 out.x = in.x; out.y = in.y; out.z = in.z;
187 out.r = out.g = out.b =
static_cast<uint8_t
> (255 * in.
v);
191 int i =
static_cast<int> (floorf (a));
192 float f = a -
static_cast<float> (i);
193 float p = in.
v * (1 - in.
s);
194 float q = in.
v * (1 - in.
s * f);
195 float t = in.
v * (1 - in.
s * (1 - f));
201 out.r =
static_cast<uint8_t
> (255 * in.
v);
202 out.g =
static_cast<uint8_t
> (255 * t);
203 out.b =
static_cast<uint8_t
> (255 * p);
208 out.r =
static_cast<uint8_t
> (255 * q);
209 out.g =
static_cast<uint8_t
> (255 * in.
v);
210 out.b =
static_cast<uint8_t
> (255 * p);
215 out.r =
static_cast<uint8_t
> (255 * p);
216 out.g =
static_cast<uint8_t
> (255 * in.
v);
217 out.b =
static_cast<uint8_t
> (255 * t);
222 out.r =
static_cast<uint8_t
> (255 * p);
223 out.g =
static_cast<uint8_t
> (255 * q);
224 out.b =
static_cast<uint8_t
> (255 * in.
v);
229 out.r =
static_cast<uint8_t
> (255 * t);
230 out.g =
static_cast<uint8_t
> (255 * p);
231 out.b =
static_cast<uint8_t
> (255 * in.
v);
236 out.r =
static_cast<uint8_t
> (255 * in.
v);
237 out.g =
static_cast<uint8_t
> (255 * p);
238 out.b =
static_cast<uint8_t
> (255 * q);
254 for (
size_t i = 0; i < in.
points.size (); i++)
272 for (
size_t i = 0; i < in.
points.size (); i++)
290 for (
size_t i = 0; i < in.
points.size (); i++)
308 for (
size_t i = 0; i < in.
points.size (); i++)
326 for (
size_t i = 0; i < in.
points.size (); i++)
344 for (
size_t i = 0; i < in.
points.size (); i++)
364 float bad_point = std::numeric_limits<float>::quiet_NaN();
365 size_t width_ = depth.
width;
366 size_t height_ = depth.
height;
367 float constant_ = 1.0f / focal;
369 for (
size_t v = 0; v < height_; v++)
371 for (
size_t u = 0; u < width_; u++)
374 float depth_ = depth.
at (u, v).intensity;
378 pt.x = pt.y = pt.z = bad_point;
382 pt.z = depth_ * 0.001f;
383 pt.x =
static_cast<float> (u) * pt.z * constant_;
384 pt.y = static_cast<float> (v) * pt.z * constant_;
386 pt.r = image.
at (u, v).r;
387 pt.g = image.
at (u, v).g;
388 pt.b = image.
at (u, v).b;
390 out.
points.push_back (pt);
398 #endif //#ifndef PCL_TYPE_CONVERSIONS_H
void PointXYZRGBtoXYZI(const PointXYZRGB &in, PointXYZI &out)
Convert a XYZRGB point type to a XYZI.
A point structure representing the grayscale intensity in single-channel images.
void PointCloudXYZRGBAtoXYZHSV(const PointCloud< PointXYZRGBA > &in, PointCloud< PointXYZHSV > &out)
Convert a XYZRGB point cloud to a XYZHSV.
void PointCloudXYZRGBtoXYZHSV(const PointCloud< PointXYZRGB > &in, PointCloud< PointXYZHSV > &out)
Convert a XYZRGB point cloud to a XYZHSV.
uint32_t width
The point cloud width (if organized as an image-structure).
void PointCloudDepthAndRGBtoXYZRGBA(const PointCloud< Intensity > &depth, const PointCloud< RGB > &image, const float &focal, PointCloud< PointXYZRGBA > &out)
Convert registered Depth image and RGB image to PointCloudXYZRGBA.
void PointCloudXYZRGBtoXYZI(const PointCloud< PointXYZRGB > &in, PointCloud< PointXYZI > &out)
Convert a XYZRGB point cloud to a XYZI.
This file defines compatibility wrappers for low level I/O functions.
A point structure representing Euclidean xyz coordinates, and the RGBA color.
A point structure representing the grayscale intensity in single-channel images.
void PointRGBtoI(const RGB &in, Intensity &out)
Convert a RGB point type to a I.
std::vector< PointT, Eigen::aligned_allocator< PointT > > points
The point data.
void PointXYZRGBtoXYZHSV(const PointXYZRGB &in, PointXYZHSV &out)
Convert a XYZRGB point type to a XYZHSV.
A structure representing RGB color information.
void PointCloudRGBtoI(const PointCloud< RGB > &in, PointCloud< Intensity > &out)
Convert a RGB point cloud to an Intensity.
void PointXYZRGBAtoXYZHSV(const PointXYZRGBA &in, PointXYZHSV &out)
Convert a XYZRGBA point type to a XYZHSV.
A point structure representing the grayscale intensity in single-channel images.
void PointXYZHSVtoXYZRGB(const PointXYZHSV &in, PointXYZRGB &out)
uint32_t height
The point cloud height (if organized as an image-structure).
const PointT & at(int column, int row) const
Obtain the point given by the (column, row) coordinates.
A point structure representing Euclidean xyz coordinates, and the RGB color.