annotate scripts/compute-clearmot.py @ 593:e2a873e08568

non-working clear mot metrics
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Sat, 06 Dec 2014 22:15:56 -0500
parents 985a3021cff2
children 9e39cd95e017
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 ?
985a3021cff2 first match table implementation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 591
diff changeset
8 # pass frame interval where matching is done?
591
aded6c1c2ebd added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
9
aded6c1c2ebd added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10 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
11 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
12
aded6c1c2ebd added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
13 Polytrack format:
aded6c1c2ebd added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
14 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
15 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
16 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
17 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
18 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
19 parser.add_argument('-m', dest = 'matchingDistance', help = 'matching distance between tracker and ground truth trajectories', required = True)
592
985a3021cff2 first match table implementation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 591
diff changeset
20 parser.add_argument('-f', dest = 'firstInstant', help = 'first instant for measurement', required = True)
985a3021cff2 first match table implementation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 591
diff changeset
21 parser.add_argument('-l', dest = 'lastInstant', help = 'last instant for measurement', required = True)
591
aded6c1c2ebd added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
22 args = parser.parse_args()
aded6c1c2ebd added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
23
aded6c1c2ebd added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
24 # 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
25 if args.homographyFilename != None:
aded6c1c2ebd added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
26 homography = loadtxt(args.homographyFilename)
aded6c1c2ebd added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
27 else:
aded6c1c2ebd added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
28 homography = None
aded6c1c2ebd added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
29
593
e2a873e08568 non-working clear mot metrics
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 592
diff changeset
30 firstInstant = int(args.firstInstant)
e2a873e08568 non-working clear mot metrics
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 592
diff changeset
31 lastInstant = int(args.lastInstant)
e2a873e08568 non-working clear mot metrics
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 592
diff changeset
32
591
aded6c1c2ebd added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
33 objects = storage.loadTrajectoriesFromSqlite(args.trackerDatabaseFilename, 'object')
aded6c1c2ebd added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
34 annotations = storage.loadGroundTruthFromSqlite(args.groundTruthDatabaseFilename)
aded6c1c2ebd added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
35 for a in annotations:
aded6c1c2ebd added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
36 a.computeCentroidTrajectory(homography)
aded6c1c2ebd added framework script and function to compute matchings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
37
593
e2a873e08568 non-working clear mot metrics
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 592
diff changeset
38 matchTable = moving.matchingGroundTruthToTracker(objects, annotations, args.matchingDistance,
e2a873e08568 non-working clear mot metrics
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 592
diff changeset
39 firstInstant, lastInstant)
592
985a3021cff2 first match table implementation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 591
diff changeset
40
593
e2a873e08568 non-working clear mot metrics
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 592
diff changeset
41 # number of frames of existence of all objects within [firstInstant, lastInstant]
e2a873e08568 non-working clear mot metrics
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 592
diff changeset
42 nTrackFrames = sum([min(o.getLastInstant(),lastInstant)-max(o.getFirstInstant(),firstInstant)+1 for o in objects])
e2a873e08568 non-working clear mot metrics
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 592
diff changeset
43
e2a873e08568 non-working clear mot metrics
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 592
diff changeset
44 print moving.computeClearMOT(matchTable, nTrackFrames)
e2a873e08568 non-working clear mot metrics
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 592
diff changeset
45