Mercurial Hosting > traffic-intelligence
comparison python/moving.py @ 949:d6c1c05d11f5
modified multithreading at the interaction level for safety computations
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Fri, 21 Jul 2017 17:52:56 -0400 |
parents | 05d4302bf67e |
children | 196a1fd498ba |
comparison
equal
deleted
inserted
replaced
948:584b9405e494 | 949:d6c1c05d11f5 |
---|---|
3 | 3 |
4 import utils, cvutils | 4 import utils, cvutils |
5 from base import VideoFilenameAddable | 5 from base import VideoFilenameAddable |
6 | 6 |
7 from math import sqrt, atan2, cos, sin | 7 from math import sqrt, atan2, cos, sin |
8 from numpy import median, array, zeros, hypot, NaN, std, floor, float32, argwhere | 8 from numpy import median, array, arange, zeros, ones, hypot, NaN, std, floor, float32, argwhere, minimum |
9 from matplotlib.pyplot import plot, text | 9 from matplotlib.pyplot import plot, text |
10 from scipy.stats import scoreatpercentile | 10 from scipy.stats import scoreatpercentile |
11 from scipy.spatial.distance import cdist | 11 from scipy.spatial.distance import cdist |
12 from scipy.signal import savgol_filter | 12 from scipy.signal import savgol_filter |
13 | 13 |
1456 at which the object passes from one side of the segment to the other | 1456 at which the object passes from one side of the segment to the other |
1457 empty list if there is no crossing''' | 1457 empty list if there is no crossing''' |
1458 indices, intersections = self.positions.getIntersections(p1, p2) | 1458 indices, intersections = self.positions.getIntersections(p1, p2) |
1459 return [t+self.getFirstInstant() for t in indices] | 1459 return [t+self.getFirstInstant() for t in indices] |
1460 | 1460 |
1461 def computeTrajectorySimilarities(self, prototypes, lcss): | |
1462 'Computes the similarities to the prototypes using the LCSS' | |
1463 if not hasattr(self, 'prototypeSimilarities'): | |
1464 self.prototypeSimilarities = [] | |
1465 for proto in prototypes: | |
1466 lcss.similarities(proto.getMovingObject().getPositions().asArray().T, self.getPositions().asArray().T) | |
1467 similarities = lcss.similarityTable[-1, :-1].astype(float) | |
1468 self.prototypeSimilarities.append(similarities/minimum(arange(1.,len(similarities)+1), proto.getMovingObject().length()*ones(len(similarities)))) | |
1469 | |
1461 @staticmethod | 1470 @staticmethod |
1462 def computePET(obj1, obj2, collisionDistanceThreshold): | 1471 def computePET(obj1, obj2, collisionDistanceThreshold): |
1463 '''Post-encroachment time based on distance threshold | 1472 '''Post-encroachment time based on distance threshold |
1464 | 1473 |
1465 Returns the smallest time difference when the object positions are within collisionDistanceThreshold | 1474 Returns the smallest time difference when the object positions are within collisionDistanceThreshold |