ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
Hi luke,
To get RGB image from cloud data ,
cv::Mat imageFrame;
if (cloud->isOrganized())
{
imageFrame = cv::Mat(cloud->height, cloud->width, CV_8UC3);
{
for (int h=0; h<imageFrame.rows; h++)
{
for (int w=0; w<imageFrame.cols; w++)
{
pcl::PointXYZRGBA point = cloud->at(w, h);
Eigen::Vector3i rgb = point.getRGBVector3i();
imageFrame.at<cv::Vec3b>(h,w)[0] = rgb[2];
imageFrame.at<cv::Vec3b>(h,w)[1] = rgb[1];
imageFrame.at<cv::Vec3b>(h,w)[2] = rgb[0];
}
}
}
}
But first you might need to convert cloud data into pcl supported form, for this you can use,
pcl::PointCloud<pcl::pointxyzrgba>::Ptr cloud (new pcl::PointCloud<pcl::pointxyzrgba>);
pcl::fromROSMsg (*input, *cloud);
Once you get the image, you can apply your detection algorithm using opencv libs,
To get depth of point x,y in image
int i = x + y*cloud->width; float depth = (float)cloud->points[i].z;
Hope this helped :)