forked from JakobEngel/dso
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathResiduals.h
106 lines (76 loc) · 2.3 KB
/
Residuals.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
105
/**
* This file is part of DSO.
*
* Copyright 2016 Technical University of Munich and Intel.
* Developed by Jakob Engel <engelj at in dot tum dot de>,
* for more information see <http://vision.in.tum.de/dso>.
* If you use this code, please cite the respective publications as
* listed on the above website.
*
* DSO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* DSO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with DSO. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "util/globalCalib.h"
#include "vector"
#include "util/NumType.h"
#include <iostream>
#include <fstream>
#include "util/globalFuncs.h"
#include "OptimizationBackend/RawResidualJacobian.h"
namespace dso
{
class PointHessian;
class FrameHessian;
class CalibHessian;
class EFResidual;
enum ResLocation {ACTIVE=0, LINEARIZED, MARGINALIZED, NONE};
enum ResState {IN=0, OOB, OUTLIER};
struct FullJacRowT
{
Eigen::Vector2f projectedTo[MAX_RES_PER_POINT];
};
class PointFrameResidual
{
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
EFResidual* efResidual;
static int instanceCounter;
ResState state_state;
double state_energy;
ResState state_NewState;
double state_NewEnergy;
double state_NewEnergyWithOutlier;
void setState(ResState s) {state_state = s;}
PointHessian* point;
FrameHessian* host;
FrameHessian* target;
RawResidualJacobian* J;
bool isNew;
Eigen::Vector2f projectedTo[MAX_RES_PER_POINT];
Vec3f centerProjectedTo;
~PointFrameResidual();
PointFrameResidual();
PointFrameResidual(PointHessian* point_, FrameHessian* host_, FrameHessian* target_);
double linearize(CalibHessian* HCalib);
void resetOOB()
{
state_NewEnergy = state_energy = 0;
state_NewState = ResState::OUTLIER;
setState(ResState::IN);
};
void applyRes( bool copyJacobians);
void debugPlot();
void printRows(std::vector<VecX> &v, VecX &r, int nFrames, int nPoints, int M, int res);
};
}