ANYbotics / grid_map

Universal grid map library for mobile robotic mapping
BSD 3-Clause "New" or "Revised" License
2.62k stars 800 forks source link

Let toImage and addLayerFromImage propagate raw values #372

Open moritzkuhne opened 2 years ago

moritzkuhne commented 2 years ago

For working with other 3rd party libraries, e.g. OpenCV, I would like to convert a layer of floating precision data type to a raw copy of the underlying data.

Like described here, if the data at a cell evaluates std::isfinite to false, its value in the conversion is zero. Furthermore, scaling takes place when converting to and from Mat.

Especially for floating type data, I would like to have the option to propagate numeric limits, like std::nanf and std::numeric_limits<float>::infinity

I looked at the code, and it seems to me that adding a function

template<int NChannels_>
static bool convertToMat(const grid_map::GridMap& gridMap, const std::string& layer,
                    const int encoding, cv::Mat& image)

is clearer, than adding more overloads to the function. Especially since without scaling many assumptions on images are not fulfilled. We write float values images, including non-finite values, to .pfm file. Its not the most widely used format, but I haven't seen something else for float images.

JoLichtenfeld commented 1 year ago

Are there any news on this issue?