#define FILENAME_SIZE 1024
-char trajectory_filename[FILENAME_SIZE];
-char graph_filename[FILENAME_SIZE];
-int verbose;
+struct Global {
+ char trajectory_filename[FILENAME_SIZE];
+ char graph_filename[FILENAME_SIZE];
+ int verbose;
+} global;
void usage(ostream *os) {
(*os) << "mtp [-h|--help] [--help-formats] [-v|--verbose] [-t|--trajectory-filename <trajectory filename>] [-g|--graph-filename <graph filename>] [<tracking parameter file>]" << endl;
timeval start_time, end_time;
MTPTracker *tracker = new MTPTracker();
- if(verbose) { cout << "Reading the tracking parameters." << endl; }
+ if(global.verbose) { cout << "Reading the tracking parameters." << endl; }
tracker->read(in_tracker);
- if(verbose) {
+ if(global.verbose) {
cout << "Building the graph ... "; cout.flush();
gettimeofday(&start_time, 0);
}
tracker->build_graph();
- if(verbose) {
+ if(global.verbose) {
gettimeofday(&end_time, 0);
cout << "done (" << diff_in_second(&start_time, &end_time) << "s)." << endl;
}
- if(verbose) {
+ if(global.verbose) {
cout << "Tracking ... "; cout.flush();
gettimeofday(&start_time, 0);
}
tracker->track();
- if(verbose) {
+ if(global.verbose) {
gettimeofday(&end_time, 0);
cout << "done (" << diff_in_second(&start_time, &end_time) << "s)." << endl;
}
- if(strcmp(trajectory_filename, "")) {
- ofstream out_traj(trajectory_filename);
+ if(strcmp(global.trajectory_filename, "")) {
+ ofstream out_traj(global.trajectory_filename);
tracker->write_trajectories(&out_traj);
- if(verbose) { cout << "Wrote " << trajectory_filename << "." << endl; }
+ if(global.verbose) { cout << "Wrote " << global.trajectory_filename << "." << endl; }
} else {
tracker->write_trajectories(&cout);
}
- if(strcmp(graph_filename, "") != 0) {
- ofstream out_dot(graph_filename);
+ if(strcmp(global.graph_filename, "") != 0) {
+ ofstream out_dot(global.graph_filename);
tracker->print_graph_dot(&out_dot);
- if(verbose) { cout << "Wrote " << graph_filename << "." << endl; }
+ if(global.verbose) { cout << "Wrote " << global.graph_filename << "." << endl; }
}
delete tracker;
int c;
int error = 0, show_help = 0;
- strncpy(trajectory_filename, "", FILENAME_SIZE);
- strncpy(graph_filename, "", FILENAME_SIZE);
- verbose = 0;
+ strncpy(global.trajectory_filename, "", FILENAME_SIZE);
+ strncpy(global.graph_filename, "", FILENAME_SIZE);
+ global.verbose = 0;
- while ((c = getopt_long(argc, argv, "t:g:hv",
- long_options, NULL)) != -1) {
+ while ((c = getopt_long(argc, argv, "t:g:hv", long_options, NULL)) != -1) {
switch(c) {
case 't':
- strncpy(trajectory_filename, optarg, FILENAME_SIZE);
+ strncpy(global.trajectory_filename, optarg, FILENAME_SIZE);
break;
case 'g':
- strncpy(graph_filename, optarg, FILENAME_SIZE);
+ strncpy(global.graph_filename, optarg, FILENAME_SIZE);
break;
case 'h':
break;
case 'v':
- verbose = 1;
+ global.verbose = 1;
break;
default: