dictionary.h
Go to the documentation of this file.
1 
17 #ifndef ARUCO_DICTIONARY_
18 #define ARUCO_DICTIONARY_
19 
20 #include "aruco_export.h"
21 
22 #include <opencv2/core/core.hpp>
23 
24 #include <iostream>
25 #include <map>
26 #include <stdint.h>
27 #include <string>
28 #include <vector>
29 
30 namespace aruco
31 {
32 class MarkerMap;
42 {
43 public:
44  // loads from a set of predefined ones
45  enum DICT_TYPES : uint64_t
46  {
47  ALL_DICTS = 0,
48  ARUCO_MIP_36h12 = 1, //*** recommended
49  ARUCO = 2, // original aruco dictionary. By default
50  ARUCO_MIP_25h7 = 3,
51  ARUCO_MIP_16h3 = 4,
52  ARTAG = 5, //
53  ARTOOLKITPLUS = 6,
54  ARTOOLKITPLUSBCH = 7, //
55  TAG16h5 = 8,
56  TAG25h7 = 9,
57  TAG25h9 = 10,
58  TAG36h11 = 11,
59  TAG36h10 = 12, // april tags
60  CHILITAGS = 13, // chili tags dictionary . NOT RECOMMENDED. It has distance 0.
61  // Markers 806 and 682 should not be used!!!
62  CUSTOM = 14, // for used defined dictionaries (using loadFromfile).
63  };
64  // indicates if a code is in the dictionary
65  bool is(uint64_t code) const
66  {
67  return _code_id.find(code) != _code_id.end();
68  }
69 
71  {
72  return _type;
73  }
74 
75  // reutnr the numerber of ids
76  uint64_t size() const
77  {
78  return _code_id.size();
79  }
80  // returns the total number of bits of the binary code
81  uint32_t nbits() const
82  {
83  return _nbits;
84  }
85  // returns the dictionary distance
86  uint32_t tau() const
87  {
88  return _tau;
89  }
90  // returns the name
91  std::string getName() const
92  {
93  return _name;
94  }
95  // return the set of ids
96  const std::map<uint64_t, uint16_t>& getMapCode() const
97  {
98  return _code_id;
99  }
100 
101  // returns the id of a given code.
102  int operator[](uint64_t code)
103  {
104  return _code_id[code];
105  } // returns the id of a given code.
106  int at(uint64_t code)
107  {
108  return _code_id[code];
109  }
110 
111  // returns the image of the marker indicated by its id. It the id is not, returns empty
112  // matrix
113  //@param id of the marker image to return
114  //@param bit_size of the image will be AxA, A=(nbits()+2)*bit_size
115  //@param enclosed_corners if true, extra rectagles are added touching the marker
116  //corners. it can be used to allow subpixel refinement
117  cv::Mat getMarkerImage_id(int id, int bit_size, bool addWaterMark = true,
118  bool enclosed_corners = false,
119  bool printExternalWhiteBorder = false, bool centralCircle = false);
120 
121  // cv::Mat getMarkerMatrix_id(int id);
122 
123  // used for boards
124  MarkerMap createMarkerMap(cv::Size gridSize, int MarkerSize, int MarkerDistance,
125  const std::vector<int>& Ids, bool chess_board = false);
126 
127  static Dictionary loadPredefined(DICT_TYPES type);
128  static Dictionary loadPredefined(std::string type);
129 
147  static Dictionary loadFromFile(std::string path);
148 
152  static Dictionary load(std::string info);
153 
154  // //io functions
155  // void saveToFile(std::string file);
156  // void readFromFile(std::string file);
157  // void saveToStream(std::ostream & str);
158  // void readFromStream(std::istream &str);
159 
160  // returns the dictionary distance
161  static uint64_t computeDictionaryDistance(const Dictionary& d);
162 
163  // given a string,returns the type
164  static DICT_TYPES getTypeFromString(std::string str);
165  static std::string getTypeString(DICT_TYPES t);
166  static bool isPredefinedDictinaryString(std::string str);
167  static std::vector<std::string> getDicTypes();
168 
169 private:
170  // obfuscate start
171 
172  void insert(uint64_t code, int id)
173  {
174  _code_id.insert(std::make_pair(code, id));
175  }
176  static void fromVector(const std::vector<uint64_t>& codes,
177  std::map<uint64_t, uint16_t>& code_id_map);
178 
179  std::map<uint64_t, uint16_t> _code_id; // marker have and code (internal binary code),
180  // which correspond to an id.
181 
182  uint32_t _nbits; // total number of bits . So, there are sqrt(nbits) in each axis
183  uint32_t _tau; // minimum distance between elements
184 
186  std::string _name;
187  // obfuscate end
188 };
189 } // namespace aruco
190 
191 #endif
aruco::MarkerMap
This class defines a set of markers whose locations are attached to a common reference system,...
Definition: markermap.h:111
aruco::Dictionary::nbits
uint32_t nbits() const
Definition: dictionary.h:81
aruco::Dictionary::insert
void insert(uint64_t code, int id)
Definition: dictionary.h:172
aruco::Dictionary::getName
std::string getName() const
Definition: dictionary.h:91
aruco::Dictionary
Definition: dictionary.h:41
aruco::Dictionary::getMapCode
const std::map< uint64_t, uint16_t > & getMapCode() const
Definition: dictionary.h:96
aruco::Dictionary::size
uint64_t size() const
Definition: dictionary.h:76
aruco::Dictionary::_code_id
std::map< uint64_t, uint16_t > _code_id
Definition: dictionary.h:179
aruco::Dictionary::at
int at(uint64_t code)
Definition: dictionary.h:106
aruco::Dictionary::tau
uint32_t tau() const
Definition: dictionary.h:86
aruco_export.h
aruco::Dictionary::_type
DICT_TYPES _type
Definition: dictionary.h:185
aruco::Dictionary::DICT_TYPES
DICT_TYPES
Definition: dictionary.h:45
aruco::Dictionary::operator[]
int operator[](uint64_t code)
Definition: dictionary.h:102
ARUCO_EXPORT
#define ARUCO_EXPORT
Definition: aruco_export.h:30
aruco::Dictionary::getType
DICT_TYPES getType() const
Definition: dictionary.h:70
aruco::Dictionary::_name
std::string _name
Definition: dictionary.h:186
aruco
Definition: cameraparameters.h:24
aruco::Dictionary::is
bool is(uint64_t code) const
Definition: dictionary.h:65
aruco::Dictionary::_tau
uint32_t _tau
Definition: dictionary.h:183
aruco::Dictionary::_nbits
uint32_t _nbits
Definition: dictionary.h:182


aruco
Author(s): Rafael Muñoz Salinas , Bence Magyar
autogenerated on Sat Sep 23 2023 02:26:45