Point Cloud Library (PCL)  1.9.1-dev
List of all members | Public Member Functions | Friends
pcl::PointXYZRGB Struct Reference

A point structure representing Euclidean xyz coordinates, and the RGB color. More...

#include <pcl/impl/point_types.hpp>

+ Inheritance diagram for pcl::PointXYZRGB:

Public Member Functions

 PointXYZRGB (const _PointXYZRGB &p)
 PointXYZRGB ()
 PointXYZRGB (uint8_t _r, uint8_t _g, uint8_t _b)


std::ostream & operator<< (std::ostream &os, const PointXYZRGB &p)

Additional Inherited Members

- Public Attributes inherited from pcl::_PointXYZRGB

Detailed Description

A point structure representing Euclidean xyz coordinates, and the RGB color.

Due to historical reasons (PCL was first developed as a ROS package), the RGB information is packed into an integer and casted to a float. This is something we wish to remove in the near future, but in the meantime, the following code snippet should help you pack and unpack RGB colors in your PointXYZRGB structure:

// pack r/g/b into rgb
uint8_t r = 255, g = 0, b = 0; // Example: Red color
uint32_t rgb = ((uint32_t)r << 16 | (uint32_t)g << 8 | (uint32_t)b);
p.rgb = *reinterpret_cast<float*>(&rgb);

To unpack the data into separate values, use:

// unpack rgb into r/g/b
uint32_t rgb = *reinterpret_cast<int*>(&p.rgb);
uint8_t r = (rgb >> 16) & 0x0000ff;
uint8_t g = (rgb >> 8) & 0x0000ff;
uint8_t b = (rgb) & 0x0000ff;

Alternatively, from 1.1.0 onwards, you can use p.r, p.g, and p.b directly.

Definition at line 620 of file point_types.hpp.

Constructor & Destructor Documentation

pcl::PointXYZRGB::PointXYZRGB ( const _PointXYZRGB p)

Definition at line 622 of file point_types.hpp.

pcl::PointXYZRGB::PointXYZRGB ( )

Definition at line 628 of file point_types.hpp.

pcl::PointXYZRGB::PointXYZRGB ( uint8_t  _r,
uint8_t  _g,
uint8_t  _b 

Definition at line 635 of file point_types.hpp.

References pcl::operator<<(), and PCL_MAKE_ALIGNED_OPERATOR_NEW.

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const PointXYZRGB p 

The documentation for this struct was generated from the following file: