Mercurial Hosting > traffic-intelligence
annotate scripts/compute-clearmot.py @ 628:977407c9f815
corrected bugs in loading interactions (index shifted) and added functionalities to play/plot interactions
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Mon, 16 Feb 2015 11:58:51 +0100 |
parents | 17b02c8054d0 |
children | 3058e00887bc |
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 |
592
985a3021cff2
first match table implementation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
591
diff
changeset
|
4 from numpy import loadtxt |
591
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 |
592
985a3021cff2
first match table implementation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
591
diff
changeset
|
7 # TODO: need to trim objects to same mask ? |
591
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)') |
594
9e39cd95e017
first implementation of CLEAR MOT (needs formal tests)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
593
diff
changeset
|
18 parser.add_argument('-m', dest = 'matchingDistance', help = 'matching distance between tracker and ground truth trajectories', required = True, type = float) |
9e39cd95e017
first implementation of CLEAR MOT (needs formal tests)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
593
diff
changeset
|
19 parser.add_argument('-f', dest = 'firstInstant', help = 'first instant for measurement', required = True, type = int) |
9e39cd95e017
first implementation of CLEAR MOT (needs formal tests)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
593
diff
changeset
|
20 parser.add_argument('-l', dest = 'lastInstant', help = 'last instant for measurement', required = True, type = int) |
591
aded6c1c2ebd
added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
21 args = parser.parse_args() |
aded6c1c2ebd
added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
22 |
aded6c1c2ebd
added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
23 if args.homographyFilename != None: |
aded6c1c2ebd
added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
24 homography = loadtxt(args.homographyFilename) |
aded6c1c2ebd
added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
25 else: |
aded6c1c2ebd
added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
26 homography = None |
aded6c1c2ebd
added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
27 |
aded6c1c2ebd
added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
28 objects = storage.loadTrajectoriesFromSqlite(args.trackerDatabaseFilename, 'object') |
aded6c1c2ebd
added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
29 annotations = storage.loadGroundTruthFromSqlite(args.groundTruthDatabaseFilename) |
aded6c1c2ebd
added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
30 for a in annotations: |
aded6c1c2ebd
added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
31 a.computeCentroidTrajectory(homography) |
aded6c1c2ebd
added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
32 |
595
17b02c8054d0
added tests and corrected one bug
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
594
diff
changeset
|
33 motp, mota, mt, mme, fpt, gt = moving.computeClearMOT(annotations, objects, args.matchingDistance, args.firstInstant, args.lastInstant) |
592
985a3021cff2
first match table implementation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
591
diff
changeset
|
34 |
594
9e39cd95e017
first implementation of CLEAR MOT (needs formal tests)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
593
diff
changeset
|
35 print 'MOTP: {}'.format(motp) |
9e39cd95e017
first implementation of CLEAR MOT (needs formal tests)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
593
diff
changeset
|
36 print 'MOTA: {}'.format(mota) |
9e39cd95e017
first implementation of CLEAR MOT (needs formal tests)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
593
diff
changeset
|
37 print 'Number of missed objects.frames: {}'.format(mt) |
9e39cd95e017
first implementation of CLEAR MOT (needs formal tests)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
593
diff
changeset
|
38 print 'Number of mismatches: {}'.format(mme) |
9e39cd95e017
first implementation of CLEAR MOT (needs formal tests)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
593
diff
changeset
|
39 print 'Number of false alarms.frames: {}'.format(fpt) |