Mercurial > hg > nsaunier > traffic-intelligence
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 587:cf578ba866da | 588:c5406edbcf12 |
|---|---|
| 922 | 922 |
| 923 userType2Num = utils.inverseEnumeration(userTypeNames) | 923 userType2Num = utils.inverseEnumeration(userTypeNames) |
| 924 | 924 |
| 925 class MovingObject(STObject): | 925 class MovingObject(STObject): |
| 926 '''Class for moving objects: a spatio-temporal object | 926 '''Class for moving objects: a spatio-temporal object |
| 927 with a trajectory and a geometry (constant volume over time) and a usertype (e.g. road user) coded as a number (see | 927 with a trajectory and a geometry (constant volume over time) |
| 928 and a usertype (e.g. road user) coded as a number (see userTypeNames) | |
| 928 ''' | 929 ''' |
| 929 | 930 |
| 930 def __init__(self, num = None, timeInterval = None, positions = None, velocities = None, geometry = None, userType = userType2Num['unknown']): | 931 def __init__(self, num = None, timeInterval = None, positions = None, velocities = None, geometry = None, userType = userType2Num['unknown']): |
| 931 super(MovingObject, self).__init__(num, timeInterval) | 932 super(MovingObject, self).__init__(num, timeInterval) |
| 932 self.positions = positions | 933 self.positions = positions |
| 1276 return Point.cosine(movingObject1.getPositionAtInstant(instant)-movingObject2.getPositionAtInstant(instant), #deltap | 1277 return Point.cosine(movingObject1.getPositionAtInstant(instant)-movingObject2.getPositionAtInstant(instant), #deltap |
| 1277 movingObject2.getVelocityAtInstant(instant)-movingObject1.getVelocityAtInstant(instant)) #deltav | 1278 movingObject2.getVelocityAtInstant(instant)-movingObject1.getVelocityAtInstant(instant)) #deltav |
| 1278 | 1279 |
| 1279 | 1280 |
| 1280 ################## | 1281 ################## |
| 1281 # Bounding Boxes | 1282 # Annotations |
| 1282 ################## | 1283 ################## |
| 1283 | 1284 |
| 1284 # class BoundingBoxes(STObject): | 1285 class BBAnnotation(MovingObject): |
| 1285 # '''Class for : a spatio-temporal object | 1286 '''Class for : a series of ground truth annotations using bounding boxes |
| 1286 # with a trajectory and a geometry (constant volume over time) and a usertype (e.g. road user) coded as a number (see | 1287 Its center is the center of the containing shape |
| 1287 # ''' | 1288 ''' |
| 1288 | 1289 |
| 1289 # def __init__(self, num = None, timeInterval = None, positions = None, velocities = None, geometry = None, userType = userType2Num['unknown']): | 1290 def __init__(self, num = None, timeInterval = None, topPositions = None, bottomPositions = None, userType = userType2Num['unknown']): |
| 1290 # super(MovingObject, self).__init__(num, timeInterval) | 1291 super(BBAnnotation, self).__init__(num, timeInterval, Trajectory(), userType = userType) |
| 1291 # self.positions = positions | 1292 self.topPositions = topPositions.getPositions() |
| 1292 # self.velocities = velocities | 1293 self.bottomPositions = bottomPositions.getPositions() |
| 1293 # self.geometry = geometry | 1294 for i in xrange(int(topPositions.length())): |
| 1294 # self.userType = userType | 1295 self.positions.addPosition((topPositions.getPositionAt(i) + bottomPositions.getPositionAt(i)).multiply(0.5)) |
| 1295 # self.features = [] | 1296 |
| 1296 # # compute bounding polygon from trajectory | |
| 1297 | 1297 |
| 1298 def plotRoadUsers(objects, colors): | 1298 def plotRoadUsers(objects, colors): |
| 1299 '''Colors is a PlottingPropertyValues instance''' | 1299 '''Colors is a PlottingPropertyValues instance''' |
| 1300 from matplotlib.pyplot import figure, axis | 1300 from matplotlib.pyplot import figure, axis |
| 1301 figure() | 1301 figure() |
