licornea_tools
depth_densify_fast.cc
Go to the documentation of this file.
1 #include "depth_densify_fast.h"
2 #include "../common.h"
3 #include <vector>
4 #include <algorithm>
5 
6 namespace tlz {
7 
8 
9 void depth_densify_fast::densify(const std::vector<sample>& samples, cv::Mat_<real>& out, cv::Mat_<uchar>& out_mask) {
10  const real scaledown = 0.3;
11  cv::Size scaled_size(scaledown * texture_width, scaledown * texture_height);
12 
13  cv::Mat_<real> scaled_out(scaled_size);
14  scaled_out.setTo(0.0);
15 
16  for(const sample& samp : samples) {
17  int scaled_x = scaledown * samp.color_coordinates[0];
18  int scaled_y = scaledown * samp.color_coordinates[1];
19  if(scaled_x < 0 || scaled_x >= scaled_size.width || scaled_y < 0 || scaled_y >= scaled_size.height) continue;
20 
21  real new_d = samp.color_depth;
22  real& d = scaled_out(scaled_y, scaled_x);
23  if(d == 0.0 || new_d < d) d = new_d;
24  }
25 
26  cv::resize(scaled_out, out, cv::Size(texture_width, texture_height), 0.0, 0.0, cv::INTER_NEAREST);
27  out_mask = (out != 0.0);
28 }
29 
30 }
constexpr std::size_t texture_height
Definition: common.h:13
void densify(const std::vector< sample > &samples, cv::Mat_< real > &out, cv::Mat_< uchar > &out_mask) override
constexpr std::size_t texture_width
Definition: common.h:12
double real
Definition: common.h:16