diff python/moving.py @ 588:c5406edbcf12

added loading ground truth annotations (ground truth) from polytrack format
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Fri, 05 Dec 2014 00:54:38 -0500
parents cf578ba866da
children 5800a87f11ae 0954aaf28231
line wrap: on
line diff
--- a/python/moving.py	Thu Dec 04 17:46:32 2014 -0500
+++ b/python/moving.py	Fri Dec 05 00:54:38 2014 -0500
@@ -924,7 +924,8 @@
 
 class MovingObject(STObject):
     '''Class for moving objects: a spatio-temporal object 
-    with a trajectory and a geometry (constant volume over time) and a usertype (e.g. road user) coded as a number (see 
+    with a trajectory and a geometry (constant volume over time) 
+    and a usertype (e.g. road user) coded as a number (see userTypeNames)
     '''
 
     def __init__(self, num = None, timeInterval = None, positions = None, velocities = None, geometry = None, userType = userType2Num['unknown']):
@@ -1278,22 +1279,21 @@
 
 
 ##################
-# Bounding Boxes
+# Annotations
 ##################
 
-# class BoundingBoxes(STObject):
-#     '''Class for : a spatio-temporal object 
-#     with a trajectory and a geometry (constant volume over time) and a usertype (e.g. road user) coded as a number (see 
-#     '''
+class BBAnnotation(MovingObject):
+    '''Class for : a series of ground truth annotations using bounding boxes
+    Its center is the center of the containing shape
+    '''
 
-#     def __init__(self, num = None, timeInterval = None, positions = None, velocities = None, geometry = None, userType = userType2Num['unknown']):
-#         super(MovingObject, self).__init__(num, timeInterval)
-#         self.positions = positions
-#         self.velocities = velocities
-#         self.geometry = geometry
-#         self.userType = userType
-#         self.features = []
-#         # compute bounding polygon from trajectory
+    def __init__(self, num = None, timeInterval = None, topPositions = None, bottomPositions = None, userType = userType2Num['unknown']):
+        super(BBAnnotation, self).__init__(num, timeInterval, Trajectory(), userType = userType)
+        self.topPositions = topPositions.getPositions()
+        self.bottomPositions = bottomPositions.getPositions()
+        for i in xrange(int(topPositions.length())):
+            self.positions.addPosition((topPositions.getPositionAt(i) + bottomPositions.getPositionAt(i)).multiply(0.5))
+        
 
 def plotRoadUsers(objects, colors):
     '''Colors is a PlottingPropertyValues instance'''