I'm trying to convert a planar section of a pcl::pointcloud into a binary image. I found a class called savePNGFile, but is not working well with my program.
Until now I did a ROI selector and a intensity filter to get the points I want.
void regionOfInterest(VPointCloud::Ptr cloud_in, double x1, double x2,
double y1, double y2, double z)
{
for (VPoint& point: cloud_in->points)
if ((z > point.z) && (y1 > point.y) && (y2 < point.y) && (x1 > point.x)
&&(x2 < point.x))
cloud_out->points.push_back(point);
}
(VPointCloud is the kind of pointcloud I need to work with my data) I know that maybe the piece of code I show there is not relevant, but it can show you more or less the types I'm using.
Anybody knows how to export this pointcloud to binary image? After this step I will work with OpenCV.
Thank you
This method should work for either organized or unorganized data. However you may need to rotate your input point cloud plane so that it is parallel to two of the orthogonal dimensions and you know what dimension you want to remove. stepSize1 and stepSize2 are parameters to set what size of the point cloud becomes a pixel in the new image. This calculates a grayscale image based on point density, but it could easily be modified to show depth or other information. A simple threshold can also be used to make the image binary.