Mercurial Hosting > traffic-intelligence
diff python/events.py @ 451:cd342a774806
Point/CurvilinearTrajectory/Interaction utiles
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Thu, 13 Feb 2014 01:24:27 -0500 |
parents | b64ff7fe7b45 |
children | c59a47ce0209 |
line wrap: on
line diff
--- a/python/events.py Tue Feb 11 02:55:02 2014 -0500 +++ b/python/events.py Thu Feb 13 01:24:27 2014 -0500 @@ -67,6 +67,7 @@ self.roadUser2 = roadUser2 self.categoryNum = categoryNum self.indicators = {} + self.interactionInterval = None def getRoadUserNumbers(self): return self.roadUserNumbers @@ -141,8 +142,20 @@ self.videoFilename= videoFilename def addInteractionType(self,interactionType): - ''' interaction types: conflict or collision if they are known''' - self.interactionType= interactionType + ''' interaction types: conflict or collision if they are known''' + self.interactionType= interactionType + + def computeInteractionInterval(self): + ''' Computes the times during which the road users are getting closer, + ie the collision course angle is positive + (Other thresholds/indicators could be tried)''' + collisionCourseDotProducts = self.getIndicator(Interaction.indicatorNames[0]) + inter = collisionCourseDotProducts.getTimeInterval() + interactionInstants = [t for t in inter if collisionCourseDotProducts[t] >= 0] + if len(interactionInstants) >= 2: + self.interactionInterval = moving.TimeInterval(interactionInstants[0], interactionInstants[-1]) + else: + self.interactionInterval = moving.TimeInterval() def createInteractions(objects): '''Create all interactions of two co-existing road users