CXXFLAGS = -Wconversion -Wall $(OPTIMIZE_FLAG) $(PROFILE_FLAG) $(VERBOSE_FLAG)
-all: mtp mtp_example mtp_stress_test
+all: mtp mtp_example
mtp: \
path.o \
mtp_example.o
$(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS)
-mtp_stress_test: \
- path.o \
- mtp_graph.o \
- mtp_tracker.o \
- mtp_stress_test.o
- $(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS)
-
Makefile.depend: *.h *.cc Makefile
$(CC) $(CXXFLAGS) -M *.cc > Makefile.depend
clean:
- \rm -f mtp mtp_example mtp_stress_test *.o Makefile.depend
+ \rm -f mtp mtp_example *.o Makefile.depend
-include Makefile.depend
- mtp_example creates a tracking toy example, and runs the tracking
algorithm on it. It gives an example of how to use MTPTracker on a
configuration produced dynamically, and produces a test input file
- for the mtp command.
-
- - mtp_stress_test creates a larger problem with a lot of noise and
- multiple trajectories, to check the behavior of the code under
- slightly more complex situations.
+ for the mtp command. If you pass it the "stress" argument, it
+ generates a larger and noisier problem.
* INSTALLATION
#include <iostream>
#include <fstream>
#include <stdlib.h>
+#include <string.h>
using namespace std;
}
}
-int main(int argc, char **argv) {
+void create_light_test(MTPTracker *tracker) {
int nb_locations = 7;
int nb_time_steps = 8;
int motion_amplitude = 1;
- MTPTracker *tracker = new MTPTracker();
-
tracker->allocate(nb_time_steps, nb_locations);
// We define the spatial structure by stating what are the possible
ofstream out_tracker("tracker.dat");
tracker->write(&out_tracker);
}
+}
+
+void create_heavy_test(MTPTracker *tracker) {
+ int nb_locations = 100;
+ int nb_time_steps = 1000;
+
+ tracker->allocate(nb_time_steps, nb_locations);
+
+ for(int l = 0; l < nb_locations; l++) {
+ for(int m = 0; m < nb_locations; m++) {
+ tracker->allowed_motions[l][m] = (drand48() < 0.1);
+ }
+ }
+
+ for(int t = 0; t < nb_time_steps; t++) {
+ for(int l = 0; l < nb_locations; l++) {
+ tracker->entrances[t][l] = drand48() < 0.01;
+ tracker->exits[t][l] = drand48() < 0.01;
+ }
+ }
+
+ tracker->build_graph();
+
+ for(int t = 0; t < nb_time_steps; t++) {
+ for(int l = 0; l < nb_locations; l++) {
+ tracker->detection_scores[t][l] = scalar_t(drand48()) - 0.95f;
+ }
+ }
+}
+
+int main(int argc, char **argv) {
+ int stress_test;
+
+ if(argc == 1) {
+ stress_test = 0;
+ } else if(argc == 2 && strcmp(argv[1], "stress") == 0) {
+ stress_test = 1;
+ } else {
+ cerr << "mtp_examples [stress]" << endl;
+ exit(EXIT_FAILURE);
+ }
+
+ MTPTracker *tracker = new MTPTracker();
+
+ if(stress_test) {
+ create_heavy_test(tracker);
+ } else {
+ create_light_test(tracker);
+ }
// Performs the tracking per se
+++ /dev/null
-
-/*
- * mtp is the ``Multi Tracked Paths'', an implementation of the
- * k-shortest paths algorithm for multi-target tracking.
- *
- * Copyright (c) 2012 Idiap Research Institute, http://www.idiap.ch/
- * Written by Francois Fleuret <francois.fleuret@idiap.ch>
- *
- * This file is part of mtp.
- *
- * mtp is free software: you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 3 as
- * published by the Free Software Foundation.
- *
- * mtp is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
- * License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with selector. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include <iostream>
-#include <fstream>
-#include <stdlib.h>
-
-using namespace std;
-
-#include "mtp_tracker.h"
-
-//////////////////////////////////////////////////////////////////////
-
-int main(int argc, char **argv) {
- int nb_locations = 100;
- int nb_time_steps = 1000;
-
- MTPTracker *tracker = new MTPTracker();
-
- tracker->allocate(nb_time_steps, nb_locations);
-
- for(int l = 0; l < nb_locations; l++) {
- for(int m = 0; m < nb_locations; m++) {
- tracker->allowed_motions[l][m] = (drand48() < 0.1);
- }
- }
-
- for(int t = 0; t < nb_time_steps; t++) {
- for(int l = 0; l < nb_locations; l++) {
- tracker->entrances[t][l] = drand48() < 0.01;
- tracker->exits[t][l] = drand48() < 0.01;
- }
- }
-
- tracker->build_graph();
-
- for(int t = 0; t < nb_time_steps; t++) {
- for(int l = 0; l < nb_locations; l++) {
- tracker->detection_scores[t][l] = scalar_t(drand48()) - 0.95f;
- }
- }
-
- // Performs the tracking per se
-
- tracker->track();
-
- // Prints the detected trajectories
-
- for(int t = 0; t < tracker->nb_trajectories(); t++) {
- cout << "Trajectory "
- << t
- << " starting at " << tracker->trajectory_entrance_time(t)
- << ", duration " << tracker->trajectory_duration(t)
- << ", score " << tracker->trajectory_score(t)
- << ", through locations";
- for(int u = 0; u < tracker->trajectory_duration(t); u++) {
- cout << " " << tracker->trajectory_location(t, u);
- }
- cout << endl;
- }
-
- delete tracker;
-
- exit(EXIT_SUCCESS);
-}