我怎样才能改变PCL的RGB值:: PointXYZRGBA?(How can I change R

2019-08-22 23:31发布

我有型点pcl::PointXYZRGBA 。 我该如何分配/改变它的RGB值?

为了改变XYZ坐标,我可以简单地做point.x = some_value

Answer 1:

或者只是使用

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


Answer 2:

您可以使用pcl::PointXYZRGB而不是pcl::PointXYZRGBA 。 我认为他们都做同样的。 然后到颜色的红点(255,0,0),你可以这样做:

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

和XYZ坐标然后可以分别分配:

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

编辑:或者,如果你坚持使用pcl::PointXYZRGBA ,你可以做

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


文章来源: How can I change RGB values of pcl::PointXYZRGBA?