读取pcl::PointXYZRGB中的RGB信息

对于PointXYZRGB类型读取RGB信息:

pcl::PointCloud::PointXYZRGB>::Ptr cloud (new pcl::PointCloud::PointXYZRGB>);

方法一

int r = cloud->points[i].r;
int g = cloud->points[i].g;
int b = cloud->points[i].b;

方法二

unsigned long rgb = *reinterpret_cast<int*>(&cloud->points[i].rgb);
int r = (rgb>>16)&0x0000ff;
int g = (rgb>>8)&0x0000ff;
int b = (rgb)&0x0000ff;

备注一

typedef signed char int8_t;
typedef unsigned char uint8_t;

typedef int int16_t;
typedef unsigned int uint16_t;

typedef long int32_t;
typedef unsigned long uint32_t;

typedef long long int64_t;
typedef unsigned long long uint64_t;

备注二:

unsigned long a;
printf("%lu",a);//%lu for unsigned long

参考
1pcl::PointXYZRGB Struct Reference
2meaning of the rgb field in PCD file format
3tutorials_The PCD (Point Cloud Data) file format
4printf unsigned long

你可能感兴趣的:(机器视觉)