1 #include "../lib/common.h" 2 #include "../lib/args.h" 3 #include "../lib/viewer.h" 4 #include "../lib/opencv.h" 12 int main(
int argc,
const char* argv[]) {
13 get_args(argc, argv,
"depth.png [min_d max_d] [out.png]");
19 cv::Mat_<ushort> depth = cv::imread(depth_filename, CV_LOAD_IMAGE_ANYDEPTH);
20 bool is16bit = (depth.depth() == CV_16U);
24 if(out_depth_filename.empty() && depth.cols > max_cols) {
25 int new_cols = max_cols;
26 int new_rows = new_cols * depth.rows / depth.cols;
27 cv::resize(depth, depth, cv::Size(new_cols, new_rows));
31 ushort min_value = (is16bit ? 0xffff : 0xff), max_value = 0;
32 for(ushort value : depth) {
33 if(value == 0)
continue;
34 else if(value > max_value) max_value = value;
35 else if(value < min_value) min_value = value;
39 if(out_depth_filename.empty()) {
42 auto& z_near_slider = view.
add_real_slider(
"z near", (z_near_init == -1 ? min_value : z_near_init), min_value, max_value, slider_steps);
43 auto& z_far_slider = view.
add_real_slider(
"z far", (z_far_init == -1 ? max_value : z_near_init), min_value, max_value, slider_steps);
47 real max_d = z_far_slider.value();
49 std::cout <<
"min_d=" << min_d <<
", max_d=" << max_d << std::endl;
52 view.
clear(img.size());
60 cv::imwrite(out_depth_filename, img);
61 std::cout <<
"saved to " << out_depth_filename << std::endl;
real_slider & add_real_slider(const std::string &caption, real default_val, real min_val, real max_val, int steps=100)
long int_opt_arg(long def)
static cv::Mat_< uchar > visualize_depth(const cv::Mat &, float min_d, float max_d)
std::string in_filename_arg()
void draw(const cv::Mat_< cv::Vec3b > &, real blend=1.0)
std::string out_filename_opt_arg(const std::string &def)
void clear(int width, int height)
int main(int argc, const char *argv[])
std::function< void()> update_callback
void get_args(int argc, const char *argv[], const std::string &usage)