-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a generic savePNGFile()
function
#204
Conversation
The new function takes sensor_msgs::Image and saves it as a PNG file. Currently supported are "rgb8", "mono8", and "mono16" image encodings.
* PointCloudImageExtractorFromRGBField produced a color image based on the data in "rgb" field of a point cloud. * PointCloudImageExtractorFromNormalField produced a color image based on the data in "normal" field of a point cloud. * PointCloudImageExtractorFromLabelField produced a mono image based on the data in "label" field of a point cloud. * PointCloudImageExtractorFromZField produces a mono image based on the "z" field of a point cloud. * PointCloudImageExtractorFromCurvatureField produces a mono image based on the "curvature" field of a point cloud. * PointCloudImageExtractorFromIntensityField produces a mono image based on the "intensity" field of a point cloud.
The new function takes a field name and uses appropriate PointCloudImageExtractor subclass to extract an image from the given field. Currently supported are "normal", rgb", "label", "z", "curvature", and "intensity" fields.
Does this support the full resolution of an OpenNI camera's depth map (IIRC the Kinect has 16 bits of depth resolution in terms of image files) or is it downsampled / truncated to fit in the PNG? |
Depth ("z" field) is saved to a mono PNG file with 16 bits per pixel. By default "z" value of a point is multiplied by 10000 to get pixel value. Although the number is somewhat arbitrary (should it be different? let's discuss), it gives nice pictures for typical scenes. Of course, for points that are further away than ~6.55 m the product will overflow 16 bit and will be aliased with close points. If the user works with such scenes he could use other custom scale factor. Alternatively, he could use automatic scaling to full range. |
Hi Sergey, that's a lot of code, thanks for contributing! On the other hand, this will take some time to review. For example I've found you are using make_shared() a number of times. Is this really needed? Regarding the API change, would it be possible to keep the old API and make it call the new one (haven't checked the code)? We have some PCL_DEPRECATED() macros to notice users of this functions, but we can't remove stuff from the API during the 1.7.X releases. Regarding the pcd2png, would it be possible to extend the old tool, so we don't have to introduce a new one? Thanks! |
Jochen,
|
make_shared creates an extra copy, so it's a bit inefficient, depending on what object you apply it to. |
To my knowledge it's quite the opposite, or do I misunderstand boost documentation?
|
Yes, but it still calls the copy constructor afaik. The best way is to create a shared_ptr directly, and then use it throughout the code. |
Regarding the tool, I'm fine with adding the new one, could you add a warning to the old one, that it's deprecated, as well? Thanks! |
Bump. Are there any remaining issues that prevent from merging? |
#include <string> | ||
#include <vector> | ||
#include <pcl/io/point_cloud_image_extractors.h> | ||
#include <boost/make_shared.hpp> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unneeded, as far as I can see.
Looking fine for me, @rbrusu are you ok with it? |
Old pcl::io::savePNGFile() functions are obsolete now, as well as the organized_pcd_to_png tool.
This gets rid of depreciation warning in example_supervoxels.cpp and organized_pcd_to_png.cpp.
This way the default behavior is the same as of the organized_pcd_to_png tool.
This allows to get a colorful image where different labels are painted with random colors. Unit tests and pcd2png tool are updated accordingly.
I removed the unnecessary include and also added some documentation for |
looks great to me! |
Add a generic `savePNGFile()` function
This pull request introduces a new
savePNGFile()
function as discussed in this thread: http://www.pcl-developers.org/A-generic-savePNGFile-function-td5707976.html.The function accepts the name of the field which should be used to extract image data. Currently "rgb", "normal", "label", "z", "curvature", and "intensity" fields are supported. The underlying implementation is driven by a set of
PointCloudImageExtractorFrom...Field
classes which know how to extract data from a particular field (applying additional scaling as necessary).There are tests for all Image Extractors.
Additionally there is a new application "pcd2png" in the "tools" module which uses the new functionality.
There are three things that should be discussed before merging this pull request:
savePNGFile()
with the following signature:Should it be removed in favor of using
savePNGFile("blah.png", cloud, "label")
?3) There exist a templated version of
savePNGFile()
with the following signature:It uses "r", "g", and "b" field of a point cloud (if exist, otherwise it fails to compile, of course). Should it be removed in favor of using
savePNGFile("blah.png", cloud, "rgb")
?