From c49a92058415f38909bf323a82313bba7b17cd63 Mon Sep 17 00:00:00 2001 From: Francois Fleuret Date: Mon, 24 Dec 2012 15:02:07 +0100 Subject: [PATCH] Added the --help-formats option. --- mtp.cc | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 4 deletions(-) diff --git a/mtp.cc b/mtp.cc index 5feb2be..300e4a6 100644 --- a/mtp.cc +++ b/mtp.cc @@ -26,6 +26,7 @@ #include #include #include +#include #include using namespace std; @@ -39,17 +40,51 @@ char graph_filename[FILENAME_SIZE]; int verbose; void usage(ostream *os) { - (*os) << "mtp [-h|--help] [-v|--verbose] [-t|--trajectory-filename ] [-g|--graph-filename ] []" << endl; + (*os) << "mtp [-h|--help] [--help-formats] [-v|--verbose] [-t|--trajectory-filename ] [-g|--graph-filename ] []" << endl; (*os) << endl; (*os) << "The mtp command processes a file containing the description of a topology" << endl; (*os) << "and detection scores, and prints the optimal set of trajectories." << endl; - (*os) << "If no filename is provided, it will read the parameters from the stdin." << endl; - (*os) << "If no trajectory filename is provided, it will write the result to" << endl; - (*os) << "stdout." << endl; + (*os) << endl; + (*os) << "If no filename is provided, it reads the parameters from the standard" << endl; + (*os) << "input. If no trajectory filename is provided, it writes the result to" << endl; + (*os) << "the standard output." << endl; (*os) << endl; (*os) << "Written by Francois Fleuret. (C) Idiap Research Institute, 2012." << endl; } +void print_help_formats() { + cout << "The tracking parameters the command takes as input have the following" << endl; + cout << "format, where L is the number of locations and T is the number of time" << endl; + cout << "steps:" << endl; + cout << endl; + cout << "---------------------------- snip snip -------------------------------" << endl; + cout << " int:L int:T" << endl; + cout << endl; + cout << " bool:allowed_motion_from_1_to_1 ... bool:allowed_motion_from_1_to_L" << endl; + cout << " ..." << endl; + cout << " bool:allowed_motion_from_L_to_1 ... bool:allowed_motion_from_L_to_L" << endl; + cout << endl; + cout << " bool:entrance_1_1 ... bool:entrance_1_L" << endl; + cout << " ..." << endl; + cout << " bool:entrance_T_1 ... bool:entrance_T_L" << endl; + cout << endl; + cout << " bool:exit_1_1 ... bool:exit_1_L" << endl; + cout << " ..." << endl; + cout << " bool:exit_T_1 ... bool:exit_T_L" << endl; + cout << endl; + cout << " float:detection_score_1_1 ... float:detection_score_1_L" << endl; + cout << " ..." << endl; + cout << " float:detection_score_T_1 ... float:detection_score_T_L" << endl; + cout << "---------------------------- snip snip -------------------------------" << endl; + cout << endl; + cout << "As results, the command writes first the number of trajectories," << endl; + cout << "followed by one line per trajectory with the following structure:" << endl; + cout << endl; + cout << "---------------------------- snip snip -------------------------------" << endl; + cout << " int:traj_number int:entrance_time int:duration float:score int:location_1 ... int:location_duration" << endl; + cout << "---------------------------- snip snip -------------------------------" << endl; +} + scalar_t diff_in_second(struct timeval *start, struct timeval *end) { return scalar_t(end->tv_sec - start->tv_sec) + @@ -100,11 +135,17 @@ void do_tracking(istream *in_tracker) { delete tracker; } +enum +{ + OPT_HELP_FORMATS = CHAR_MAX + 1 +}; + static struct option long_options[] = { { "trajectory-file", 1, 0, 't' }, { "graph-file", 1, 0, 'g' }, { "help", no_argument, 0, 'h' }, { "verbose", no_argument, 0, 'v' }, + { "help-formats", no_argument, 0, OPT_HELP_FORMATS }, { 0, 0, 0, 0 } }; @@ -133,6 +174,11 @@ int main(int argc, char **argv) { show_help = 1; break; + case OPT_HELP_FORMATS: + print_help_formats(); + exit(EXIT_SUCCESS); + break; + case 'v': verbose = 1; break; -- 2.39.5