-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbundle.h
83 lines (61 loc) · 1.71 KB
/
bundle.h
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/* Copyright 2014 Matthieu Tourne */
#ifndef BUNDLE_H
#define BUNDLE_H
#include <vector>
#include "image.h"
#include "image_pairs.h"
class Bundle {
public:
Bundle() {};
// create with an existing bundle
Bundle(std::vector<ImagePair> image_pairs)
: image_pairs(image_pairs)
{};
~Bundle() {};
inline void add_pair(ImagePair &pair) {
image_pairs.push_back(pair);
}
inline size_t pair_count() const {
return image_pairs.size();
}
inline vector<ImagePair> get_image_pairs() const {
return image_pairs;
}
inline ImagePair get_image_pair(const int i) const {
return image_pairs[i];
}
void add_image(Image::ptr image);
inline Image::ptr get_image(const int i) const {
return images[i];
}
inline vector<Image::ptr> get_images() const {
return images;
}
inline size_t image_count() const {
return images.size();
}
// serialization
void write(FileStorage& fs) const;
// deserialization
void read(const FileNode& node);
private:
// potentially this could be a hashmap indexed by camera
// type, if there are multiple photos from different cams
// XX (mtourne): I think it's possible to match different "K" from
// different images (need to check).
vector<ImagePair> image_pairs;
vector<Image::ptr> images;
};
// serialization
inline void write(FileStorage& fs, const std::string&, const Bundle& x) {
x.write(fs);
}
// deserialization
inline void read(const FileNode& node, Bundle& x,
const Bundle& default_value = Bundle()){
if (node.empty())
x = default_value;
else
x.read(node);
}
#endif // !BUNDLE_H