licornea_tools
merge_cors.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <fstream>
3 #include <string>
4 #include <cstdlib>
5 #include <stdexcept>
6 #include "../lib/args.h"
7 #include "../lib/json.h"
8 #include "../lib/opencv.h"
10 
11 using namespace tlz;
12 
13 
14 int main(int argc, const char* argv[]) {
15  get_args(argc, argv, "in_cors1.json in_cors2.json out_cors.json");
18  std::string out_cors_filename = out_filename_arg();
19 
20  if(in_cors1.dataset_group != in_cors2.dataset_group)
21  throw std::runtime_error("input cors must have same dataset group");
22 
23  image_correspondences out_cors = in_cors1;
24  for(const auto& kv : in_cors2.features) {
25  const std::string& feature_name = kv.first;
26  const image_correspondence_feature& feature = kv.second;
27 
28  auto existing_it = out_cors.features.find(feature_name);
29  if(existing_it == out_cors.features.end()) {
30  out_cors.features[feature_name] = feature;
31  } else {
32  image_correspondence_feature& existing_feature = existing_it->second;
33  if(existing_feature.reference_view != feature.reference_view)
34  throw std::runtime_error("same name features with different reference views");
35  existing_feature.points.insert(feature.points.begin(), feature.points.end());
36  }
37  }
38 
39  export_image_corresponcences(out_cors, out_cors_filename);
40 }
41 
Set of features, each on set of views.
std::map< std::string, image_correspondence_feature > features
int main(int argc, const char *argv[])
Definition: merge_cors.cc:14
image_correspondences image_correspondences_arg()
std::string out_filename_arg()
Definition: args.cc:104
Feature on set of views. Optionally one view is "reference".
void export_image_corresponcences(const image_correspondences &cors, const std::string &filename)
std::map< view_index, feature_point > points
void get_args(int argc, const char *argv[], const std::string &usage)
Definition: args.cc:49