- for(int r = 0; r < 10; r++) {
- cout << "* ROUND " << r << endl;
- for(int t = 0; t < nb_time_steps; t++) {
- for(int l = 0; l < nb_locations; l++) {
- tracker.set_detection_score(t, l,
- (drand48() < 0.9 ? -1.0 : 1.0) + drand48() * 0.1 - 0.05);
- }
- tracker.set_detection_score(t, 0,
- (drand48() < 0.9 ? 1.0 : -1.0) + drand48() * 0.1 - 0.05);
- }
-
- tracker.build_graph();
- tracker.track();
-
- for(int t = 0; t < tracker.nb_trajectories(); t++) {
- cout << "TRAJECTORY " << t << " :";
- for(int u = 0; u < tracker.trajectory_duration(t); u++) {
- cout << " " << tracker.trajectory_location(t, u);
- }
- cout << endl;
- }
+ ifstream *in_tracker = new ifstream(argv[1]);
+
+ if(in_tracker->good()) {
+
+ MTPTracker *tracker = new MTPTracker();
+
+ cout << "Reading " << argv[1] << "." << endl;
+ tracker->read(in_tracker);
+
+ cout << "Building the graph ... "; cout.flush();
+ gettimeofday(&start_time, 0);
+ tracker->build_graph();
+ gettimeofday(&end_time, 0);
+ cout << "done (" << diff_in_second(&start_time, &end_time) << "s)." << endl;
+
+ cout << "Tracking ... "; cout.flush();
+ gettimeofday(&start_time, 0);
+ tracker->track();
+ gettimeofday(&end_time, 0);
+ cout << "done (" << diff_in_second(&start_time, &end_time) << "s)." << endl;
+
+ ofstream out_traj("result.trj");
+ tracker->write_trajectories(&out_traj);
+ cout << "Wrote result.trj" << endl;
+
+ ofstream out_dot("graph.dot");
+ tracker->print_graph_dot(&out_dot);
+ cout << "Wrote graph.dot" << endl;
+
+ delete tracker;
+
+ } else {
+
+ cerr << "Can not open " << argv[1] << endl;
+ exit(EXIT_FAILURE);
+