Skip to content

Commit

Permalink
Update ControlNetTK to use Common.h
Browse files Browse the repository at this point in the history
Standards! Hooray!
  • Loading branch information
Zack Moratto committed Apr 13, 2011
1 parent c6be86f commit 707a679
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 69 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -127,6 +127,7 @@ src/asp/ControlNetTK/cnet_build
src/asp/ControlNetTK/cnet_convert
src/asp/ControlNetTK/cnet_merge
src/asp/ControlNetTK/isis_position_extract
src/asp/ControlNetTK/render_gcp

# Data
data/MOC/*cub
Expand Down
25 changes: 8 additions & 17 deletions src/asp/ControlNetTK/cnet_build.cc
Expand Up @@ -12,6 +12,7 @@ using namespace vw;
using namespace vw::ba;

#include <asp/Core/Macros.h>
#include <asp/Core/Common.h>
#include <asp/IsisIO/IsisCameraModel.h>
#include <asp/IsisIO/IsisAdjustCameraModel.h>
using namespace vw::camera;
Expand Down Expand Up @@ -60,7 +61,7 @@ void sort_out_gcpcnets( IContainT& input, OContainT& output ) {
input.erase(new_end,input.end());
}

struct Options {
struct Options : public asp::BaseOptions {
// Input
std::vector<std::string> input_names, gcp_names,
gcp_cnet_names, serial_names;
Expand All @@ -79,8 +80,8 @@ void handle_arguments( int argc, char *argv[], Options& opt ) {
("t,type-of-cnet", po::value(&opt.cnet_output_type)->default_value("binary"), "Types of cnets are [binary,isis]")
("isis-adjust", po::bool_switch(&opt.isis_adjust)->default_value(false),
"Use isis_adjust camera models for triangulation")
("min-matches", po::value(&opt.min_matches)->default_value(5))
("help,h", "Display this help message");
("min-matches", po::value(&opt.min_matches)->default_value(5));
general_options.add( asp::BaseOptionsDescription(opt) );

po::options_description positional("");
positional.add_options()
Expand All @@ -89,23 +90,13 @@ void handle_arguments( int argc, char *argv[], Options& opt ) {
po::positional_options_description positional_desc;
positional_desc.add("input-files", -1);

po::options_description all_options;
all_options.add(general_options).add(positional);

po::variables_map vm;
try {
po::store( po::command_line_parser( argc, argv ).options(all_options).positional(positional_desc).run(), vm );
po::notify( vm );
} catch (po::error &e ) {
vw_throw( ArgumentErr() << "Error parsing input:\n\t"
<< e.what() << general_options );
}

std::ostringstream usage;
usage << "Usage: " << argv[0] << " [options] <isis cube files> ...\n";

if ( vm.count("help") )
vw_throw( ArgumentErr() << usage.str() << general_options );
po::variables_map vm =
asp::check_command_line( argc, argv, opt, general_options,
positional, positional_desc, usage.str() );

if ( opt.input_names.empty() )
vw_throw( ArgumentErr() << "Missing input cube files!\n"
<< usage.str() << general_options );
Expand Down
25 changes: 8 additions & 17 deletions src/asp/ControlNetTK/cnet_convert.cc
Expand Up @@ -19,10 +19,11 @@ namespace fs = boost::filesystem;

#include <asp/IsisIO/IsisCameraModel.h>
#include <asp/Core/Macros.h>
#include <asp/Core/Common.h>

#include <fstream>

struct Options {
struct Options : public asp::BaseOptions {
// Input
std::string cnet_file;
std::string camera_list_file;
Expand All @@ -37,8 +38,8 @@ void handle_arguments( int argc, char *argv[], Options& opt ) {
po::options_description general_options("");
general_options.add_options()
("convert-serial-to-name", "Convert the serial numbers in cnet to filenames.")
("output-prefix,o", po::value(&opt.output_prefix)->default_value("converted"), "Output prefix for new control network.")
("help,h", "Display this help message");
("output-prefix,o", po::value(&opt.output_prefix)->default_value("converted"), "Output prefix for new control network.");
general_options.add( asp::BaseOptionsDescription(opt) );

po::options_description positional("");
positional.add_options()
Expand All @@ -49,26 +50,16 @@ void handle_arguments( int argc, char *argv[], Options& opt ) {
positional_desc.add("cnet-file", 1 );
positional_desc.add("camera-list-file", 1 );

po::options_description all_options;
all_options.add(general_options).add(positional);

po::variables_map vm;
try {
po::store( po::command_line_parser( argc, argv ).options(all_options).positional(positional_desc).run(), vm );
po::notify( vm );
} catch (po::error &e) {
vw_throw( ArgumentErr() << "Error parsing input:\n\t"
<< e.what() << general_options );
}

std::ostringstream usage;
usage << "Usage: " << argv[0] << " [options] <cnet_file> <list_of_cameras>\n";

po::variables_map vm =
asp::check_command_line( argc, argv, opt, general_options,
positional, positional_desc, usage.str() );

opt.convert_isis = vm.count("convert-isis");
opt.convert_serial_to_name = vm.count("convert-serial-to-name");

if ( vm.count("help") )
vw_throw( ArgumentErr() << usage.str() << general_options );
if ( !vm.count("cnet-file") )
vw_throw( ArgumentErr() << "Missing required input file.\n"
<< usage.str() << general_options );
Expand Down
25 changes: 8 additions & 17 deletions src/asp/ControlNetTK/cnet_merge.cc
Expand Up @@ -20,6 +20,7 @@ namespace fs = boost::filesystem;

#include <asp/IsisIO/IsisCameraModel.h>
#include <asp/Core/Macros.h>
#include <asp/Core/Common.h>

size_t find_destination_index( int const& source_idx,
std::map<int,std::string> const& src_map,
Expand Down Expand Up @@ -72,7 +73,7 @@ struct ContainsCloseMeasure {
}
};

struct Options {
struct Options : public asp::BaseOptions {
// Input
std::string destination_cnet;
std::vector<std::string> source_cnets;
Expand All @@ -89,8 +90,8 @@ void handle_arguments( int argc, char *argv[], Options& opt ) {
("output-prefix,o", po::value(&opt.output_prefix)->default_value("merged"),
"Output prefix for merge control network.")
("close-px", po::value(&opt.close)->default_value(-1),
"Merge measurements are that are this pixel close. Leave -1 to only merge exact measurements." )
("help,h", "Display this help message");
"Merge measurements are that are this pixel close. Leave -1 to only merge exact measurements." );
general_options.add( asp::BaseOptionsDescription(opt) );

po::options_description positional("");
positional.add_options()
Expand All @@ -101,23 +102,13 @@ void handle_arguments( int argc, char *argv[], Options& opt ) {
positional_desc.add("dest-cnet", 1 );
positional_desc.add("source-cnets", -1 );

po::options_description all_options;
all_options.add(general_options).add(positional);

po::variables_map vm;
try {
po::store( po::command_line_parser( argc, argv ).options(all_options).positional(positional_desc).run(), vm );
po::notify( vm );
} catch (po::error &e) {
vw_throw( ArgumentErr() << "Error parsing input:\n\t"
<< e.what() << general_options );
}

std::ostringstream usage;
usage << "Usage: " << argv[0] << " [options] <dest> <source1> ... <sourceN>\n";

if ( vm.count("help") )
vw_throw( ArgumentErr() << usage.str() << general_options );
po::variables_map vm =
asp::check_command_line( argc, argv, opt, general_options,
positional, positional_desc, usage.str() );

if ( opt.destination_cnet.empty() )
vw_throw( ArgumentErr() << "Missing destination cnets.\n"
<< usage.str() << general_options );
Expand Down
2 changes: 1 addition & 1 deletion src/asp/ControlNetTK/isis_position_extract.cc
Expand Up @@ -4,7 +4,7 @@
#include <asp/IsisIO/IsisCameraModel.h>
#include <asp/IsisIO/IsisAdjustCameraModel.h>

// This executable is not meant to be used by people directory. This
// This executable is not meant to be used by people directly. This
// is a helper utility for pairlist_degree.py

using namespace vw;
Expand Down
26 changes: 9 additions & 17 deletions src/asp/ControlNetTK/reduce_match.cc
Expand Up @@ -18,9 +18,10 @@ using namespace vw;
// Stereo Pipeline
#include <asp/ControlNetTK/Equalization.h>
#include <asp/Core/Macros.h>
#include <asp/Core/Common.h>
using namespace asp;

struct Options {
struct Options : public asp::BaseOptions {
std::vector<std::string> match_files;
size_t max_points, min_points;
};
Expand All @@ -29,8 +30,8 @@ void handle_arguments( int argc, char *argv[], Options& opt ) {
po::options_description general_options("");
general_options.add_options()
("max-pts,m",po::value(&opt.max_points)->default_value(100),"Max points a pair can have. If it execeeds we trim.")
("min-pts,n",po::value(&opt.min_points)->default_value(10),"Minimum points a pair is required to have. Delete if fails this.")
("help,h", "Display this help message");
("min-pts,n",po::value(&opt.min_points)->default_value(10),"Minimum points a pair is required to have. Delete if fails this.");
general_options.add( asp::BaseOptionsDescription(opt) );

po::options_description positional("");
positional.add_options()
Expand All @@ -39,22 +40,13 @@ void handle_arguments( int argc, char *argv[], Options& opt ) {
po::positional_options_description positional_desc;
positional_desc.add("input-files", -1);

po::options_description all_options;
all_options.add(general_options).add(positional);

po::variables_map vm;
try {
po::store( po::command_line_parser( argc, argv ).options(all_options).positional(positional_desc).run(), vm );
po::notify( vm );
} catch (po::error &e ) {
vw_throw( ArgumentErr() << "Error parsing input:\n\t"
<< e.what() << general_options );
}

std::ostringstream usage;
usage << "Usage: " << argv[0] << " [options] <match-files> ...\n\n";
if ( vm.count("help") )
vw_throw( ArgumentErr() << usage.str() << general_options );

po::variables_map vm =
asp::check_command_line( argc, argv, opt, general_options,
positional, positional_desc, usage.str() );

if ( opt.match_files.empty() )
vw_throw( ArgumentErr() << "Must specify at least one input file!\n\n" << usage.str() );
}
Expand Down

0 comments on commit 707a679

Please sign in to comment.