Mercurial > hg > nsaunier > traffic-intelligence
comparison python/events.py @ 378:3805b9639647
added tests for movement orientation, object size
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Thu, 18 Jul 2013 21:55:17 -0400 |
| parents | c41ff9f3c263 |
| children | ba813f148ade |
comparison
equal
deleted
inserted
replaced
| 377:2aed569f39e7 | 378:3805b9639647 |
|---|---|
| 94 self.addIndicator(indicators.SeverityIndicator('Speed Differential', speedDifferentials)) | 94 self.addIndicator(indicators.SeverityIndicator('Speed Differential', speedDifferentials)) |
| 95 | 95 |
| 96 # todo test for interaction instants and interval, compute indicators | 96 # todo test for interaction instants and interval, compute indicators |
| 97 | 97 |
| 98 # if we have features, compute other indicators | 98 # if we have features, compute other indicators |
| 99 if self.roadUser1.features and self.roadUser2.features: | 99 if self.roadUser1.features != None and self.roadUser2.features != None: |
| 100 from scipy.spatial.distance import cdist | |
| 101 minDistance={} | 100 minDistance={} |
| 102 for instant in self.timeInterval: | 101 for instant in self.timeInterval: |
| 103 positions1 = [f.getPositionAtInstant(instant).astuple() for f in self.roadUser1.features if f.existsAtInstant(instant)] | 102 minDistance[instant] = MovingObject.minDistance(self.roadUser1, self.roadUser2, instant) |
| 104 positions2 = [f.getPositionAtInstant(instant).astuple() for f in self.roadUser2.features if f.existsAtInstant(instant)] | |
| 105 distance = cdist(positions1, positions2, metric = 'euclidean') | |
| 106 minDistance[instant] = distance.min() | |
| 107 self.addIndicator(indicators.SeverityIndicator('Minimum Distance', minDistance)) | 103 self.addIndicator(indicators.SeverityIndicator('Minimum Distance', minDistance)) |
| 108 | 104 |
| 109 def computeCrossingsCollisions(self, predictionParameters, collisionDistanceThreshold, timeHorizon, computeCZ = False, debug = False, timeInterval = None): | 105 def computeCrossingsCollisions(self, predictionParameters, collisionDistanceThreshold, timeHorizon, computeCZ = False, debug = False, timeInterval = None): |
| 110 '''Computes all crossing and collision points at each common instant for two road users. ''' | 106 '''Computes all crossing and collision points at each common instant for two road users. ''' |
| 111 self.collisionPoints={} | 107 self.collisionPoints={} |
