licornea_tools
depth_densify_splat.cc
Go to the documentation of this file.
1 #include "depth_densify_splat.h"
2 #include "../common.h"
3 #include <vector>
4 #include <algorithm>
5 
6 namespace tlz {
7 
8 
9 void depth_densify_splat::densify(const std::vector<sample>& orig_samples, cv::Mat_<real>& out, cv::Mat_<uchar>& out_mask) {
10  out = cv::Mat_<real>(texture_height, texture_width);
11  out_mask = cv::Mat_<uchar>(texture_height, texture_width);
12 
13  std::vector<sample> samples = orig_samples;
14  auto cmp = [](const sample& a, const sample& b) { return (a.color_depth > b.color_depth); };
15  std::sort(samples.begin(), samples.end(), cmp);
16 
17  out.setTo(0.0);
18  out_mask.setTo(0);
19 
20  int rad = 4;
21  for(const sample& samp : samples) {
22  int sx = samp.color_coordinates[0], sy = samp.color_coordinates[1];
23  if(sx < 0 || sx >= texture_width || sy < 0 || sy >= texture_height) continue;
24 
25  real new_d = samp.color_depth;
26 
27  cv::circle(out, cv::Point(sx, sy), rad, new_d, -1);
28  cv::circle(out_mask, cv::Point(sx, sy), rad, 0xff, -1);
29  }
30 
31  std::cout << "done" << std::endl;
32 }
33 
34 }
constexpr std::size_t texture_height
Definition: common.h:13
constexpr std::size_t texture_width
Definition: common.h:12
void densify(const std::vector< sample > &samples, cv::Mat_< real > &out, cv::Mat_< uchar > &out_mask) override
double real
Definition: common.h:16