Problem with assigning different colors to segments in PointCloud
Hello,
I am trying a segment tracking algorithm. Right now I have 2 segments. I am coloring each segment with different RGB values, pushing the segments into output_cloud which is pcl::PointCloud2<pcl::pointxyzrgb> and publishing the output cloud.
The issue I am facing is when I see the PointCloud from RVIZ, I am getting only a single color for both (all) the segments. I have checked the correctness of assigning the RGB values by doing this:
// checking colors
int prev_r = 0;
int prev_g = 0;
int prev_b = 0;
int counter = 0;
for (pcl::PointXYZRGB point : output_cloud) {
if (prev_r != point.r) {
std::cout << int(point.r) << " " << int(point.g) << " " << int(point.b) << std::endl;
std::cout << counter << std::endl;
counter = 0;
}
prev_r = point.r;
prev_g = point.g;
prev_b = point.b;
counter++;
}
std::cout << counter << std::endl;
pub_cloud.publish(output_cloud);
This is what I get (which I think is correct):
Size of segNo_cloud[0] :1168
Size of output_cloud: 1168
Size of segNo_cloud[1] :40680
Size of output_cloud: 41848
16 85 230
0
210 15 236
1168
40680