[8db413]: contrib / brl / bbas / bwm / pro / processes / bwm_create_satellite_site_process.cxx Maximize Restore History

Download this file

bwm_create_satellite_site_process.cxx    136 lines (106 with data), 4.1 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
//This is brl/bbas/bwm/pro/processes/bwm_create_satellite_site_process.cxx
//:
// \file
#include <bprb/bprb_func_process.h>
#include <bprb/bprb_parameters.h>
#include <vcl_string.h>
#include <vcl_iostream.h>
#include <vcl_cstdio.h> // for std::FILE and std::fopen()
#include <brdb/brdb_value.h>
#include <bwm/algo/bwm_satellite_resources.h>
#include <bwm/algo/bwm_satellite_resources_sptr.h>
#include <bwm/io/bwm_site_sptr.h>
#include <bwm/io/bwm_site.h>
#include <bwm/io/bwm_io_config_parser.h>
//: sets input and output types
bool bwm_create_satellite_resources_process_cons(bprb_func_process& pro)
{
//inputs
vcl_vector<vcl_string> input_types_(5);
input_types_[0] = "vcl_string"; // folder -- will be traversed recursively to find NITF files and create the resources
input_types_[1] = "double"; // lower left corner latitude
input_types_[2] = "double"; // lower left corner longitude
input_types_[3] = "double"; // upper right corner latitude
input_types_[4] = "double"; // upper right corner longitude
if (!pro.set_input_types(input_types_))
return false;
//output
vcl_vector<vcl_string> output_types_(1);
output_types_[0] = "bwm_satellite_resources_sptr";
return pro.set_output_types(output_types_);
}
bool bwm_create_satellite_resources_process(bprb_func_process& pro)
{
//check number of inputs
if (!pro.verify_inputs())
{
vcl_cout << pro.name() << " invalid inputs" << vcl_endl;
return false;
}
//get the inputs
vcl_string folder = pro.get_input<vcl_string>(0);
double lower_left_lat = pro.get_input<double>(1);
double lower_left_lon = pro.get_input<double>(2);
double upper_right_lat = pro.get_input<double>(3);
double upper_right_lon = pro.get_input<double>(4);
bwm_satellite_resources_sptr res = new bwm_satellite_resources(folder, lower_left_lat, lower_left_lon,
upper_right_lat, upper_right_lon);
return true;
}
/*
//: sets input and output types
bool bwm_create_satellite_site_process_cons(bprb_func_process& pro)
{
//inputs
vcl_vector<vcl_string> input_types_(4);
if (!pro.set_input_types(input_types_))
return false;
//output
vcl_vector<vcl_string> output_types_(0);
return pro.set_output_types(output_types_);
}
bool bwm_create_satellite_site_process(bprb_func_process& pro)
{
//check number of inputs
if (!pro.verify_inputs())
{
vcl_cout << pro.name() << " invalid inputs" << vcl_endl;
return false;
}
//get the inputs
vcl_string file_name = pro.get_input<vcl_string>(0);
bwm_site_sptr site = parser->site();
vcl_vector<vcl_vector<vcl_pair<vcl_string, vsol_point_2d> > > site_correspondences = site->corresp_;
if (!site_correspondences.size() || !site_correspondences[0].size()) {
vcl_cout << "The file: " << site_file << " does not contain any correspondences, returning!\n";
return true;
}
corr_cnt = corr_cnt > (int)site_correspondences.size() ? (int)site_correspondences.size() : corr_cnt;
// first open corr_file in read mode, see if it already contains any corrs
vcl_ifstream corr_file_r(file_name.c_str(), vcl_ios::in);
if (!corr_file_r) {
vcl_ofstream corr_file(file_name.c_str(), vcl_ios::out);
corr_file << corr_cnt << '\n';
corr_file.close();
}
else
corr_file_r.close();
// now open corr_file in append mode
vcl_ofstream corr_file(file_name.c_str(), vcl_ios::app);
if (!corr_file) {
vcl_cout << "error in opening: " << file_name << vcl_endl;
return false;
}
// now turn the corrs into the format: <cam name> corr1 x corr1 y corr2x corr2y ...
int cam_size = site_correspondences[0].size();
for (int j = 0; j < cam_size; j++) {
corr_file << site->path_ << "\\cameras\\" << site_correspondences[0][j].first << ".RPB ";
for (int i = 0; i < corr_cnt; i++) {
corr_file << site_correspondences[i][j].second.x() << ' ' << site_correspondences[i][j].second.y() << ' ';
}
corr_file << '\n';
}
corr_file.close();
return true;
}
*/