Mercurial Hosting > traffic-intelligence
comparison 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 |
comparison
equal
deleted
inserted
replaced
450:c0786fe4ad94 | 451:cd342a774806 |
---|---|
65 self.roadUserNumbers = set([roaduserNum1, roaduserNum2]) | 65 self.roadUserNumbers = set([roaduserNum1, roaduserNum2]) |
66 self.roadUser1 = roadUser1 | 66 self.roadUser1 = roadUser1 |
67 self.roadUser2 = roadUser2 | 67 self.roadUser2 = roadUser2 |
68 self.categoryNum = categoryNum | 68 self.categoryNum = categoryNum |
69 self.indicators = {} | 69 self.indicators = {} |
70 self.interactionInterval = None | |
70 | 71 |
71 def getRoadUserNumbers(self): | 72 def getRoadUserNumbers(self): |
72 return self.roadUserNumbers | 73 return self.roadUserNumbers |
73 | 74 |
74 def getIndicator(self, indicatorName): | 75 def getIndicator(self, indicatorName): |
139 | 140 |
140 def addVideoFilename(self,videoFilename): | 141 def addVideoFilename(self,videoFilename): |
141 self.videoFilename= videoFilename | 142 self.videoFilename= videoFilename |
142 | 143 |
143 def addInteractionType(self,interactionType): | 144 def addInteractionType(self,interactionType): |
144 ''' interaction types: conflict or collision if they are known''' | 145 ''' interaction types: conflict or collision if they are known''' |
145 self.interactionType= interactionType | 146 self.interactionType= interactionType |
147 | |
148 def computeInteractionInterval(self): | |
149 ''' Computes the times during which the road users are getting closer, | |
150 ie the collision course angle is positive | |
151 (Other thresholds/indicators could be tried)''' | |
152 collisionCourseDotProducts = self.getIndicator(Interaction.indicatorNames[0]) | |
153 inter = collisionCourseDotProducts.getTimeInterval() | |
154 interactionInstants = [t for t in inter if collisionCourseDotProducts[t] >= 0] | |
155 if len(interactionInstants) >= 2: | |
156 self.interactionInterval = moving.TimeInterval(interactionInstants[0], interactionInstants[-1]) | |
157 else: | |
158 self.interactionInterval = moving.TimeInterval() | |
146 | 159 |
147 def createInteractions(objects): | 160 def createInteractions(objects): |
148 '''Create all interactions of two co-existing road users | 161 '''Create all interactions of two co-existing road users |
149 | 162 |
150 todo add test to compute categories?''' | 163 todo add test to compute categories?''' |