Color in output of simulated kinect

asked 2013-10-23 10:36:25 -0600

Vahid 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 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