-
Notifications
You must be signed in to change notification settings - Fork 236
/
Copy pathFeature.cc
69 lines (56 loc) · 2.03 KB
/
Feature.cc
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
#include "Feature.h"
#include "Point.h"
#include "internal/ImmaturePoint.h"
#include "internal/PointHessian.h"
#include <memory>
using namespace std;
using namespace ldso::internal;
namespace ldso {
void Feature::CreateFromImmature() {
if (point) {
LOG(WARNING) << "Map point already created! You cannot create twice! " << endl;
return;
}
assert(ip != nullptr);
point = shared_ptr<Point>(new Point(ip->feature));
point->mpPH->point = point; // set the point hessians backward pointer
status = Feature::FeatureStatus::VALID;
}
void Feature::ReleaseImmature() {
if (ip) {
ip->feature = nullptr;
ip = nullptr;
}
}
void Feature::ReleaseMapPoint() {
if (point) {
point->ReleasePH();
}
}
void Feature::save(ofstream &fout) {
fout.write((char *) &status, sizeof(status));
fout.write((char *) &uv[0], sizeof(float));
fout.write((char *) &uv[1], sizeof(float));
fout.write((char *) &invD, sizeof(float));
fout.write((char *) &isCorner, sizeof(bool));
fout.write((char *) &angle, sizeof(float));
fout.write((char *) &score, sizeof(float));
fout.write((char *) descriptor, sizeof(uchar) * 32);
if (point && status == Feature::FeatureStatus::VALID)
point->save(fout);
}
void Feature::load(ifstream &fin, vector<shared_ptr<Frame>> &allKFs) {
fin.read((char *) &status, sizeof(status));
fin.read((char *) &uv[0], sizeof(float));
fin.read((char *) &uv[1], sizeof(float));
fin.read((char *) &invD, sizeof(float));
fin.read((char *) &isCorner, sizeof(bool));
fin.read((char *) &angle, sizeof(float));
fin.read((char *) &score, sizeof(float));
fin.read((char *) descriptor, sizeof(uchar) * 32);
if (status == Feature::FeatureStatus::VALID) {
point = shared_ptr<Point>(new Point);
point->load(fin, allKFs);
}
}
}