Resurgence (PY2022)
Codebase for the Husky Robotics 2021-2022 rover Resurgence
Loading...
Searching...
No Matches
MarkerSet.h
1#pragma once
2
3#include "MarkerPattern.h"
4
5#include <memory>
6#include <unordered_map>
7#include <vector>
8
9#include <opencv2/aruco.hpp>
10#include <opencv2/core.hpp>
11
12namespace AR {
17
38class MarkerSet {
39private:
42 float physical_size;
43 uint8_t data_region_size;
44 uint8_t border_size;
46 std::unordered_map<int, int> reverse_mappings;
47 void init(uint8_t data_region_size, uint8_t border_size, float physical_size,
49
50public:
69 MarkerSet(uint8_t data_region_size, uint8_t border_size, float physical_size,
70 cv::aruco::Dictionary markerDict);
90 MarkerSet(uint8_t data_region_size, uint8_t border_size, float physical_size,
91 cv::Ptr<cv::aruco::Dictionary> markerDictPtr);
96 void addIDMapping(int id, int mapping);
101 int getIDMapping(int id) const;
108 template <class IDMapping_t> IDMapping_t getIDMappingCast(int id) const {
109 return static_cast<IDMapping_t>(this->getIDMapping(id));
110 }
111
125 uint8_t getBorderSize() const;
131 float getPhysicalSize() const;
142 bool getMarkerByID(int id, MarkerPattern& out) const;
149 bool getMarkerByMappedID(int mapped_id, MarkerPattern& out) const;
153 bool isIDMapped(int id) const;
157 int& operator[](int id);
158};
159
160namespace Markers {
164enum URCMarkerName {
165 START,
166 POST1,
167 POST2,
168 POST3,
169 GATEL,
170 GATER
171};
172
180enum CIRCMarkerName { CIRCMarker1, CIRCMarker2 };
181
185const std::shared_ptr<MarkerSet> URC_MARKERS();
186
190const std::shared_ptr<MarkerSet> CIRC_MARKERS();
191
192} // namespace Markers
194} // namespace AR
A class to represent the pattern that may appear on a physical AR tag, NOT a physical instance of a t...
Definition MarkerPattern.h:28
IDMapping_t getIDMappingCast(int id) const
Gets an ID mapping, statically cast to the type given in the template type parameter.
Definition MarkerSet.h:108
int getIDMapping(int id) const
Gets an ID mapping.
Definition MarkerSet.cpp:57
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)...
Definition MarkerSet.cpp:52
bool getMarkerByMappedID(int mapped_id, MarkerPattern &out) const
Gets a Marker by its mapped ID (as defined with addIDMapping()).
Definition MarkerSet.cpp:97
std::vector< MarkerPattern > getMarkers() const
Returns a vector of the Markers in this marker set.
Definition MarkerSet.cpp:81
uint8_t getBorderSize() const
Returns the border size on ONE side of the marker.
Definition MarkerSet.cpp:73
bool isIDMapped(int id) const
Returns true if the given user-defined ID mapping exists and false if it does not.
Definition MarkerSet.cpp:85
MarkerSet(uint8_t data_region_size, uint8_t border_size, float physical_size, cv::aruco::Dictionary markerDict)
Constructs a new marker set.
Definition MarkerSet.cpp:18
uint8_t getDataRegionSize() const
Returns the data region size; i.e.
Definition MarkerSet.cpp:69
int & operator[](int id)
Operator to add or get ID mappings; can be used instead of addIDMapping/getIDMapping.
Definition MarkerSet.cpp:61
cv::Ptr< cv::aruco::Dictionary > getDict() const
Returns the underlying ARUco dictionary defining the marker patterns.
Definition MarkerSet.cpp:65
bool getMarkerByID(int id, MarkerPattern &out) const
Gets a Marker by its ID, as defined by the ARUco Dictionary.
Definition MarkerSet.cpp:89
float getPhysicalSize() const
Returns the physical size (in real-world units) of the tags that the markers will appear on.
Definition MarkerSet.cpp:77
std::shared_ptr< _Tp > Ptr
::uint8_t uint8_t