diff python/moving.py @ 590:0fa73cbe9fdb

annotation centroid are computed explicitly and projected at that step if required
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Fri, 05 Dec 2014 16:41:11 -0500
parents 5800a87f11ae
children 985a3021cff2
line wrap: on
line diff
--- a/python/moving.py	Fri Dec 05 15:14:44 2014 -0500
+++ b/python/moving.py	Fri Dec 05 16:41:11 2014 -0500
@@ -726,6 +726,11 @@
             return Trajectory([[a-b for a,b in zip(self.getXCoordinates(),traj2.getXCoordinates())],
                                [a-b for a,b in zip(self.getYCoordinates(),traj2.getYCoordinates())]])
 
+    def multiply(self, alpha):
+        '''Returns a new trajectory of the same length'''
+        return Trajectory([[alpha*x for x in self.getXCoordinates()],
+                           [alpha*y for y in self.getYCoordinates()]])
+
     def differentiate(self, doubleLastPosition = False):
         diff = Trajectory()
         for i in xrange(1, self.length()):
@@ -1283,17 +1288,33 @@
 ##################
 
 class BBAnnotation(MovingObject):
-    '''Class for : a series of ground truth annotations using bounding boxes
+    '''Class for a series of ground truth annotations using bounding boxes
     Its center is the center of the containing shape
+
+    By default in image space
     '''
 
     def __init__(self, num = None, timeInterval = None, topLeftPositions = None, bottomRightPositions = None, userType = userType2Num['unknown']):
-        super(BBAnnotation, self).__init__(num, timeInterval, Trajectory(), userType = userType)
+        super(BBAnnotation, self).__init__(num, timeInterval, userType = userType)
         self.topLeftPositions = topLeftPositions.getPositions()
         self.bottomRightPositions = bottomRightPositions.getPositions()
-        for i in xrange(int(topLeftPositions.length())):
-            self.positions.addPosition((topLeftPositions.getPositionAt(i) + bottomRightPositions.getPositionAt(i)).multiply(0.5))
-    
+
+    def computeCentroidTrajectory(self, homography = None):
+        self.positions = self.topLeftPositions.add(self.bottomRightPositions).multiply(0.5)
+        if homography != None:
+            self.positions = self.positions.project(homography)
+
+    def matches(self, obj, instant, matchingDistance):
+        '''Indicates if the annotation matches obj (MovingObject)
+        with threshold matchingDistance'''
+        return True
+
+def matchingGroundTruthToTracker(objects, annotations, matchingDistance):
+    '''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'''
 
 def plotRoadUsers(objects, colors):
     '''Colors is a PlottingPropertyValues instance'''