[module_name] OctreePointCloudCompression loses intensity when decompressing pcl::PointXYZI point type
Describe the bug
I use pcl::io::OctreePointCloudCompression<pcl::PointXYZI> to compress and decompress a point cloud. I can see that it reads the intensity values, however when I decompressed the compressed stream, I lose intensity data. It writes only zeros instead of intensity.
Context
I use pretty simple code to generate encoder and decoder. ` bool showStatistics = true;
pcl::io::compression_Profiles_e compressionProfile = pcl::io::HIGH_RES_OFFLINE_COMPRESSION_WITH_COLOR;
PointCloudEncoder = new pcl::io::OctreePointCloudCompressionpcl::PointXYZI (compressionProfile, showStatistics); PointCloudDecoder = new pcl::io::OctreePointCloudCompressionpcl::PointXYZI (); `
The input point data is like this:
345678.33 7027198.37 0.37 29512 345678.65 7027188.83 0.45 29206 345679.22 7027188.36 0.31 34296 345698.41 7027190.22 0.36 45830 345699.26 7027193.52 0.43 35847 347698.84 7027198.09 0.38 28070 345768.38 7027197.18 0.32 28005 345987.83 7027198.26 0.34 31260 345984.69 7027195.48 0.34 34471
But after compressine and decompressing, it turns into this:
345678.25 7027188.5 0.30900002 0 345678.81 7027198.5 0.33900002 0 345680.38 7027197 0.31900001 0 345698.69 7027195.5 0.33900002 0 345688.62 7027189 0.449 0 344527.31 7027198.5 0.37 0 345698.81 7027198 0.37900001 0 345985.25 7027193.5 0.43000001 0 345984.44 7027190 0.36000001 0
These are x, y, z, intensity values respectively.
Expected behavior
I expect to see intensity values too with some reasonable error or not.
Current Behavior
Intensity turns into 0 after compressing/decompressing with OctreePointCloudCompression.
To Reproduce
- Just create empty pcd file in ascii format and then open it in text editor and write the initial x, y, z, intensity values.
- Compress/decompress it via OctreePointCloudCompression with pcl::PointXYZI point type all over.
- Print the output and see if the intensity values are all zero or not.
Your Environment (please complete the following information):
- OS: [e.g. Ubuntu 20.04]
- Compiler: [:eg GCC 11.4.0]
- PCL Version [e.g. 1.15, HEAD]
Hi! This is a known limitation of OctreePointCloudCompression. It only encodes/decodes xyz and rgb-color. I guess this should be more clearly documented. I don't know how easy it would be to extend OctreePointCloudCompression so that it also encodes/decodes intensity information. Do you know the range of your intensity values (meaning, is there a maximum value)? If yes, you can try using PointXYZRGB and transfer the intensity information to r, g, and b. One idea (low precision):
point.r = static_cast<std::uint8_t>(intensity/max_intensity*255.0);
Another idea:
float intensity = ... ;
intensity = intensity/max_intensity*(255.0*255.0*255.0);
point.r = static_cast<std::uint8_t>(fmod(intensity, 255.0);
intensity /= 255.0;
point.g = static_cast<std::uint8_t>(fmod(intensity, 255.0);
intensity /= 255.0;
point.b = static_cast<std::uint8_t>(intensity);
(Both ideas are untested)
Related issue: https://github.com/PointCloudLibrary/pcl/issues/4516