Skip to content
Browse files

Stereo: Must parse all stereo options

- Must parse all stereo options, even those not used by the individual stereo tools, to avoid incorrect behavior and inconsistency. When printing the help message though, print only the options relevant to the current tool.

- Make variable names more consistent.

Most programs will not be affected, but the API changes a bit.
  • Loading branch information...
1 parent e7c13d0 commit b13931e896ee9f0e6eab37dc752a8c0c937ceb53 @oleg-alexandrov oleg-alexandrov committed Oct 2, 2012
View
2 src/asp/ControlNetTK/cnet_build.cc
@@ -112,7 +112,7 @@ void handle_arguments( int argc, char *argv[], Options& opt ) {
std::string usage("[options] <isis cube files> ...");
po::variables_map vm =
- asp::check_command_line( argc, argv, opt, general_options,
+ asp::check_command_line( argc, argv, opt, general_options, general_options,
positional, positional_desc, usage );
if ( opt.input_names.empty() )
View
2 src/asp/ControlNetTK/cnet_convert.cc
@@ -64,7 +64,7 @@ void handle_arguments( int argc, char *argv[], Options& opt ) {
std::string usage("[options] <cnet_file> <list_of_cameras>");
po::variables_map vm =
- asp::check_command_line( argc, argv, opt, general_options,
+ asp::check_command_line( argc, argv, opt, general_options, general_options,
positional, positional_desc, usage );
opt.convert_isis = vm.count("convert-isis");
View
2 src/asp/ControlNetTK/cnet_merge.cc
@@ -116,7 +116,7 @@ void handle_arguments( int argc, char *argv[], Options& opt ) {
std::string usage("[options] <dest> <source1> ... <sourceN>");
po::variables_map vm =
- asp::check_command_line( argc, argv, opt, general_options,
+ asp::check_command_line( argc, argv, opt, general_options, general_options,
positional, positional_desc, usage );
if ( opt.destination_cnet.empty() )
View
2 src/asp/ControlNetTK/reduce_match.cc
@@ -60,7 +60,7 @@ void handle_arguments( int argc, char *argv[], Options& opt ) {
std::string usage("[options] <match-files> ...");
po::variables_map vm =
- asp::check_command_line( argc, argv, opt, general_options,
+ asp::check_command_line( argc, argv, opt, general_options, general_options,
positional, positional_desc, usage );
if ( opt.match_files.empty() )
View
2 src/asp/ControlNetTK/render_gcp.cc
@@ -62,7 +62,7 @@ void handle_arguments( int argc, char *argv[], Options& opt ) {
std::string usage("[options] <gcp file>");
po::variables_map vm =
- asp::check_command_line( argc, argv, opt, general_options,
+ asp::check_command_line( argc, argv, opt, general_options, general_options,
positional, positional_desc, usage );
if ( opt.gcp_file.empty() )
View
9 src/asp/Core/Common.cc
@@ -75,20 +75,27 @@ asp::BaseOptionsDescription::BaseOptionsDescription( asp::BaseOptions& opt ) {
po::variables_map
asp::check_command_line( int argc, char *argv[], BaseOptions& opt,
po::options_description const& public_options,
+ po::options_description const& all_public_options,
po::options_description const& positional_options,
po::positional_options_description const& positional_desc,
std::string & usage_comment,
bool allow_unregistered ) {
+
// Finish filling in the usage_comment.
std::ostringstream ostr;
ostr << "Usage: " << argv[0] << " " << usage_comment << "\n\n";
ostr << " [ASP " << ASP_VERSION << "]\n\n";
usage_comment = ostr.str();
+ // We distinguish between all_public_options, which is all the
+ // options we must parse, even if we don't need some of them, and
+ // public_options, which are the options specifically used by the
+ // current tool, and for which we also print the help message.
+
po::variables_map vm;
try {
po::options_description all_options;
- all_options.add(public_options).add(positional_options);
+ all_options.add(all_public_options).add(positional_options);
if ( allow_unregistered ) {
po::store( po::command_line_parser( argc, argv ).options(all_options).positional(positional_desc).allow_unregistered().style( po::command_line_style::unix_style ).run(), vm );
View
1 src/asp/Core/Common.h
@@ -57,6 +57,7 @@ namespace asp {
boost::program_options::variables_map
check_command_line( int argc, char *argv[], BaseOptions& opt,
boost::program_options::options_description const& public_options,
+ boost::program_options::options_description const& all_public_options,
boost::program_options::options_description const& positional_options,
boost::program_options::positional_options_description const& positional_desc,
std::string & usage_comment,
View
2 src/asp/Tools/aligndem.cc
@@ -177,7 +177,7 @@ void handle_arguments( int argc, char *argv[], Options& opt ) {
std::string usage("<dem1> <ortho1> <dem2> <ortho2>");
po::variables_map vm =
- asp::check_command_line( argc, argv, opt, general_options,
+ asp::check_command_line( argc, argv, opt, general_options, general_options,
positional, positional_desc, usage );
if ( opt.dem1_name.empty() || opt.dem2_name.empty() ||
View
2 src/asp/Tools/bundle_adjust.cc
@@ -156,7 +156,7 @@ void handle_arguments( int argc, char *argv[], Options& opt ) {
std::string usage("[options] <image filenames> ...");
po::variables_map vm =
- asp::check_command_line(argc, argv, opt, general_options,
+ asp::check_command_line(argc, argv, opt, general_options, general_options,
positional, positional_desc, usage);
if ( opt.image_files.empty() )
View
2 src/asp/Tools/disparitydebug.cc
@@ -67,7 +67,7 @@ void handle_arguments( int argc, char *argv[], Options& opt ) {
std::string usage("[options] <input disparity map>");
po::variables_map vm =
- asp::check_command_line( argc, argv, opt, general_options,
+ asp::check_command_line( argc, argv, opt, general_options, general_options,
positional, positional_desc, usage );
if ( opt.input_file_name.empty() )
View
2 src/asp/Tools/geodiff.cc
@@ -69,7 +69,7 @@ void handle_arguments( int argc, char *argv[], Options& opt ) {
std::string usage("[options] <dem1> <dem2>");
po::variables_map vm =
- asp::check_command_line( argc, argv, opt, general_options,
+ asp::check_command_line( argc, argv, opt, general_options, general_options,
positional, positional_desc, usage );
if ( opt.dem1_name.empty() || opt.dem2_name.empty() )
View
22 src/asp/Tools/hsv_merge.cc
@@ -82,28 +82,28 @@ int main( int argc, char *argv[] ) {
Options opt;
try {
- po::options_description desc("Description: Mimicks hsv_merge.py by Frank Warmerdam and Trent Hare. Use it to combine results from gdaldem.");
- desc.add_options()
+ po::options_description general_options("Description: Mimicks hsv_merge.py by Frank Warmerdam and Trent Hare. Use it to combine results from gdaldem.");
+ general_options.add_options()
("output-file,o", po::value(&opt.output_file), "Specify the output file.");
- desc.add( asp::BaseOptionsDescription(opt) );
+ general_options.add( asp::BaseOptionsDescription(opt) );
- po::options_description hidden("");
- hidden.add_options()
+ po::options_description positional_options("");
+ positional_options.add_options()
("input-rgb", po::value(&opt.input_rgb), "Explicitly specify the input rgb image.")
("input-gray", po::value(&opt.input_gray), "Explicitly specify the input gray image.");
- po::positional_options_description p;
- p.add("input-rgb", 1 );
- p.add("input-gray", 1 );
+ po::positional_options_description positional_desc;
+ positional_desc.add("input-rgb", 1 );
+ positional_desc.add("input-gray", 1 );
std::string usage("[options] <input rgb> <input gray>");
po::variables_map vm =
- asp::check_command_line( argc, argv, opt, desc,
- hidden, p, usage );
+ asp::check_command_line( argc, argv, opt, general_options, general_options,
+ positional_options, positional_desc, usage );
if ( opt.input_rgb.empty() || opt.input_gray.empty() )
vw_throw( ArgumentErr() << "Missing required input files.\n"
- << usage << desc );
+ << usage << general_options );
// Get the input RGB's type
DiskImageResource *rsrc = DiskImageResource::open(opt.input_rgb);
View
2 src/asp/Tools/isis_adjust.cc
@@ -232,7 +232,7 @@ void handle_arguments( int argc, char *argv[], Options& opt ) {
std::string usage("[options] <isis cube files> ...");
po::variables_map vm =
- asp::check_command_line( argc, argv, opt, general_options,
+ asp::check_command_line( argc, argv, opt, general_options, general_options,
positional, positional_desc, usage );
if ( opt.input_names.empty() )
View
2 src/asp/Tools/isis_adjust_camera_err.cc
@@ -60,7 +60,7 @@ void handle_arguments( int argc, char *argv[], Options& opt ) {
std::string usage("<cnet_file> <isis cube files> ...");
po::variables_map vm =
- asp::check_command_line( argc, argv, opt, general_options,
+ asp::check_command_line( argc, argv, opt, general_options, general_options,
positional, positional_desc, usage );
if ( opt.input_names.empty() )
View
2 src/asp/Tools/isis_adjust_cnet_clip.cc
@@ -68,7 +68,7 @@ void handle_arguments( int argc, char *argv[], Options& opt ) {
std::string usage("[options] <cnet_file> <isis cube files> ...");
po::variables_map vm =
- asp::check_command_line( argc, argv, opt, general_options,
+ asp::check_command_line( argc, argv, opt, general_options, general_options,
positional, positional_desc, usage );
if ( opt.input_names.empty() )
View
2 src/asp/Tools/mer2camera.cc
@@ -55,7 +55,7 @@ void handle_arguments( int argc, char *argv[], Options& opt ) {
std::string usage("[options] <img_file>");
po::variables_map vm =
- asp::check_command_line( argc, argv, opt, general_options,
+ asp::check_command_line( argc, argv, opt, general_options, general_options,
positional, positional_desc, usage );
if ( opt.img_file.empty() )
View
2 src/asp/Tools/orbitviz.cc
@@ -87,7 +87,7 @@ void handle_arguments( int argc, char *argv[], Options& opt ) {
std::string usage("[options] <input image> <input camera model> <...and repeat...>\nNote: All cameras and their images must be of the same session type. Camera models only can be used as input for stereo sessions pinhole and isis.");
po::variables_map vm =
- asp::check_command_line( argc, argv, opt, general_options,
+ asp::check_command_line( argc, argv, opt, general_options, general_options,
positional, positional_desc, usage );
// Determining if feed only camera model
View
2 src/asp/Tools/orthoproject.cc
@@ -88,7 +88,7 @@ void handle_arguments( int argc, char *argv[], Options& opt ) {
std::string usage("[options] <dem> <camera-image> <camera-model> <output>");
po::variables_map vm =
- asp::check_command_line( argc, argv, opt, general_options,
+ asp::check_command_line( argc, argv, opt, general_options, general_options,
positional, positional_desc, usage );
if ( opt.dem_file.empty() || opt.image_file.empty() ||
View
2 src/asp/Tools/plateorthoproject.cc
@@ -87,7 +87,7 @@ void handle_arguments(int argc, char *argv[], Options& opt) {
std::string usage("<input-plate> <camera-image> <camera-model> <output-plate> [options]");
po::variables_map vm =
- asp::check_command_line( argc, argv, opt, general_options,
+ asp::check_command_line( argc, argv, opt, general_options, general_options,
hidden_options, p, usage );
if ( opt.input_url.empty() ||
View
2 src/asp/Tools/point2dem.cc
@@ -142,7 +142,7 @@ void handle_arguments( int argc, char *argv[], Options& opt ) {
std::string usage("<point-cloud> ...");
po::variables_map vm =
- asp::check_command_line( argc, argv, opt, general_options,
+ asp::check_command_line( argc, argv, opt, general_options, general_options,
positional, positional_desc, usage );
if ( opt.pointcloud_filename.empty() )
View
2 src/asp/Tools/point2las.cc
@@ -67,7 +67,7 @@ void handle_arguments( int argc, char *argv[], Options& opt ) {
std::string usage("<point-cloud> ...");
po::variables_map vm =
- asp::check_command_line( argc, argv, opt, general_options,
+ asp::check_command_line( argc, argv, opt, general_options, general_options,
positional, positional_desc, usage );
if ( opt.pointcloud_filename.empty() )
View
2 src/asp/Tools/point2mesh.cc
@@ -471,7 +471,7 @@ void handle_arguments( int argc, char *argv[], Options& opt ) {
std::string usage("[options] <pointcloud> <texture-file> ...");
po::variables_map vm =
- asp::check_command_line( argc, argv, opt, general_options,
+ asp::check_command_line( argc, argv, opt, general_options, general_options,
positional, positional_desc, usage );
if ( opt.pointcloud_filename.empty() )
View
2 src/asp/Tools/rmax_adjust.cc
@@ -236,7 +236,7 @@ void handle_arguments( int argc, char *argv[], Options& opt ) {
std::string usage("[options] <rmax image filenames> ...");
po::variables_map vm =
- asp::check_command_line( argc, argv, opt, general_options,
+ asp::check_command_line( argc, argv, opt, general_options, general_options,
hidden_options, p, usage );
if ( opt.image_files.size() < 2)
View
2 src/asp/Tools/rpc_mapproject.cc
@@ -68,7 +68,7 @@ void handle_arguments( int argc, char *argv[], Options& opt ) {
std::string usage("[options] <dem> <camera-image> <camera-model> <output>");
po::variables_map vm =
- asp::check_command_line( argc, argv, opt, general_options,
+ asp::check_command_line( argc, argv, opt, general_options, general_options,
positional, positional_desc, usage );
if ( !vm.count("dem") || !vm.count("camera-image") ||
View
22 src/asp/Tools/stereo.cc
@@ -32,13 +32,27 @@ namespace asp {
void handle_arguments( int argc, char *argv[], Options& opt,
boost::program_options::options_description const&
additional_options ) {
- po::options_description general_options("");
- general_options.add_options()
+
+ po::options_description general_options_sub("");
+ general_options_sub.add_options()
("session-type,t", po::value(&opt.stereo_session_string), "Select the stereo session type to use for processing. [options: pinhole isis dg rpc]")
("stereo-file,s", po::value(&opt.stereo_default_filename)->default_value("./stereo.default"), "Explicitly specify the stereo.default file to use. [default: ./stereo.default]");
+
+ // We distinguish between all_general_options, which is all the
+ // options we must parse, even if we don't need some of them, and
+ // general_options, which are the options specifically used by the
+ // current tool, and for which we also print the help message.
+
+ po::options_description general_options("");
+ general_options.add ( general_options_sub );
general_options.add( additional_options );
general_options.add( asp::BaseOptionsDescription(opt) );
+ po::options_description all_general_options("");
+ all_general_options.add ( general_options_sub );
+ all_general_options.add( generate_config_file_options( opt ) );
+ all_general_options.add( asp::BaseOptionsDescription(opt) );
+
po::options_description positional_options("");
positional_options.add_options()
("left-input-image", po::value(&opt.in_file1), "Left Input Image")
@@ -64,8 +78,8 @@ namespace asp {
std::string usage("[options] <Left_input_image> <Right_input_image> [Left_camera_file] [Right_camera_file] <output_file_prefix> [DEM]\n Extensions are automaticaly added to the output files.\n Camera model arguments may be optional for some stereo session types (e.g. isis).\n Stereo parameters should be set in the stereo.default file.");
po::variables_map vm =
- asp::check_command_line( argc, argv, opt, general_options,
- positional_options, positional_desc, usage, true );
+ asp::check_command_line( argc, argv, opt, general_options, all_general_options,
+ positional_options, positional_desc, usage, false );
// Read the config file
try {

0 comments on commit b13931e

Please sign in to comment.
Something went wrong with that request. Please try again.