简体   繁体   中英

How can I change RGB values of pcl::PointXYZRGBA?

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

For changing xyz coordinates, I can simply do point.x = some_value .

Or just use

point.r = 255;
point.b = 0;
point.g = 0;
point.a = 255;

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

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

And the xyz-coordinates can then be assigned respectively:

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

EDIT: Or if you have to stick with 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM