SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
WAIMapStorage.h
Go to the documentation of this file.
1 #ifndef MAP_STORAGE
2 #define MAP_STORAGE
3 
4 #include <SLSceneView.h>
5 #include <WAIHelper.h>
6 #include <WAISlam.h>
7 #include <fbow.h>
8 #include <Utils.h>
9 
10 //-----------------------------------------------------------------------------
12 {
13  struct MapInfo
14  {
15  int32_t version;
16  int32_t kfCount, mpCount;
17  // nodeOmSaved is used as boolean... sizeof(bool) is not defined in the c++ standard, thats why we have to use an int
18  int32_t nodeOmSaved;
19  };
20 
21  struct KeyFrameInfo
22  {
23  int32_t id;
24  int32_t parentId;
25 
26  float scaleFactor;
27  int32_t scaleLevels;
28 
29  int32_t minX, minY, maxX, maxY;
30 
31  int32_t loopEdgesCount;
32  int32_t kpCount;
33  int32_t covisiblesCount;
34 
35  int32_t bowVecSize;
36  };
37 
38  struct MapPointInfo
39  {
40  int32_t id;
41  int32_t refKfId;
42 
43  int32_t nObervations;
44 
45  float minDistance, maxDistance;
46  };
47 
48  struct KeyPointData
49  {
50  float x, y;
51  float size;
52  float angle;
53  float response;
54  int32_t octave;
55  int32_t classId;
56  };
57 
58 public:
59  static bool saveMap(WAIMap* waiMap,
60  SLNode* mapNode,
61  std::string fileName,
62  std::string imgDir = "",
63  bool saveBOW = true);
64 
65  static bool saveMapRaw(WAIMap* waiMap,
66  SLNode* mapNode,
67  std::string fileName,
68  std::string imgDir = "");
69 
70  static bool saveMapBinary(WAIMap* waiMap,
71  SLNode* mapNode,
72  std::string fileName,
73  std::string imgDir = "",
74  bool saveBOW = true);
75 
76  static bool loadMap(WAIMap* waiMap,
77  cv::Mat& mapNodeOm,
78  WAIOrbVocabulary* voc,
79  std::string path,
80  bool loadImgs,
81  bool fixKfsAndMPts);
82 
83  static bool loadMapBinary(WAIMap* waiMap,
84  cv::Mat& mapNodeOm,
85  WAIOrbVocabulary* voc,
86  std::string path,
87  bool loadImgs,
88  bool fixKfsAndMPts);
89 
90  static cv::Mat convertToCVMat(const SLMat4f slMat);
91  static SLMat4f convertToSLMat(const cv::Mat& cvMat);
92  static std::vector<uint8_t> convertCVMatToVector(const cv::Mat& mat);
93  static void saveKeyFrameVideoMatching(std::vector<int>& keyFrameVideoMatching, std::vector<std::string> vidname, const std::string& mapDir, const std::string outputKFMatchingFile);
94  static void loadKeyFrameVideoMatching(std::vector<int>& keyFrameVideoMatching, std::vector<std::string>& vidname, const std::string& mapDir, const std::string outputKFMatchingFile);
95 
96  template<typename T>
97  static void writeVectorToBinaryFile(FILE* f, const std::vector<T> vec);
98  template<typename T>
99  static std::vector<T> loadVectorFromBinaryStream(uint8_t** data, int count);
100  static void writeCVMatToBinaryFile(FILE* f, const cv::Mat& mat);
101  static cv::Mat loadCVMatFromBinaryStream(uint8_t** data, int rows, int cols, int type);
102 };
103 //-----------------------------------------------------------------------------
104 #endif
#define WAI_API
Definition: WAIHelper.h:36
SLNode represents a node in a hierarchical scene graph.
Definition: SLNode.h:147
Definition: WAIMap.h:52