Mercurial Hosting > traffic-intelligence
changeset 592:985a3021cff2
first match table implementation
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Fri, 05 Dec 2014 17:50:16 -0500 |
parents | aded6c1c2ebd |
children | e2a873e08568 |
files | python/moving.py scripts/compute-clearmot.py |
diffstat | 2 files changed, 34 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/python/moving.py Fri Dec 05 17:00:37 2014 -0500 +++ b/python/moving.py Fri Dec 05 17:50:16 2014 -0500 @@ -1307,14 +1307,37 @@ def matches(self, obj, instant, matchingDistance): '''Indicates if the annotation matches obj (MovingObject) with threshold matchingDistance''' - return True + d = Point.distanceNorm2(self.getPositionAtInstant(instant), obj.getPositionAtInstant(instant)) + return d<matchingDistance, d -def matchingGroundTruthToTracker(objects, annotations, matchingDistance): +def matchingGroundTruthToTracker(objects, annotations, matchingDistance, firstInstant, lastInstant): '''Returns a matching of tracker output (objects) to ground truth (annnotations) objects and annotations are supposed to in the same space current implementation is BBAnnotations (bounding boxes) - mathingDistance is threshold on matching between annotation and object''' + mathingDistance is threshold on matching between annotation and object + + Output is list of + [frame number, ground truth id, tracker object id, distance] + where tracker object id is None if no matching was found''' + + matchTable = [] + for t in xrange(firstInstant, lastInstant+1): + for a in annotations: + if a.existsAtInstant(t): + minDist = float('inf') + matchingObject = None + for o in objects: + if o.existsAtInstant(t): + match, d = a.matches(o, t, matchingDistance) + if match and d<minDist: + minDist = d + matchingObject = o + if matchingObject == None: + matchTable.append([t, a.getNum(), None, minDist]) + else: + matchTable.append([t, a.getNum(), matchingObject.getNum(), minDist]) + return matchTable def plotRoadUsers(objects, colors): '''Colors is a PlottingPropertyValues instance'''
--- a/scripts/compute-clearmot.py Fri Dec 05 17:00:37 2014 -0500 +++ b/scripts/compute-clearmot.py Fri Dec 05 17:50:16 2014 -0500 @@ -1,10 +1,11 @@ #! /usr/bin/env python import sys, argparse - +from numpy import loadtxt import moving, storage -from numpy import loadtxt +# TODO: need to trim objects to same mask ? +# pass frame interval where matching is done? 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: Keni, Bernardin, and Stiefelhagen Rainer. "Evaluating multiple object tracking performance: the CLEAR MOT metrics." EURASIP Journal on Image and Video Processing 2008 (2008) @@ -16,6 +17,8 @@ parser.add_argument('-g', dest = 'groundTruthDatabaseFilename', help = 'name of the Sqlite database containing the ground truth', required = True) parser.add_argument('-o', dest = 'homographyFilename', help = 'name of the filename for the homography (if tracking was done using the homography)') parser.add_argument('-m', dest = 'matchingDistance', help = 'matching distance between tracker and ground truth trajectories', required = True) +parser.add_argument('-f', dest = 'firstInstant', help = 'first instant for measurement', required = True) +parser.add_argument('-l', dest = 'lastInstant', help = 'last instant for measurement', required = True) args = parser.parse_args() # args.homographyFilename is None if nothing as argument @@ -29,5 +32,7 @@ for a in annotations: a.computeCentroidTrajectory(homography) -moving.matchingGroundTruthToTracker(objects, annotations, args.matchingDistance) +moving.matchingGroundTruthToTracker(objects, annotations, args.matchingDistance, + int(args.firstInstant), int(args.lastInstant)) #storage.deleteFromSqlite(args.databaseFilename, args.dataType) +