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

陌路散爱 提交于 2019-12-21 13:41:08

问题


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.


回答1:


Or just use

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



回答2:


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


来源:https://stackoverflow.com/questions/15999331/how-can-i-change-rgb-values-of-pclpointxyzrgba

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!