-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfeature_manager.h
104 lines (85 loc) · 2.4 KB
/
feature_manager.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
//
// Created by grn on 10/31/18.
//
#ifndef VINS_FEATURE_MANAGER_H
#define VINS_FEATURE_MANAGER_H
#include <list>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;
#include <eigen3/Eigen/Dense>
using namespace Eigen;
#include "parameters.h"
class FeaturePerFrame
{
public:
FeaturePerFrame(const Eigen::Matrix<double, 7, 1> &_point, double td)
{
point.x() = _point(0);
point.y() = _point(1);
point.z() = _point(2);
uv.x() = _point(3);
uv.y() = _point(4);
velocity.x() = _point(5);
velocity.y() = _point(6);
cur_td = td;
}
double cur_td;
Vector3d point;
Vector2d uv;
Vector2d velocity;
double z;
bool is_used;
double parallax;
MatrixXd A;
VectorXd b;
double dep_gradient;
};
class FeaturePerId
{
public:
const int feature_id;
int start_frame;
vector<FeaturePerFrame> feature_per_frame;
int used_num;
bool is_outlier;
bool is_margin;
double estimated_depth;
int solve_flag; // 0 haven't solve yet; 1 solve succ; 2 solve fail;
Vector3d gt_p;
FeaturePerId(int _feature_id, int _start_frame)
: feature_id(_feature_id), start_frame(_start_frame),
used_num(0), estimated_depth(-1.0), solve_flag(0)
{
}
int endFrame();
};
class FeatureManager
{
public:
FeatureManager(Matrix3d _Rs[]);
void setRic(Matrix3d _ric[]);
void clearState();
int getFeatureCount();
bool addFeatureCheckParallax(int frame_count, const map<int, vector<pair<int, Eigen::Matrix<double, 7, 1>>>> &image, double td);
void debugShow();
vector<pair<Vector3d, Vector3d>> getCorresponding(int frame_count_l, int frame_count_r);
//void updateDepth(const VectorXd &x);
void setDepth(const VectorXd &x);
void removeFailures();
void clearDepth(const VectorXd &x);
VectorXd getDepthVector();
void triangulate(Vector3d Ps[], Vector3d tic[], Matrix3d ric[]);
void removeBackShiftDepth(Eigen::Matrix3d marg_R, Eigen::Vector3d marg_P, Eigen::Matrix3d new_R, Eigen::Vector3d new_P);
void removeBack();
void removeFront(int frame_count);
void removeOutlier();
list<FeaturePerId> feature;
int last_track_num;
private:
double compensatedParallax2(const FeaturePerId &it_per_id, int frame_count);
const Matrix3d *Rs;
Matrix3d ric[NUM_OF_CAM];
};
#endif //VINS_FEATURE_MANAGER_H