MCPcopy Create free account
hub / github.com/PlotJuggler/PlotJuggler / buildFastRectifyMap

Function buildFastRectifyMap

pj_scene2D/core/src/undistort_remap.cpp:177–212  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

175}
176
177UndistortMapFast buildFastRectifyMap(const UndistortMap& map) {
178 UndistortMapFast fast;
179 if (!map.valid() || map.src_width <= 0 || map.src_height <= 0) {
180 return fast; // invalid -> caller treats as "do not rectify".
181 }
182 fast.out_width = map.out_width;
183 fast.out_height = map.out_height;
184 fast.src_width = map.src_width;
185 fast.src_height = map.src_height;
186
187 const int sw = map.src_width;
188 const int sh = map.src_height;
189 const auto n = static_cast<size_t>(map.out_width) * static_cast<size_t>(map.out_height);
190 fast.src_p0.resize(n);
191 fast.frac_x.resize(n);
192 fast.frac_y.resize(n);
193
194 for (size_t i = 0; i < n; ++i) {
195 const float fx = map.src_x[i];
196 const float fy = map.src_y[i];
197 if (!bilinearTapInBounds(fx, fy, sw, sh)) {
198 fast.src_p0[i] = -1;
199 fast.frac_x[i] = 0.0F;
200 fast.frac_y[i] = 0.0F;
201 continue;
202 }
203 const float x0f = std::floor(fx);
204 const float y0f = std::floor(fy);
205 const int x0 = static_cast<int>(x0f);
206 const int y0 = static_cast<int>(y0f);
207 fast.src_p0[i] = y0 * sw + x0; // linear pixel index; rectifyFrameFast scales by channels.
208 fast.frac_x[i] = fx - x0f;
209 fast.frac_y[i] = fy - y0f;
210 }
211 return fast;
212}
213
214std::vector<float> undistortMapToNormalizedRG(const UndistortMap& map) {
215 std::vector<float> rg;

Callers 2

rectifyIfCalibratedMethod · 0.85
TESTFunction · 0.85

Calls 3

bilinearTapInBoundsFunction · 0.85
validMethod · 0.45
resizeMethod · 0.45

Tested by 1

TESTFunction · 0.68