Mercurial Hosting > traffic-intelligence
changeset 705:0ceee3b1a96d dev
cleanup crossing collisions and crossing zones in Interaction (not stored per type of prediction method)
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Wed, 22 Jul 2015 13:46:28 -0400 |
parents | f83d125d0c55 |
children | e395bffe1412 |
files | python/events.py |
diffstat | 1 files changed, 11 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/python/events.py Wed Jul 22 12:58:04 2015 -0400 +++ b/python/events.py Wed Jul 22 13:46:28 2015 -0400 @@ -6,7 +6,6 @@ from base import VideoFilenameAddable import numpy as np -from numpy import arccos import multiprocessing import itertools @@ -182,14 +181,14 @@ v1 = self.roadUser1.getVelocityAtInstant(instant) v2 = self.roadUser2.getVelocityAtInstant(instant) deltav = v2-v1 - velocityAngles[instant] = arccos(moving.Point.dot(v1, v2)/(v1.norm2()*v2.norm2())) + velocityAngles[instant] = np.arccos(moving.Point.dot(v1, v2)/(v1.norm2()*v2.norm2())) collisionCourseDotProducts[instant] = moving.Point.dot(deltap, deltav) distances[instant] = deltap.norm2() speedDifferentials[instant] = deltav.norm2() if collisionCourseDotProducts[instant] > 0: interactionInstants.append(instant) if distances[instant] != 0 and speedDifferentials[instant] != 0: - collisionCourseAngles[instant] = arccos(collisionCourseDotProducts[instant]/(distances[instant]*speedDifferentials[instant])) + collisionCourseAngles[instant] = np.arccos(collisionCourseDotProducts[instant]/(distances[instant]*speedDifferentials[instant])) if len(interactionInstants) >= 2: self.interactionInterval = moving.TimeInterval(interactionInstants[0], interactionInstants[-1]) @@ -227,7 +226,7 @@ # crossing zones and pPET if computeCZ: - self.crossingZones[predictionParameters.name] = crossingZones + self.crossingZones = crossingZones pPETs = {} for i, cz in self.crossingZones.iteritems(): pPETs[i] = prediction.SafetyPoint.computeExpectedIndicator(cz) @@ -248,18 +247,11 @@ else: return None - def getCrossingZones(self, predictionMethodName): - if self.crossingZones is not None: - return self.crossingZones[predictionMethodName] - else: - return None + def getCollisionPoints(self): + return self.collisionPoints - def getCollisionPoints(self, predictionMethodName): - if self.collisionPoints is not None: - return self.collisionPoints[predictionMethodName] - else: - return None - + def getCrossingZones(self): + return self.crossingZones def createInteractions(objects, _others = None): '''Create all interactions of two co-existing road users''' @@ -288,22 +280,19 @@ else: return None -def aggregateSafetyPoints(interactions, predictionMethodName = None, pointType = 'collision'): +def aggregateSafetyPoints(interactions, pointType = 'collision'): '''Put all collision points or crossing zones in a list for display''' - if predictionMethodName is None and len(interactions)>0: - predictionMethodName = interactions[0].collisionPoints.keys()[0] - allPoints = [] if pointType == 'collision': for i in interactions: - for points in i.collisionPoints[predictionMethodName].values(): + for points in i.collisionPoints.values(): allPoints += points elif pointType == 'crossing': for i in interactions: - for points in i.crossingZones[predictionMethodName].values(): + for points in i.crossingZones.values(): allPoints += points else: - print('unknown type of point '+pointType) + print('unknown type of point: '+pointType) return allPoints def prototypeCluster(interactions, similarityMatrix, alignmentMatrix, indicatorName, minSimilarity):