Elaboradar  0.1
 Tutto Classi Namespace File Funzioni Variabili Tipi enumerati (enum) Gruppi
template<typename T >
void radarelab::ScaledIndexMapping::to_cart_average ( const PolarScan< double > &  src,
std::function< T(const std::vector< double > &)> &  convert,
Matrix2D< T > &  dst 
) const
inline

Fill the cartesian map dst with the output of the function src(azimuth, range)

Definizione alla linea 186 del file cart.h.

Referenzia radarelab::PolarScanBase::beam_count, radarelab::CoordinateMapping::beam_size, radarelab::PolarScanBase::beam_size, image_offset, e radarelab::CoordinateMapping::sample().

187  {
188  // In case dst is not a square with side beam_size*2, center it
189  int dx = ((int)width - dst.cols()) / 2;
190  int dy = ((int)height - dst.rows()) / 2;
191  std::vector<double> samples;
192 
193  for (unsigned y = 0; y < dst.rows(); ++y)
194  {
195  if (y + dy < 0 || y + dy >= height) continue;
196 
197  for (unsigned x = 0; x < dst.cols(); ++x)
198  {
199  if (x + dx < 0 || x + dx >= width) continue;
200 
201  samples.clear();
202  std::function<void(unsigned, unsigned)> compute_average = [&samples, &src](unsigned azimuth, unsigned range) {
203  if (azimuth < 0 || azimuth > src.beam_count) return;
204  if (range < 0 || range > src.beam_size) return;
205  samples.push_back(src(azimuth, range));
206  };
207 
208  for(unsigned sy = 0; sy < fullsize_pixels_per_scaled_pixel; ++sy)
209  for(unsigned sx = 0; sx < fullsize_pixels_per_scaled_pixel; ++sx)
210  {
211  int src_x = x * fullsize_pixels_per_scaled_pixel + sx + image_offset;
212  int src_y = y * fullsize_pixels_per_scaled_pixel + sy + image_offset;
213  if (src_x < 0 || src_x >= mapping.beam_size * 2 || src_y < 0 || src_y >= mapping.beam_size * 2)
214  continue;
215  mapping.sample(src.beam_count, src_x, src_y, compute_average);
216  }
217 
218  if (!samples.empty())
219  dst(y + dy, x + dx) = convert(samples);
220  }
221  }
222  }
const unsigned beam_size
Beam size of the volume that we are mapping to cartesian coordinates.
Definition: cart.h:24
int image_offset
Image offset in full size pixels.
Definition: cart.h:167
void sample(unsigned beam_count, unsigned x, unsigned y, std::function< void(unsigned, unsigned)> &f) const
Generate all the (azimuth, range) indices corresponding to a map point.
Definition: cart.cpp:44