Ask Your Question
0

Color in pointcloud

asked 2013-10-23 05:39:17 -0600

VahidD gravatar image

updated 2016-10-24 09:01:08 -0600

ngrennan gravatar image

Hi all, at first ;) my Ubuntu is 12.04 and my gazebo version is 1.9.1 and also my Ros is hydro. I have a simulated kinect in gazebo and i need the color of points, I’ve write below code that i get the data of simulated kinect and converted to pointcloud, also i tried two method that second one is in comment but when i print the color, it's empty but all other thing is ok, any one can help me?

void readkinectCallback(const sensor_msgs::PointCloud2& msg)
{
 pcl::PointCloud<pcl::PointXYZRGB> pc;

// Convert To Poinct Cloud
pcl::fromROSMsg(msg,pc);

uint32_t rgb = *reinterpret_cast<int*>(&pc.points[100].rgb);
uint8_t r = (rgb >> 16) & 0x0000ff;
uint8_t g = (rgb >> 8) & 0x0000ff;
uint8_t b = (rgb) & 0x0000ff;
   // std::cout<<pc.point[0].r<<pc.point[0].g<<pc.point[0].b<<endl;

}
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2013-10-24 11:12:42 -0600

VahidD gravatar image

my problem is solved, my libraries wasn't match with version of my Ros.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2013-10-23 05:39:17 -0600

Seen: 993 times

Last updated: Oct 23 '13