dictionary.h
Go to the documentation of this file.
1 #ifndef ARUCO_DICTIONARY_
2 #define ARUCO_DICTIONARY_
3 #include <map>
4 #include <string>
5 #include <iostream>
6 #include <vector>
7 #include <stdint.h>
8 #include "exports.h"
9 #include <opencv2/core/core.hpp>
10 namespace aruco{
11 class MarkerMap;
20 {
21 public:
22 
23  //loads from a set of predefined ones
24  enum DICT_TYPES {ARUCO,//original aruco dictionary. By default
27  ARUCO_MIP_36h12,//*** recommended
28  ARTAG,//
31  TAG16h5,TAG25h7,TAG25h9,TAG36h11,TAG36h10 //april tags
32  };
33  //indicates if a code is in the dictionary
34  bool is(uint64_t code)const{return _code_id.find(code)!=_code_id.end();}
35 
36  DICT_TYPES getType()const{return _type;}
37 
38  //reutnr the numerber of ids
39  uint64_t size()const{return _code_id.size();}
40  //returns the total number of bits of the binary code
41  uint32_t nbits()const{return _nbits;}
42  //
43  uint32_t tau()const{return _tau;}
44  //return the set of ids
45  const std::map<uint64_t,uint16_t> & getMapCode()const{return _code_id;}
46 
47  //returns the id of a given code.
48  int operator[](uint64_t code) { return _code_id[code]; }
49 
50 
51  //returns the image of the marker indicated by its id. It the id is not, returns empty matrix
52  //@param id of the marker image to return
53  //@param bit_size of the image will be AxA, A=(nbits()+2)*bit_size
54  cv::Mat getMarkerImage_id(int id,int bit_size,bool addWaterMark=true);
55 
56  //used for boards
57  MarkerMap createMarkerMap( cv::Size gridSize,int MarkerSize,int MarkerDistance, const std::vector<int> &Ids,bool chess_board=false) throw (cv::Exception);
58 
59 
60  static Dictionary loadPredefined(DICT_TYPES type) throw(cv::Exception);
61  static Dictionary loadPredefined(std::string type) throw(cv::Exception);
62  //io functions
63  void saveToFile(std::string file)throw(cv::Exception);
64  void readFromFile(std::string file)throw(cv::Exception);
65  void saveToStream(std::ostream & str)throw(cv::Exception);
66  void readFromStream(std::istream &str)throw(cv::Exception);
67 
68 
69 
70  //given a string,returns the type
71  static DICT_TYPES getTypeFromString(std::string str) throw(cv::Exception);
72  static std::string getTypeString(DICT_TYPES t) throw(cv::Exception);
73  static std::vector<std::string> getDicTypes() ;
74 private:
75 
76  void insert(uint64_t code,int id){_code_id.insert(std::make_pair(code,id));}
77  static void fromVector(const std::vector<uint64_t> &codes,std::map<uint64_t,uint16_t> &code_id_map);
78 
79  std::map<uint64_t,uint16_t> _code_id;//marker have and code (internal binary code), which correspond to an id.
80 
81  uint32_t _nbits;//total number of bits . So, there are sqrt(nbits) in each axis
82  uint32_t _tau;//minimum distance between elements
83 
84  cv::Mat getMarkerImage_code(uint64_t id,int nbits);
85 
87 };
88 }
89 
90 #endif
91 
#define ARUCO_EXPORTS
Definition: exports.h:42
void insert(uint64_t code, int id)
Definition: dictionary.h:76
DICT_TYPES getType() const
Definition: dictionary.h:36
uint64_t size() const
Definition: dictionary.h:39
int operator[](uint64_t code)
Definition: dictionary.h:48
const std::map< uint64_t, uint16_t > & getMapCode() const
Definition: dictionary.h:45
uint32_t tau() const
Definition: dictionary.h:43
DICT_TYPES _type
Definition: dictionary.h:86
bool is(uint64_t code) const
Definition: dictionary.h:34
uint32_t _nbits
Definition: dictionary.h:81
This class defines a set of markers whose locations are attached to a common reference system...
Definition: markermap.h:71
std::map< uint64_t, uint16_t > _code_id
Definition: dictionary.h:79
uint32_t nbits() const
Definition: dictionary.h:41


tuw_aruco
Author(s): Lukas Pfeifhofer
autogenerated on Mon Jun 10 2019 15:40:48