Resurgence (PY2022)
Codebase for the Husky Robotics 2021-2022 rover Resurgence
|
Represents a "set" of markers used for a competition, containing the markers that should be recognized for that competition and also some other information like the physical (real-world) size of the tags. More...
#include <MarkerSet.h>
Public Member Functions | |
MarkerSet (uint8_t data_region_size, uint8_t border_size, float physical_size, cv::aruco::Dictionary markerDict) | |
Constructs a new marker set. | |
MarkerSet (uint8_t data_region_size, uint8_t border_size, float physical_size, cv::Ptr< cv::aruco::Dictionary > markerDictPtr) | |
Constructs a new marker set. | |
void | addIDMapping (int id, int mapping) |
Adds an ID mapping; that is, a mapping from a marker's actual ID (as defined by the ARUco dictionary) to a user-defined ID that may have some actual meaning in context. | |
int | getIDMapping (int id) const |
Gets an ID mapping. | |
template<class IDMapping_t> | |
IDMapping_t | getIDMappingCast (int id) const |
Gets an ID mapping, statically cast to the type given in the template type parameter. | |
cv::Ptr< cv::aruco::Dictionary > | getDict () const |
Returns the underlying ARUco dictionary defining the marker patterns. | |
uint8_t | getDataRegionSize () const |
Returns the data region size; i.e. | |
uint8_t | getBorderSize () const |
Returns the border size on ONE side of the marker. | |
float | getPhysicalSize () const |
Returns the physical size (in real-world units) of the tags that the markers will appear on. | |
std::vector< MarkerPattern > | getMarkers () const |
Returns a vector of the Markers in this marker set. | |
bool | getMarkerByID (int id, MarkerPattern &out) const |
Gets a Marker by its ID, as defined by the ARUco Dictionary. | |
bool | getMarkerByMappedID (int mapped_id, MarkerPattern &out) const |
Gets a Marker by its mapped ID (as defined with addIDMapping()). | |
bool | isIDMapped (int id) const |
Returns true if the given user-defined ID mapping exists and false if it does not. | |
int & | operator[] (int id) |
Operator to add or get ID mappings; can be used instead of addIDMapping/getIDMapping. | |
Represents a "set" of markers used for a competition, containing the markers that should be recognized for that competition and also some other information like the physical (real-world) size of the tags.
Additionally maps markers to some kind of descriptive meaning in the context for the competition; for example, a MarkerSet could be made for URC that contains all the marker patterns used by the ALVAR system, and maps certain marker patterns to enum constants describing which leg of the autonomous mission the markers represent.
A MarkerSet is constructed from an ARUco Dictionary, which contains a list of all defined marker patterns, which all have some internal ID; the first marker in the Dictionary has ID 0, the second has ID 1, etc. These IDs are usually meaningless and only refer to the order of the markers in the dictionary. Therefore, the MarkerSet class introduces a concept of an ID mapping; that is, a mapping from a marker's actual ID (as defined by the ARUco dictionary) to a user-defined ID that may have some actual meaning in context. Not all markers in the dictionary have to be mapped; the user may choose to map only some meaningful ones and leave others without a mapping.
Note that you should probably not need to construct any instances of this class yourself; Markers.h will contain predefined MarkerSets that you should use.
AR::MarkerSet::MarkerSet | ( | uint8_t | data_region_size, |
uint8_t | border_size, | ||
float | physical_size, | ||
cv::aruco::Dictionary | markerDict ) |
Constructs a new marker set.
Note that you should likely not need to do this as a client of the AR tag detection system.
Parameters:
AR::MarkerSet::MarkerSet | ( | uint8_t | data_region_size, |
uint8_t | border_size, | ||
float | physical_size, | ||
cv::Ptr< cv::aruco::Dictionary > | markerDictPtr ) |
Constructs a new marker set.
Note that you should likely not need to do this as a client of the AR tag detection system.
Parameters:
uint8_t AR::MarkerSet::getBorderSize | ( | ) | const |
Returns the border size on ONE side of the marker.
For example if the marker is 9 pixels wide and the data region is 5 pixels wide, the border size will be 2 (since the border is on both sides of the marker).
uint8_t AR::MarkerSet::getDataRegionSize | ( | ) | const |
Returns the data region size; i.e.
the size of the data region of the marker (NOT including border).
int AR::MarkerSet::getIDMapping | ( | int | id | ) | const |
Gets an ID mapping.
The ID mapping should actually be defined; this method will throw a std::out_of_range exception if the ID mapping does not exist. See isIDMapped().
|
inline |
Gets an ID mapping, statically cast to the type given in the template type parameter.
The type given should be a type that an integer can be statically cast to (e.g. enums). This method will throw a std::out_of_range exception if the ID mapping does not exist. See isIDMapped().
bool AR::MarkerSet::getMarkerByID | ( | int | id, |
MarkerPattern & | out ) const |
Gets a Marker by its ID, as defined by the ARUco Dictionary.
If the Marker exists, this method will return true and the Marker will be returned through the output parameter; if it does not exist, this method will return false and the output parameter will not be modified.
bool AR::MarkerSet::getMarkerByMappedID | ( | int | mapped_id, |
MarkerPattern & | out ) const |
Gets a Marker by its mapped ID (as defined with addIDMapping()).
If the mapping exists, this method will return true and the Marker will be returned through the output parameter; if it does not exist, this method will return false and the output parameter will not be modified.
float AR::MarkerSet::getPhysicalSize | ( | ) | const |
Returns the physical size (in real-world units) of the tags that the markers will appear on.
The unit scale is defined by the user when an instance of this class is constructed.