-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbundle_adjustment.h
67 lines (52 loc) · 1.4 KB
/
bundle_adjustment.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
#ifndef BUNDLE_ADJUSTMENT_H
#define BUNDLE_ADJUSTMENT_H
#include "mappoint.h"
#include "camera.h"
#include "cost_function.h"
#include <map>
#include <set>
#include <vector>
class BundleAdjustment
{
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW;
void optimizationInit();
void computeStateIndexes();
void computeHAndbAndError();
void solveNormalEquation();
void inverseM(const Eigen::MatrixXd& M, Eigen::MatrixXd& M_inv);
void updateStates();
void recoverStates();
std::map<int, MapPoint*> mappoints_;
std::map<int, Camera*> cameras_;
std::set<CostFunction*> cost_functions_;
Eigen::MatrixXd J_;
Eigen::MatrixXd JTinfo_;
Eigen::MatrixXd H_;
Eigen::MatrixXd r_;
Eigen::MatrixXd b_;
Eigen::MatrixXd info_matrix_;
Eigen::MatrixXd Delta_X_;
Eigen::MatrixXd I_;
double lambda_;
int n_cam_state_;
int n_mpt_state_;
int max_iters_;
double min_delta_;
double min_error_;
double sum_error2_;
double last_sum_error2_;
bool verbose_;
public:
BundleAdjustment();
~BundleAdjustment();
void addMapPoint(MapPoint* mpt);
void addCamera(Camera* cam);
void addCostFunction(CostFunction* cost_func);
MapPoint* getMapPoint(int id);
Camera* getCamera(int id);
void setConvergenceCondition(int max_iters, double min_delta, double min_error);
void setVerbose(bool flag);
void optimize();
};
#endif