MVE - Multi-View Environment mve-devel
Loading...
Searching...
No Matches
patch_sampler.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2015, Ronny Klowsky, Simon Fuhrmann
3 * TU Darmstadt - Graphics, Capture and Massively Parallel Computing
4 * All rights reserved.
5 *
6 * This software may be modified and distributed under the terms
7 * of the BSD 3-Clause license. See the LICENSE.txt file for details.
8 */
9
10#ifndef DMRECON_PATCH_SAMPLER_H
11#define DMRECON_PATCH_SAMPLER_H
12
13#include <map>
14#include <memory>
15
16#include "math/vector.h"
17#include "dmrecon/defines.h"
18#include "dmrecon/settings.h"
19#include "dmrecon/single_view.h"
20
22
24{
25public:
26 typedef std::shared_ptr<PatchSampler> Ptr;
27
28public:
31
34 std::vector<SingleView::Ptr> const& _views,
35 Settings const& _settings,
36 int _x, // pixel position
37 int _y,
38 float _depth,
39 float _dzI,
40 float _dzJ);
41
43 static PatchSampler::Ptr create(std::vector<SingleView::Ptr> const& views,
44 Settings const& settings, int x, int _y,
45 float _depth, float _dzI, float _dzJ);
46
48 void fastColAndDeriv(std::size_t v, Samples & color,
49 Samples& deriv);
50
52 float getFastNCC(std::size_t v);
53
55 Samples const& getMasterColorSamples() const;
56
58 float getMasterMeanColor() const;
59
61 math::Vec3f const & getMidWorldPoint() const;
62
64 float getNCC(std::size_t u, std::size_t v);
65
68 float getSAD(std::size_t v, math::Vec3f const& cs);
69
72 float getSSD(std::size_t v, math::Vec3f const& cs);
73
75 Samples const& getNeighColorSamples(std::size_t v);
76
78 std::size_t getNrSamples() const;
79
81 math::Vec3f getPatchNormal() const;
82
84 bool succeeded(std::size_t v) const;
85
87 void update(float newDepth, float newDzI, float newDzJ);
88
90 float varInMasterPatch();
91
92
93private:
94 std::vector<SingleView::Ptr> const& views;
95 Settings const& settings;
96
98 math::Vec3f meanX;
99 float sqrDevX;
100
102 math::Vec2i midPix;
103 math::Vec2i topLeft;
104 math::Vec2i bottomRight;
105
107 float masterMeanCol;
108
110 std::size_t offset;
111
112 size_t nrSamples;
113
115 float depth;
116 float dzI, dzJ;
117
119 std::vector<math::Vec3f> masterViewDirs;
120
122 Samples patchPoints;
123
125 Samples masterColorSamples;
126
128 std::map<std::size_t, Samples> neighColorSamples;
129 std::map<std::size_t, Samples> neighDerivSamples;
130 std::map<std::size_t, PixelCoords> neighPosSamples;
131
132 std::map<std::size_t, float> stepSize;
133
134 void computePatchPoints();
135 void computeMasterSamples();
136 void computeNeighColorSamples(std::size_t v);
137
138public:
139 std::vector<bool> success;
140};
141
143PatchSampler::create(std::vector<SingleView::Ptr> const& views, Settings const& settings,
144 int x, int y, float depth, float dzI, float dzJ)
145{
147 (views, settings, x, y, depth, dzI, dzJ));
148}
149
150inline Samples const&
151PatchSampler::getMasterColorSamples() const
152{
153 return masterColorSamples;
154}
155
156inline Samples const&
157PatchSampler::getNeighColorSamples(std::size_t v)
158{
159 if (neighColorSamples[v].empty())
160 computeNeighColorSamples(v);
161 return neighColorSamples[v];
162}
163
164inline float
165PatchSampler::getMasterMeanColor() const
166{
167 return masterMeanCol;
168}
169
170inline math::Vec3f const&
171PatchSampler::getMidWorldPoint() const
172{
173 return patchPoints[nrSamples/2];
174}
175
176inline std::size_t
177PatchSampler::getNrSamples() const
178{
179 return nrSamples;
180}
181
182inline float
183PatchSampler::varInMasterPatch()
184{
185 return sqrDevX / (3.f * (float) nrSamples);
186}
187
189
190#endif
Vector class for arbitrary dimensions and types.
Definition vector.h:87
PatchSampler()
Default constructor.
std::vector< bool > success
std::shared_ptr< PatchSampler > Ptr
bool succeeded(std::size_t v) const
#define MVS_NAMESPACE_BEGIN
Definition defines.h:18
#define MVS_NAMESPACE_END
Definition defines.h:19
std::vector< math::Vec3f > Samples
Definition defines.h:25