-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathgeometric_consistency.hpp
More file actions
36 lines (29 loc) · 1007 Bytes
/
geometric_consistency.hpp
File metadata and controls
36 lines (29 loc) · 1007 Bytes
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
#pragma once
#include "types.hpp"
struct GeometricConsistency
{
GeometricConsistency(const RefView &ref, const FloatT max_error)
: ref(ref)
, max_error(max_error)
{
// nothing to do
}
FloatT operator ()(const SrcView &src, const Vector2i &x_ref) const
{
return (*this)(src, convertToFloat(x_ref), ref.depth(x_ref));
}
FloatT operator ()(const SrcView &src, const Vector2 &x_ref, const FloatT depth) const
{
return (*this)(src, x_ref, ref.unproject(x_ref, depth));
}
FloatT operator ()(const SrcView &src, const Vector2 &x_ref, const Vector3 &X) const
{
const Vector2 x_src = src.project(X);
if (!src.isVisible(x_src)) return max_error;
// TODO: lineraly interpolate depth
const Vector2 x_ref_ = ref.project(src.unproject(x_src, src.depth(convertToInt(x_src))));
return std::min(max_error, (x_ref_ - x_ref).norm());
}
const RefView &ref;
const FloatT max_error;
};