-
Notifications
You must be signed in to change notification settings - Fork 31
/
ARAPDataTerm.h
108 lines (88 loc) · 3.87 KB
/
ARAPDataTerm.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
106
107
108
#ifndef __VW_STEREO_ARAPDATATERM_H__
#define __VW_STEREO_ARAPDATATERM_H__
#include <vw/Image/ImageView.h>
#include <vw/Math/Vector.h>
#include <vw/Math/BBox.h>
namespace vw {
namespace stereo {
double gradient_cost_metric(ImageView<float> const& a,
ImageView<float> const& b,
float alpha = 0.85, // These constants come from the eccv14 paper
float t_col = 1,
float t_grad = 1);
// float t_col = 0.0784,
//float t_grad = 0.0157);
double evaluate_superpixel(ImageView<float> const& a,
ImageView<float> const& b,
BBox2i const& a_superpixel,
Vector2 const& a_barycenter,
Vector<double, 10> const& surface);
double evaluate_intermediate_term(double theta,
ImageView<Vector2f> const& u,
BBox2i const& a_superpixel,
Vector2 const& a_barycenter,
Vector<double, 10> const& surface);
void fit_surface_superpixel(ImageView<PixelMask<Vector2i> > const& a_disp,
BBox2i const& a_subpixel,
Vector2 const& a_barycenter,
Vector<double, 10> & surface);
void define_superpixels(ImageView<PixelMask<Vector2i> > const& a_disp,
std::vector<std::pair<BBox2i, Vector2> > & superpixels,
std::vector<Vector<double, 10> > & superpixel_surfaces);
void render_disparity_image(std::vector<std::pair<BBox2i, Vector2> > const& superpixels,
std::vector<Vector<double, 10> > const& superpixel_surfaces,
ImageView<PixelMask<Vector2f> > & disp);
struct IndiceFinder {
int width_, num_indices_;
IndiceFinder(int w, int num) : width_(w), num_indices_(num) {}
inline int l(int s) {
return std::max(0, s - 1);
}
inline int r(int s) {
return std::min(num_indices_, s + 1);
}
inline int tl(int s) {
return std::max(0, s - 1 - width_);
}
inline int t(int s) {
return std::max(0, s - width_);
}
inline int tr(int s) {
return std::max(0, s - width_ + 1);
}
inline int bl(int s) {
return std::min(num_indices_, s + width_ - 1);
}
inline int b(int s) {
return std::min(num_indices_, s + width_);
}
inline int br(int s) {
return std::min(num_indices_, s + width_ + 1);
}
};
struct NMFunctor {
ImageView<float> const& left, right;
ImageView<Vector2f> const& u;
std::pair<BBox2i, Vector2> const& superpixel;
double theta;
NMFunctor(ImageView<float> const& a,
ImageView<float> const& b,
ImageView<Vector2f> const& u,
std::pair<BBox2i, Vector2> const& s,
double t) :
left(a), right(b), u(u), superpixel(s), theta(t) {}
double operator()(Vector<double, 10> const& surface) const {
std::cout << surface << std::endl;
return 20000*stereo::evaluate_superpixel(left, right,
superpixel.first,
superpixel.second,
surface) +
stereo::evaluate_intermediate_term(theta, u,
superpixel.first,
superpixel.second,
surface);
}
};
}
}
#endif //__VW_STEREO_ARAPDATATERM_H__