Mercurial Hosting > traffic-intelligence
annotate scripts/compute-clearmot.py @ 591:aded6c1c2ebd
added framework script and function to compute matchings
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Fri, 05 Dec 2014 17:00:37 -0500 |
parents | |
children | 985a3021cff2 |
rev | line source |
---|---|
591
aded6c1c2ebd
added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
1 #! /usr/bin/env python |
aded6c1c2ebd
added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
2 |
aded6c1c2ebd
added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
3 import sys, argparse |
aded6c1c2ebd
added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
4 |
aded6c1c2ebd
added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
5 import moving, storage |
aded6c1c2ebd
added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
6 |
aded6c1c2ebd
added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
7 from numpy import loadtxt |
aded6c1c2ebd
added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
8 |
aded6c1c2ebd
added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
9 parser = argparse.ArgumentParser(description='The program computes the CLEAR MOT metrics between ground truth and tracker output (in Polytrack format)', epilog='''CLEAR MOT metrics information: |
aded6c1c2ebd
added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
10 Keni, Bernardin, and Stiefelhagen Rainer. "Evaluating multiple object tracking performance: the CLEAR MOT metrics." EURASIP Journal on Image and Video Processing 2008 (2008) |
aded6c1c2ebd
added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
11 |
aded6c1c2ebd
added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
12 Polytrack format: |
aded6c1c2ebd
added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
13 JP. Jodoin\'s MSc thesis (in french) |
aded6c1c2ebd
added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
14 see examples on http://www.jpjodoin.com/urbantracker/dataset.html''', formatter_class=argparse.RawDescriptionHelpFormatter) |
aded6c1c2ebd
added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
15 parser.add_argument('-d', dest = 'trackerDatabaseFilename', help = 'name of the Sqlite database containing the tracker output', required = True) |
aded6c1c2ebd
added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
16 parser.add_argument('-g', dest = 'groundTruthDatabaseFilename', help = 'name of the Sqlite database containing the ground truth', required = True) |
aded6c1c2ebd
added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
17 parser.add_argument('-o', dest = 'homographyFilename', help = 'name of the filename for the homography (if tracking was done using the homography)') |
aded6c1c2ebd
added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
18 parser.add_argument('-m', dest = 'matchingDistance', help = 'matching distance between tracker and ground truth trajectories', required = True) |
aded6c1c2ebd
added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
19 args = parser.parse_args() |
aded6c1c2ebd
added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
20 |
aded6c1c2ebd
added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
21 # args.homographyFilename is None if nothing as argument |
aded6c1c2ebd
added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
22 if args.homographyFilename != None: |
aded6c1c2ebd
added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
23 homography = loadtxt(args.homographyFilename) |
aded6c1c2ebd
added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
24 else: |
aded6c1c2ebd
added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
25 homography = None |
aded6c1c2ebd
added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
26 |
aded6c1c2ebd
added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
27 objects = storage.loadTrajectoriesFromSqlite(args.trackerDatabaseFilename, 'object') |
aded6c1c2ebd
added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
28 annotations = storage.loadGroundTruthFromSqlite(args.groundTruthDatabaseFilename) |
aded6c1c2ebd
added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
29 for a in annotations: |
aded6c1c2ebd
added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
30 a.computeCentroidTrajectory(homography) |
aded6c1c2ebd
added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
31 |
aded6c1c2ebd
added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
32 moving.matchingGroundTruthToTracker(objects, annotations, args.matchingDistance) |
aded6c1c2ebd
added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
33 #storage.deleteFromSqlite(args.databaseFilename, args.dataType) |