1 #include "../lib/args.h" 2 #include "../lib/opencv.h" 3 #include "../lib/intrinsics.h" 4 #include "../lib/dataset.h" 5 #include "../lib/misc.h" 6 #include "../lib/image_io.h" 7 #include "../lib/viewer.h" 8 #include "../lib/string.h" 9 #include "../lib/random_color.h" 10 #include "../lib/filesystem.h" 11 #include "../lib/image_io.h" 22 int main(
int argc,
const char* argv[]) {
23 get_args(argc, argv,
"dataset_parameters.json cors.json closeup? [dataset_group]");
33 viewer view(
"Image Correspondences Viewer", sz,
true);
36 std::vector<std::string> feature_names(feature_names_s.begin(), feature_names_s.end());
38 auto& feature_slider = view.
add_int_slider(
"feature", 0, 0, feature_names.size()-1);
41 auto& depth_opacity_slider = view.
add_real_slider(
"depth op", 0.0, 0.0, 1.0);
44 auto& dots_opacity_slider = view.
add_real_slider(
"dots op", 0.5, 0, 1.0);
49 if(! datas.
valid(idx))
return;
51 const std::string& feature_name = feature_names.at(feature_slider);
56 cv::Mat_<cv::Vec3b> img;
61 cv::Mat_<uchar> gray_img = cv::imread(image_filename, CV_LOAD_IMAGE_GRAYSCALE);
62 if(gray_img.empty()) {
67 if(depth_opacity_slider > 0.0 &&
file_exists(depth_filename)) {
68 cv::Mat_<ushort> depth_img =
load_depth(depth_filename);
70 cv::addWeighted(gray_img, 1.0-depth_opacity_slider, viz_depth_img, depth_opacity_slider, 0.0, gray_img);
73 cv::cvtColor(gray_img, img, CV_GRAY2BGR);
81 view.
draw(cv::Rect(0, 0, sz.width, sz.height), img);
84 view.
draw(cv::Point(0, 0), img);
86 }
catch(
const std::exception&) {
return; }
real_slider & add_real_slider(const std::string &caption, real default_val, real min_val, real max_val, int steps=100)
cv::Mat_< cv::Vec3b > visualize_view_points(const image_correspondence_feature &feature, const cv::Mat_< cv::Vec3b > &back_img, const cv::Vec3b &col, int dot_radius, const border &bord)
cv::Size image_size_with_border() const
bool file_exists(const std::string &filename)
static cv::Mat_< uchar > visualize_depth(const cv::Mat &, float min_d, float max_d)
std::string image_filename() const
cv::Mat_< cv::Vec3b > visualize_view_points_closeup(const image_correspondence_feature &feature, const cv::Mat_< cv::Vec3b > &img, const cv::Vec3b &col, const view_index &ref_idx, real dots_opacity, const border &bord)
void draw(const cv::Mat_< cv::Vec3b > &, real blend=1.0)
border image_border() const
Set of features, each on set of views.
cv::Mat_< ushort > load_depth(const std::string &filename)
dataset_view view(int x) const
cv::Vec3b random_color(int i)
bool valid(view_index) const
std::string depth_filename() const
std::map< std::string, image_correspondence_feature > features
std::string dataset_group
std::vector< std::string > get_feature_names(const image_correspondences &cors)
image_correspondences image_correspondences_arg()
int string_hash(const std::string &str)
std::string to_string(const T &)
Feature on set of views. Optionally one view is "reference".
void draw_text(cv::Rect rect, const std::string &text, text_alignment=left)
int_slider & add_int_slider(const std::string &caption, int default_val, int min_val, int max_val, int step=1)
bool bool_opt_arg(const std::string &expected, bool def=false)
void clear(int width, int height)
int main(int argc, const char *argv[])
dataset_group group(const std::string &grp) const
std::function< void()> update_callback
std::string string_opt_arg(const std::string &def="")
void get_args(int argc, const char *argv[], const std::string &usage)