How to change RGB values ​​for pcl :: PointXYZRGBA?

I have a type point pcl::PointXYZRGBA. How can I assign / change its rgb values?

To change the xyz coordinates, I can just do point.x = some_value.

+5
source share
2 answers

Or just use

point.r = 255;
point.b = 0;
point.g = 0;
point.a = 255;
+6
source

You can use pcl::PointXYZRGBinstead pcl::PointXYZRGBA. I think both of them do the same. And then, to color the red point (255,0,0), you can do:

pcl::PointXYZRGB point = pcl::PointXYZRGB(255, 0, 0);

And then xyz coordinates can be assigned accordingly:

point.x = x;
point.y = y;
point.z = z;

EDIT: Or, if you need to stick pcl::PointXYZRGBA, you can do

pcl::PointXYZRGBA point;
uint8_t r = 255;
uint8_t g = 0;
uint8_t b = 0;
int32_t rgb = (r << 16) | (g << 8) | b; 
point.rgba = *(float *)(&rgb); // makes the point red
+4
source

All Articles