comparison python/moving.py @ 592:985a3021cff2

first match table implementation
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Fri, 05 Dec 2014 17:50:16 -0500
parents 0fa73cbe9fdb
children e2a873e08568
comparison
equal deleted inserted replaced
591:aded6c1c2ebd 592:985a3021cff2
1305 self.positions = self.positions.project(homography) 1305 self.positions = self.positions.project(homography)
1306 1306
1307 def matches(self, obj, instant, matchingDistance): 1307 def matches(self, obj, instant, matchingDistance):
1308 '''Indicates if the annotation matches obj (MovingObject) 1308 '''Indicates if the annotation matches obj (MovingObject)
1309 with threshold matchingDistance''' 1309 with threshold matchingDistance'''
1310 return True 1310 d = Point.distanceNorm2(self.getPositionAtInstant(instant), obj.getPositionAtInstant(instant))
1311 1311 return d<matchingDistance, d
1312 def matchingGroundTruthToTracker(objects, annotations, matchingDistance): 1312
1313 def matchingGroundTruthToTracker(objects, annotations, matchingDistance, firstInstant, lastInstant):
1313 '''Returns a matching of tracker output (objects) to ground truth (annnotations) 1314 '''Returns a matching of tracker output (objects) to ground truth (annnotations)
1314 1315
1315 objects and annotations are supposed to in the same space 1316 objects and annotations are supposed to in the same space
1316 current implementation is BBAnnotations (bounding boxes) 1317 current implementation is BBAnnotations (bounding boxes)
1317 mathingDistance is threshold on matching between annotation and object''' 1318 mathingDistance is threshold on matching between annotation and object
1319
1320 Output is list of
1321 [frame number, ground truth id, tracker object id, distance]
1322 where tracker object id is None if no matching was found'''
1323
1324 matchTable = []
1325 for t in xrange(firstInstant, lastInstant+1):
1326 for a in annotations:
1327 if a.existsAtInstant(t):
1328 minDist = float('inf')
1329 matchingObject = None
1330 for o in objects:
1331 if o.existsAtInstant(t):
1332 match, d = a.matches(o, t, matchingDistance)
1333 if match and d<minDist:
1334 minDist = d
1335 matchingObject = o
1336 if matchingObject == None:
1337 matchTable.append([t, a.getNum(), None, minDist])
1338 else:
1339 matchTable.append([t, a.getNum(), matchingObject.getNum(), minDist])
1340 return matchTable
1318 1341
1319 def plotRoadUsers(objects, colors): 1342 def plotRoadUsers(objects, colors):
1320 '''Colors is a PlottingPropertyValues instance''' 1343 '''Colors is a PlottingPropertyValues instance'''
1321 from matplotlib.pyplot import figure, axis 1344 from matplotlib.pyplot import figure, axis
1322 figure() 1345 figure()