12 #include "../lib/args.h" 13 #include "../lib/misc.h" 14 #include "../lib/dataset.h" 15 #include "../lib/image_io.h" 16 #include "../lib/json.h" 17 #include "../lib/opencv.h" 18 #include "../lib/filesystem.h" 22 int main(
int argc,
const char* argv[]) {
23 get_args(argc, argv,
"dataset_parameters.json in_cors.json out_cors.json [xy_outreach=0] [step=1]");
30 std::cout <<
"for each view, reading feature depths" << std::endl;
34 std::atomic<int> counter(0);
35 #pragma omp parallel for 36 for(std::ptrdiff_t i = 0; i < views.size(); ++i) {
38 if(i % step != 0)
continue;
44 cv::Mat_<ushort> depth =
load_depth(depth_filename);
48 const std::string& feature_name = kv.first;
49 auto& fpoints = kv.second.points;
50 if(fpoints.find(view_idx) == fpoints.end())
continue;
55 if(xy_outreach == 0) {
56 if(x < 0 || x >= depth.cols || y < 0 || y >= depth.rows)
continue;
57 ushort depth_value = depth(y, x);
58 if(depth_value != 0) fpoint.
depth = depth_value;
61 ushort min_depth_value = std::numeric_limits<ushort>::max();
62 for(
int y_ = y - xy_outreach; y_ <= y + xy_outreach; y_++)
63 for(
int x_ = x - xy_outreach; x_ <= x + xy_outreach; x_++) {
64 if(x_ < 0 || x_ >= depth.cols || y_ < 0 || y_ >= depth.rows)
continue;
65 ushort depth_value = depth(y, x);
66 if(depth_value < min_depth_value) min_depth_value = depth_value;
68 if(min_depth_value != 0) fpoint.
depth = min_depth_value;
73 std::cout <<
'.' << std::flush;
75 if(counter/step % 1000 == 0) {
77 std::cout <<
'\n' << counter <<
" of " << views.size() << std::endl;
81 std::cout <<
"saving correspondences with depths" << std::endl;
long int_opt_arg(long def)
bool file_exists(const std::string &filename)
std::vector< view_index > get_all_views(const image_correspondences &cors)
Set of features, each on set of views.
cv::Mat_< ushort > load_depth(const std::string &filename)
dataset_view view(int x) const
std::string depth_filename() const
std::map< std::string, image_correspondence_feature > features
int main(int argc, const char *argv[])
image_correspondences image_correspondences_arg()
std::string out_filename_arg()
void export_image_corresponcences(const image_correspondences &cors, const std::string &filename)
void get_args(int argc, const char *argv[], const std::string &usage)