Mercurial Hosting > traffic-intelligence
comparison scripts/compute-clearmot.py @ 594:9e39cd95e017
first implementation of CLEAR MOT (needs formal tests)
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Sun, 07 Dec 2014 01:32:36 -0500 |
parents | e2a873e08568 |
children | 17b02c8054d0 |
comparison
equal
deleted
inserted
replaced
593:e2a873e08568 | 594:9e39cd95e017 |
---|---|
3 import sys, argparse | 3 import sys, argparse |
4 from numpy import loadtxt | 4 from numpy import loadtxt |
5 import moving, storage | 5 import moving, storage |
6 | 6 |
7 # TODO: need to trim objects to same mask ? | 7 # TODO: need to trim objects to same mask ? |
8 # pass frame interval where matching is done? | |
9 | 8 |
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: | 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: |
11 Keni, Bernardin, and Stiefelhagen Rainer. "Evaluating multiple object tracking performance: the CLEAR MOT metrics." EURASIP Journal on Image and Video Processing 2008 (2008) | 10 Keni, Bernardin, and Stiefelhagen Rainer. "Evaluating multiple object tracking performance: the CLEAR MOT metrics." EURASIP Journal on Image and Video Processing 2008 (2008) |
12 | 11 |
13 Polytrack format: | 12 Polytrack format: |
14 JP. Jodoin\'s MSc thesis (in french) | 13 JP. Jodoin\'s MSc thesis (in french) |
15 see examples on http://www.jpjodoin.com/urbantracker/dataset.html''', formatter_class=argparse.RawDescriptionHelpFormatter) | 14 see examples on http://www.jpjodoin.com/urbantracker/dataset.html''', formatter_class=argparse.RawDescriptionHelpFormatter) |
16 parser.add_argument('-d', dest = 'trackerDatabaseFilename', help = 'name of the Sqlite database containing the tracker output', required = True) | 15 parser.add_argument('-d', dest = 'trackerDatabaseFilename', help = 'name of the Sqlite database containing the tracker output', required = True) |
17 parser.add_argument('-g', dest = 'groundTruthDatabaseFilename', help = 'name of the Sqlite database containing the ground truth', required = True) | 16 parser.add_argument('-g', dest = 'groundTruthDatabaseFilename', help = 'name of the Sqlite database containing the ground truth', required = True) |
18 parser.add_argument('-o', dest = 'homographyFilename', help = 'name of the filename for the homography (if tracking was done using the homography)') | 17 parser.add_argument('-o', dest = 'homographyFilename', help = 'name of the filename for the homography (if tracking was done using the homography)') |
19 parser.add_argument('-m', dest = 'matchingDistance', help = 'matching distance between tracker and ground truth trajectories', required = True) | 18 parser.add_argument('-m', dest = 'matchingDistance', help = 'matching distance between tracker and ground truth trajectories', required = True, type = float) |
20 parser.add_argument('-f', dest = 'firstInstant', help = 'first instant for measurement', required = True) | 19 parser.add_argument('-f', dest = 'firstInstant', help = 'first instant for measurement', required = True, type = int) |
21 parser.add_argument('-l', dest = 'lastInstant', help = 'last instant for measurement', required = True) | 20 parser.add_argument('-l', dest = 'lastInstant', help = 'last instant for measurement', required = True, type = int) |
22 args = parser.parse_args() | 21 args = parser.parse_args() |
23 | 22 |
24 # args.homographyFilename is None if nothing as argument | |
25 if args.homographyFilename != None: | 23 if args.homographyFilename != None: |
26 homography = loadtxt(args.homographyFilename) | 24 homography = loadtxt(args.homographyFilename) |
27 else: | 25 else: |
28 homography = None | 26 homography = None |
29 | |
30 firstInstant = int(args.firstInstant) | |
31 lastInstant = int(args.lastInstant) | |
32 | 27 |
33 objects = storage.loadTrajectoriesFromSqlite(args.trackerDatabaseFilename, 'object') | 28 objects = storage.loadTrajectoriesFromSqlite(args.trackerDatabaseFilename, 'object') |
34 annotations = storage.loadGroundTruthFromSqlite(args.groundTruthDatabaseFilename) | 29 annotations = storage.loadGroundTruthFromSqlite(args.groundTruthDatabaseFilename) |
35 for a in annotations: | 30 for a in annotations: |
36 a.computeCentroidTrajectory(homography) | 31 a.computeCentroidTrajectory(homography) |
37 | 32 |
38 matchTable = moving.matchingGroundTruthToTracker(objects, annotations, args.matchingDistance, | 33 motp, mota, mt, mme, fpt, gt = moving.computeClearMOT(objects, annotations, args.matchingDistance, args.firstInstant, args.lastInstant) |
39 firstInstant, lastInstant) | |
40 | 34 |
41 # number of frames of existence of all objects within [firstInstant, lastInstant] | 35 print 'MOTP: {}'.format(motp) |
42 nTrackFrames = sum([min(o.getLastInstant(),lastInstant)-max(o.getFirstInstant(),firstInstant)+1 for o in objects]) | 36 print 'MOTA: {}'.format(mota) |
43 | 37 print 'Number of missed objects.frames: {}'.format(mt) |
44 print moving.computeClearMOT(matchTable, nTrackFrames) | 38 print 'Number of mismatches: {}'.format(mme) |
45 | 39 print 'Number of false alarms.frames: {}'.format(fpt) |