MIRA
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | List of all members
GridMap< T, Channels > Class Template Reference

#include <maps/GridMap.h>

Inheritance diagram for GridMap< T, Channels >:
Inheritance graph
[legend]

Public Types

typedef Base::Pixel CellType
 
typedef ImgPixel< T, ChannelsPixel
 
typedef ImgIterator< ImgPixel< T, Channels > > iterator
 
typedef ImgConstIterator< ImgPixel< T, Channels > > const_iterator
 

Public Member Functions

 GridMap (float cellSize=0.1f)
 Constructs an empty map with a default cell size of 0.1 m. More...
 
 GridMap (const Size2i &size, float cellSize, const Point2i &offset=Point2i(0, 0))
 
 GridMap (const Rect2f &region, float cellSize)
 Creates a new grid map that covers the specified region. More...
 
 GridMap (const Rect2i &region, float cellSize)
 
 GridMap (const Base &data, float cellSize, const Point2i &offset=Point2i(0, 0))
 Construct a grid map from existing image. More...
 
float getCellSize () const
 Returns the size of each cell in meter. More...
 
Point2i getOffset () const
 Returns the offset of the map, e.g. the index of the cell that is located in the origin. More...
 
Point2i getMapOffset () const
 Provided for backward compatibility. Use getOffset() instead. More...
 
Point2f getWorldOffset () const
 Returns the offset of the map in metric coordinates. More...
 
GridMapoperator= (const CellType &c)
 
GridMap clone () const
 
Rect2f getRegion () const
 Returns the region that is covered by the GridMap. More...
 
Rect2i getMapRegion () const
 Returns the region that is covered by the GridMap in grid cells. More...
 
void grow (const Rect2f &region, const CellType &valueForNewCells)
 Grows the map so that the specified region is covered by the map. More...
 
void grow (const Rect2i &region, const CellType &valueForNewCells)
 
void grow (const Point2i &growLowerLeftDelta, const Point2i &growUpperRightDelta, const CellType &valueForNewCells)
 Grows the map by decreasing its minCorner by growLowerLeftDelta and increasing its maxCorner by growUpperRightDelta. More...
 
void clip (const Rect2i &region, const CellType &valueForNewCells)
 Grows and optionally crops the map to cover the specified region while minimizing copying of memory. More...
 
void clip (const Rect2f &region, const CellType &valueForNewCells)
 
Point2i world2map (const Point2f &p, bool roundDown=true) const
 Convert a given point to map coordinates. More...
 
Point2f world2mapf (const Point2f &p) const
 Convert a given point to map coordinates. More...
 
Point2f map2world (const Point2i &p) const
 Convert a given point to world coordinates. More...
 
Point2f map2world (const Point2f &p) const
 Convert a given point to world coordinates. More...
 
Rect2i world2map (const Rect2f &r, bool includeBorder=true) const
 Returns the Rect in cell coordinates that is covered by the given rect that is specified in world coordinates. More...
 
template<typename Derived >
void reflect (BinarySerializer< Derived > &r)
 Reflect method for serialization. More...
 
template<typename Derived >
void reflect (BinaryDeserializer< Derived > &r)
 Reflect method for deserialization. More...
 
void reflect (JSONSerializer &r)
 Reflect method for text visualization. More...
 
ImgPixel< T, Channels > * operator[] (int y)
 
const ImgPixel< T, Channels > * operator[] (int y) const
 
Img< T, Channelsoperator() (const cv::Rect &roi)
 
Img< T, Channelsoperator() (const cv::Rect &roi) const
 
ImgPixel< T, Channels > & operator() (int x, int y)
 
const ImgPixel< T, Channels > & operator() (int x, int y) const
 
ImgPixel< T, Channels > & operator() (const cv::Point &p)
 
const ImgPixel< T, Channels > & operator() (const cv::Point &p) const
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
 operator const cv::Mat & () const
 
 operator cv::Mat & ()
 
void assignROI (const cv::Rect &roi, const ImgBase &other)
 
void assignMask (const cv::Rect &roi, const ImgBase &other, const cv::Mat &mask)
 
void assignPolygon (const cv::Rect &roi, const ImgBase &other, const Polygon2i &poly)
 
bool operator== (const cv::Mat &other) const
 
bool operator!= (const cv::Mat &other) const
 
const cv::MatgetMat () const
 
bool empty () const
 
int width () const
 
int height () const
 
std::size_t step () const
 
std::size_t bytesPerLine () const
 
Size2i size () const
 
int depth () const
 
int channels () const
 
bool isEmpty () const
 
uint8data ()
 
const uint8data () const
 
uint8data (int y)
 
const uint8data (int y) const
 
ImgFormat format () const
 
void resize (const Size2i &s)
 
void resize (int width, int height)
 
void clear ()
 
std::size_t total () const
 

Static Public Member Functions

static Img< T, ChannelsconvertFrom (const cv::Mat &other, bool alwaysCopy=false)
 

Public Attributes

 Channels
 

Protected Types

typedef Img< T, ChannelsSelf
 

Protected Member Functions

Img< T, Channels > * This ()
 
const Img< T, Channels > * This () const
 
cv::Mat_< ImgPixel< T, Channels > > & castToMat ()
 
const cv::Mat_< ImgPixel< T, Channels > > & castToMat () const
 

Protected Attributes

float mCellSize
 width of one cell in m More...
 
Point2i mOffset
 cell index that corresponds to the origin of the map More...
 
cv::Mat mData
 

Detailed Description

template<typename T, int Channels = 1>
class mira::maps::GridMap< T, Channels >

y ^
  |
  +—+—+
  |   |v,u|
  +—+—+
  |0,0|0,1|
  +—+—+–>
  0  csize   x

Member Typedef Documentation

◆ CellType

Constructor & Destructor Documentation

◆ GridMap() [1/5]

GridMap ( float  cellSize = 0.1f)
inlineexplicit

Constructs an empty map with a default cell size of 0.1 m.

The cell size can only be changed by assigning a new Gridmap with the desired cellsize.

◆ GridMap() [2/5]

GridMap ( const Size2i size,
float  cellSize,
const Point2i offset = Point2i(0, 0) 
)
inline

◆ GridMap() [3/5]

GridMap ( const Rect2f region,
float  cellSize 
)
inline

Creates a new grid map that covers the specified region.

The created map is guaranteed to cover the whole specified region. Note that the width and height of the created map may differ, if the width or height of the specified region is not a multiple of the specified cellSize. The width and height will be increased to the next multiple of the cellSize.

◆ GridMap() [4/5]

GridMap ( const Rect2i region,
float  cellSize 
)
inline

◆ GridMap() [5/5]

GridMap ( const Base data,
float  cellSize,
const Point2i offset = Point2i(0, 0) 
)
inline

Construct a grid map from existing image.

In addition to the image, the cell size (in meter) must be specified.

Member Function Documentation

◆ getCellSize()

float getCellSize ( ) const
inline

Returns the size of each cell in meter.

◆ getOffset()

Point2i getOffset ( ) const
inline

Returns the offset of the map, e.g. the index of the cell that is located in the origin.

◆ getMapOffset()

Point2i getMapOffset ( ) const
inline

Provided for backward compatibility. Use getOffset() instead.

◆ getWorldOffset()

Point2f getWorldOffset ( ) const
inline

Returns the offset of the map in metric coordinates.

◆ operator=()

GridMap& operator= ( const CellType c)
inline

◆ clone()

GridMap clone ( ) const
inline

◆ getRegion()

Rect2f getRegion ( ) const
inline

Returns the region that is covered by the GridMap.

◆ getMapRegion()

Rect2i getMapRegion ( ) const
inline

Returns the region that is covered by the GridMap in grid cells.

◆ grow() [1/3]

void grow ( const Rect2f region,
const CellType valueForNewCells 
)
inline

Grows the map so that the specified region is covered by the map.

New cells are initialized with the specified value. If the region is already covered by the map this method does nothing. Note that, if the map is resized, data from the old map will be copied into the new map. This may result in performance penalties, if the map is resized very often. Additionally, the specified value for new cells is copied using a memcpy. This is allowed since the GridMap class can be used for POD types only.

◆ grow() [2/3]

void grow ( const Rect2i region,
const CellType valueForNewCells 
)
inline

◆ grow() [3/3]

void grow ( const Point2i growLowerLeftDelta,
const Point2i growUpperRightDelta,
const CellType valueForNewCells 
)
inline

Grows the map by decreasing its minCorner by growLowerLeftDelta and increasing its maxCorner by growUpperRightDelta.

Parameters
growLowerLeftDeltamargin by which the minCorner is decreased. Must not be negative
growUpperRightDeltamargin by which the mayCorner is increased. Must not be negative
valueForNewCellsThe value for cells that are newly added

◆ clip() [1/2]

void clip ( const Rect2i region,
const CellType valueForNewCells 
)
inline

Grows and optionally crops the map to cover the specified region while minimizing copying of memory.

Parameters
regionThe new region that is covered by the map
valueForNewCellsThe value for cells that are newly added

◆ clip() [2/2]

void clip ( const Rect2f region,
const CellType valueForNewCells 
)
inline

◆ world2map() [1/2]

Point2i world2map ( const Point2f p,
bool  roundDown = true 
) const
inline

Convert a given point to map coordinates.

Parameters
[in]pPoint in world coordinates
[in]roundDownIf true, use std::floor for rounding, else use std::ceil
Returns
Point in map coordinates
Note
The point is not checked if it exceeds the boundaries of the map

◆ world2mapf()

Point2f world2mapf ( const Point2f p) const
inline

Convert a given point to map coordinates.

Parameters
[in]pPoint in world coordinates
Returns
Floating-point point in map coordinates.
Note
The point is not checked if it exceeds the boundaries of the map

◆ map2world() [1/2]

Point2f map2world ( const Point2i p) const
inline

Convert a given point to world coordinates.

Parameters
[in]pCell index in map coordinates.
Returns
Point in world coordinates. Specifying the cell's lower-left corner position

◆ map2world() [2/2]

Point2f map2world ( const Point2f p) const
inline

Convert a given point to world coordinates.

Parameters
[in]pPoint in map coordinates. Specifying an floating-point point in cell coordinates.
Returns
Point in world coordinates.

◆ world2map() [2/2]

Rect2i world2map ( const Rect2f r,
bool  includeBorder = true 
) const
inline

Returns the Rect in cell coordinates that is covered by the given rect that is specified in world coordinates.

Parameters
includeBorderIf true, it is guaranteed, that the returned Rect covers at least the same area as the specified rect. If it is false, the Rect may be smaller.
Note
The rect is not checked if it exceeds the boundaries of the map

◆ reflect() [1/3]

void reflect ( BinarySerializer< Derived > &  r)
inline

Reflect method for serialization.

◆ reflect() [2/3]

void reflect ( BinaryDeserializer< Derived > &  r)
inline

Reflect method for deserialization.

◆ reflect() [3/3]

void reflect ( JSONSerializer r)
inline

Reflect method for text visualization.

Member Data Documentation

◆ mCellSize

float mCellSize
protected

width of one cell in m

◆ mOffset

Point2i mOffset
protected

cell index that corresponds to the origin of the map


The documentation for this class was generated from the following file: