39 #ifndef PCL_TYPE_CONVERSIONS_H 40 #define PCL_TYPE_CONVERSIONS_H 59 out.x = in.x; out.y = in.y; out.z = in.z;
60 out.
intensity = 0.299f * static_cast <
float> (in.r) + 0.587f * static_cast <float> (in.g) + 0.114f * static_cast <
float> (in.b);
71 out.intensity = 0.299f * static_cast <
float> (in.r) + 0.587f * static_cast <float> (in.g) + 0.114f * static_cast <
float> (in.b);
82 out.intensity =
static_cast<uint8_t
>(std::numeric_limits<uint8_t>::max() * 0.299f * static_cast <
float> (in.r)
83 + 0.587f * static_cast <float> (in.g) + 0.114f * static_cast <
float> (in.b));
94 out.intensity =
static_cast<uint32_t
>(
static_cast<float>(std::numeric_limits<uint32_t>::max()) * 0.299f * static_cast <float> (in.r)
95 + 0.587f * static_cast <
float> (in.g) + 0.114f * static_cast <float> (in.b));
106 const unsigned char max = std::max (in.r, std::max (in.g, in.b));
107 const unsigned char min = std::min (in.r, std::min (in.g, in.b));
109 out.x = in.x; out.y = in.y; out.z = in.z;
110 out.
v = static_cast <
float> (max) / 255.f;
119 const float diff = static_cast <
float> (max - min);
120 out.
s = diff / static_cast <
float> (max);
128 if (max == in.r) out.
h = 60.f * ( static_cast <
float> (in.g - in.b) / diff);
129 else if (max == in.g) out.
h = 60.f * (2.f + static_cast <
float> (in.b - in.r) / diff);
130 else out.
h = 60.f * (4.f + static_cast <
float> (in.r - in.g) / diff);
132 if (out.
h < 0.f) out.
h += 360.f;
144 const unsigned char max = std::max (in.r, std::max (in.g, in.b));
145 const unsigned char min = std::min (in.r, std::min (in.g, in.b));
147 out.x = in.x; out.y = in.y; out.z = in.z;
148 out.
v = static_cast <
float> (max) / 255.f;
157 const float diff = static_cast <
float> (max - min);
158 out.
s = diff / static_cast <
float> (max);
166 if (max == in.r) out.
h = 60.f * ( static_cast <
float> (in.g - in.b) / diff);
167 else if (max == in.g) out.
h = 60.f * (2.f + static_cast <
float> (in.b - in.r) / diff);
168 else out.
h = 60.f * (4.f + static_cast <
float> (in.r - in.g) / diff);
170 if (out.
h < 0.f) out.
h += 360.f;
181 out.x = in.x; out.y = in.y; out.z = in.z;
184 out.r = out.g = out.b =
static_cast<uint8_t
> (255 * in.
v);
188 int i =
static_cast<int> (floorf (a));
189 float f = a -
static_cast<float> (i);
190 float p = in.
v * (1 - in.
s);
191 float q = in.
v * (1 - in.
s * f);
192 float t = in.
v * (1 - in.
s * (1 - f));
198 out.r =
static_cast<uint8_t
> (255 * in.
v);
199 out.g =
static_cast<uint8_t
> (255 * t);
200 out.b =
static_cast<uint8_t
> (255 * p);
205 out.r =
static_cast<uint8_t
> (255 * q);
206 out.g =
static_cast<uint8_t
> (255 * in.
v);
207 out.b =
static_cast<uint8_t
> (255 * p);
212 out.r =
static_cast<uint8_t
> (255 * p);
213 out.g =
static_cast<uint8_t
> (255 * in.
v);
214 out.b =
static_cast<uint8_t
> (255 * t);
219 out.r =
static_cast<uint8_t
> (255 * p);
220 out.g =
static_cast<uint8_t
> (255 * q);
221 out.b =
static_cast<uint8_t
> (255 * in.
v);
226 out.r =
static_cast<uint8_t
> (255 * t);
227 out.g =
static_cast<uint8_t
> (255 * p);
228 out.b =
static_cast<uint8_t
> (255 * in.
v);
233 out.r =
static_cast<uint8_t
> (255 * in.
v);
234 out.g =
static_cast<uint8_t
> (255 * p);
235 out.b =
static_cast<uint8_t
> (255 * q);
251 for (
size_t i = 0; i < in.
points.size (); i++)
269 for (
size_t i = 0; i < in.
points.size (); i++)
287 for (
size_t i = 0; i < in.
points.size (); i++)
305 for (
size_t i = 0; i < in.
points.size (); i++)
323 for (
size_t i = 0; i < in.
points.size (); i++)
341 for (
size_t i = 0; i < in.
points.size (); i++)
361 float bad_point = std::numeric_limits<float>::quiet_NaN();
362 size_t width_ = depth.
width;
363 size_t height_ = depth.
height;
364 float constant_ = 1.0f / focal;
366 for (
size_t v = 0; v < height_; v++)
368 for (
size_t u = 0; u < width_; u++)
372 float depth_ = depth.
at (u, v).intensity;
376 pt.x = pt.y = pt.z = bad_point;
380 pt.z = depth_ * 0.001f;
381 pt.x =
static_cast<float> (u) * pt.z * constant_;
382 pt.y = static_cast<float> (v) * pt.z * constant_;
384 pt.r = image.
at (u, v).r;
385 pt.g = image.
at (u, v).g;
386 pt.b = image.
at (u, v).b;
388 out.
points.push_back (pt);
396 #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.
std::vector< PointT, Eigen::aligned_allocator< PointT > > points
The point data.
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.
A point structure representing Euclidean xyz coordinates, and the RGBA color.
A point structure representing the grayscale intensity in single-channel images.
const PointT & at(int column, int row) const
Obtain the point given by the (column, row) coordinates.
uint32_t height
The point cloud height (if organized as an image-structure).
void PointRGBtoI(const RGB &in, Intensity &out)
Convert a RGB point type to a I.
void PointXYZRGBtoXYZHSV(const PointXYZRGB &in, PointXYZHSV &out)
Convert a XYZRGB point type to a XYZHSV.
A structure representing RGB color information.
uint32_t width
The point cloud width (if organized as an image-structure).
void PointCloudRGBtoI(const PointCloud< RGB > &in, PointCloud< Intensity > &out)
Convert a RGB point cloud to a Intensity.
void PointXYZRGBAtoXYZHSV(const PointXYZRGBA &in, PointXYZHSV &out)
Convert a XYZRGB point type to a XYZHSV.
A point structure representing the grayscale intensity in single-channel images.
void PointXYZHSVtoXYZRGB(const PointXYZHSV &in, PointXYZRGB &out)
A point structure representing Euclidean xyz coordinates, and the RGB color.