24 const double resolution,
25 const int interpolationAlgorithm)
27 GridMap gridMapSourceCopy(gridMapSource);
29 const double sizeFactor = gridMapSourceCopy.
getResolution() / resolution;
30 bool firstLayer =
true;
31 for (
const auto& layer : gridMapSourceCopy.
getLayers()) {
32 cv::Mat imageSource, imageResult;
33 const float minValue = gridMapSourceCopy.
get(layer).minCoeffOfFinites();
34 const float maxValue = gridMapSourceCopy.
get(layer).maxCoeffOfFinites();
35 const bool hasNaN = gridMapSourceCopy.
get(layer).hasNaN();
38 result = GridMapCvConverter::toImage<unsigned short, 4>(gridMapSourceCopy, layer, CV_16UC4, minValue, maxValue, imageSource);
40 result = GridMapCvConverter::toImage<unsigned short, 1>(gridMapSourceCopy, layer, CV_16UC1, minValue, maxValue, imageSource);
42 if (!result)
return false;
43 cv::resize(imageSource, imageResult, cv::Size(0.0, 0.0), sizeFactor, sizeFactor, interpolationAlgorithm);
50 result = GridMapCvConverter::addLayerFromImage<unsigned short, 4>(imageResult, layer, gridMapResult, minValue, maxValue);
52 result = GridMapCvConverter::addLayerFromImage<unsigned short, 1>(imageResult, layer, gridMapResult, minValue, maxValue);
54 if (!result)
return false;
virtual ~GridMapCvProcessing()
Time getTimestamp() const
bool getPosition(const Index &index, Position &position) const
void setBasicLayers(const std::vector< std::string > &basicLayers)
const std::string & getFrameId() const
static bool initializeFromImage(const cv::Mat &image, const double resolution, grid_map::GridMap &gridMap, const grid_map::Position &position)
void convertToDefaultStartIndex()
double getResolution() const
const std::vector< std::string > & getLayers() const
const Matrix & get(const std::string &layer) const
static bool changeResolution(const GridMap &gridMapSource, GridMap &gridMapResult, const double resolution, const int interpolationAlgorithm=cv::INTER_CUBIC)
void setFrameId(const std::string &frameId)
void setTimestamp(const Time timestamp)
const std::vector< std::string > & getBasicLayers() const