+void do_tracking(istream *in_tracker) {
+ timeval start_time, end_time;
+ MTPTracker *tracker = new MTPTracker();
+
+ if(global.verbose) { cout << "Reading the tracking parameters." << endl; }
+ tracker->read(in_tracker);
+
+ if(global.verbose) {
+ cout << "Building the graph ... "; cout.flush();
+ gettimeofday(&start_time, 0);
+ }
+ tracker->build_graph();
+ if(global.verbose) {
+ gettimeofday(&end_time, 0);
+ cout << "done (" << diff_in_second(&start_time, &end_time) << "s)." << endl;
+ }
+
+ if(global.verbose) {
+ cout << "Tracking ... "; cout.flush();
+ gettimeofday(&start_time, 0);
+ }
+ tracker->track();
+ if(global.verbose) {
+ gettimeofday(&end_time, 0);
+ cout << "done (" << diff_in_second(&start_time, &end_time) << "s)." << endl;
+ }
+
+ if(strcmp(global.trajectory_filename, "")) {
+ ofstream out_traj(global.trajectory_filename);
+ tracker->write_trajectories(&out_traj);
+ if(global.verbose) { cout << "Wrote " << global.trajectory_filename << "." << endl; }
+ } else {
+ tracker->write_trajectories(&cout);
+ }
+
+ if(strcmp(global.graph_filename, "") != 0) {
+ ofstream out_dot(global.graph_filename);
+ tracker->print_graph_dot(&out_dot);
+ if(global.verbose) { cout << "Wrote " << global.graph_filename << "." << endl; }
+ }
+
+ 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 }
+};