-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmap.cpp
More file actions
46 lines (37 loc) · 946 Bytes
/
map.cpp
File metadata and controls
46 lines (37 loc) · 946 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "map.h"
#include <cassert>
using namespace cv;
using namespace std;
Map::Map()
{
}
bool Map::loadFromFile(const string &filename)
{
mapfile = filename;
FileStorage fs(mapfile, FileStorage::READ);
assert(fs.isOpened());
FileNode nodeKFs = fs["KeyFrames"];
FileNodeIterator it = nodeKFs.begin(), itend = nodeKFs.end();
size_pose = nodeKFs.size();
Poses.clear();
Poses.reserve(size_pose);
for(; it != itend; it++) {
FileNode nodeKF = *it;
Mat pose;
nodeKF["Pose"] >> pose;
Poses.push_back(pose);
}
FileNode nodeMPs = fs["MapPoints"];
it = nodeMPs.begin(), itend = nodeMPs.end();
size_point = nodeMPs.size();
Points.clear();
Points.reserve(size_point);
for(; it != itend; it++) {
FileNode nodeMP = *it;
Point3f pos;
nodeMP["Pos"] >> pos;
Points.push_back(pos);
}
fs.release();
return true;
}