7 #include "../lib/args.h" 8 #include "../lib/json.h" 9 #include "../lib/filesystem.h" 10 #include "../lib/dataset.h" 11 #include "../lib/image_io.h" 19 int main(
int argc,
const char* argv[]) {
20 get_args(argc, argv,
"dataset_parameters.json horiz_key vert_key out_refgrid.json [dataset_group]");
29 auto column_exists = [&](
int x) {
38 std::cout <<
"determining X coordinates of reference views" << std::endl;
41 std::deque<int> reference_x_positions;
42 for(
int x = datas.
x_mid() - horizontal_key; x >= datas.
x_min(); x -= horizontal_key) reference_x_positions.push_front(x);
43 reference_x_positions.push_back(datas.
x_mid());
44 for(
int x = datas.
x_mid() + horizontal_key; x <= datas.
x_max(); x += horizontal_key) reference_x_positions.push_back(x);
45 auto reference_x_valid = [&](
int x) {
46 return datas.
x_valid(x) && column_exists(x);
48 for(
int& x : reference_x_positions) {
49 if(reference_x_valid(x))
continue;
52 if(reference_x_valid(x + diff)) { x += diff; ok =
true; }
53 if(reference_x_valid(x - diff)) { x -= diff; ok =
true; }
56 throw std::runtime_error(
"could not find valid X coordinate near " +
std::to_string(x) +
" for reference view");
60 std::cout <<
"determining Y coordinates of reference views" << std::endl;
61 std::deque<int> reference_y_positions;
62 for(
int y = datas.
y_mid() - vertical_key; y >= datas.
y_min(); y -= vertical_key) reference_y_positions.push_front(y);
63 reference_y_positions.push_back(datas.
y_mid());
64 for(
int y = datas.
y_mid() + vertical_key; y <= datas.
y_max(); y += vertical_key) reference_y_positions.push_back(y);
66 std::cout <<
"saving reference grid" << std::endl;
68 grid.
x_indices.assign(reference_x_positions.begin(), reference_x_positions.end());
69 grid.
y_indices.assign(reference_y_positions.begin(), reference_y_positions.end());
bool file_exists(const std::string &filename)
std::string image_filename() const
dataset_view view(int x) const
bool x_valid(int x) const
const int max_reference_x_deviation
json encode_references_grid(const references_grid &grid)
std::vector< int > y_indices
void export_json_file(const json &j, const std::string &filename, bool compact)
std::vector< int > x_indices
std::string to_string(const T &)
std::string out_filename_arg()
dataset_group group(const std::string &grp) const
int main(int argc, const char *argv[])
const dataset & set() const
std::string string_opt_arg(const std::string &def="")
void get_args(int argc, const char *argv[], const std::string &usage)