Class GridMapCvConverter

Class Documentation

class GridMapCvConverter

Conversions between grid maps and OpenCV images.

Public Static Functions

static inline bool initializeFromImage(const cv::Mat &image, const double resolution, grid_map::GridMap &gridMap, const grid_map::Position &position)

Initializes the geometry of a grid map from an image. This changes the geometry of the map and deletes all contents of the layers!

Parameters:
  • image[in] the image.

  • resolution[in] the desired resolution of the grid map [m/cell].

  • gridMap[out] the grid map to be initialized.

Param :

template<typename Type_, int NChannels_>
static inline bool addLayerFromImage(const cv::Mat &image, const std::string &layer, grid_map::GridMap &gridMap, const float lowerValue = 0.0, const float upperValue = 1.0, const double alphaThreshold = 0.5)

Adds a layer with data from image.

Parameters:
  • image[in] the image to be added. If it is a color image (bgr or bgra encoding), it will be transformed in a grayscale image.

  • layer[in] the layer that is filled with the image data.

  • gridMap[out] the grid map to be populated.

Param :

template<typename Type_, int NChannels_>
static inline bool addColorLayerFromImage(const cv::Mat &image, const std::string &layer, grid_map::GridMap &gridMap)

Adds a color layer with data from an image.

Parameters:
  • image[in] the image to be added (BGR format).

  • layer[in] the layer that is filled with the image.

  • gridMap[out] the grid map to be populated.

Returns:

true if successful, false otherwise.

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

Creates a cv mat from a grid map layer. This conversion sets the corresponding black and white pixel value to the min. and max. data of the layer data.

Parameters:
  • grid[in] map to be added.

  • layer[in] the layer that is converted to the image.

  • encoding[in] the desired encoding of the image.

  • lowerValue[in] the value of the layer corresponding to black image pixels.

  • upperValue[in] the value of the layer corresponding to white image pixels.

  • image[out] the image to be populated.

Returns:

true if successful, false otherwise.

template<typename Type_, int NChannels_>
static inline bool toImage(const grid_map::GridMap &gridMap, const std::string &layer, const int encoding, const float lowerValue, const float upperValue, cv::Mat &image)

Creates a cv mat from a grid map layer.

Parameters:
  • grid[in] map to be added.

  • layer[in] the layer that is converted to the image.

  • encoding[in] the desired encoding of the image.

  • lowerValue[in] the value of the layer corresponding to black image pixels.

  • upperValue[in] the value of the layer corresponding to white image pixels.

  • image[out] the image to be populated.

Returns:

true if successful, false otherwise.