Mercurial Hosting > traffic-intelligence
comparison python/utils.py @ 561:ee45c6eb6d49
added Mohamed Gomaa Mohamed function to smooth object trajectories
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Tue, 15 Jul 2014 16:42:04 -0400 |
parents | 3622a5653ee9 |
children | 0057c04f94d5 |
comparison
equal
deleted
inserted
replaced
560:5b534ad95bfb | 561:ee45c6eb6d49 |
---|---|
207 '''Returns the media of Y's corresponding to X's in the interval [x-halfwidth, x+halfwidth]''' | 207 '''Returns the media of Y's corresponding to X's in the interval [x-halfwidth, x+halfwidth]''' |
208 from numpy import median | 208 from numpy import median |
209 return median([y for observedx, y in zip(X,Y) if abs(x-observedx)<halfwidth]) | 209 return median([y for observedx, y in zip(X,Y) if abs(x-observedx)<halfwidth]) |
210 | 210 |
211 def argmaxDict(d): | 211 def argmaxDict(d): |
212 return max(d.iterkeys(), key=(lambda key: d[key])) | 212 return max(d, key=d.get) |
213 | 213 |
214 def framesToTime(nFrames, frameRate, initialTime = time()): | 214 def framesToTime(nFrames, frameRate, initialTime = time()): |
215 '''returns a datetime.time for the time in hour, minutes and seconds | 215 '''returns a datetime.time for the time in hour, minutes and seconds |
216 initialTime is a datetime.time''' | 216 initialTime is a datetime.time''' |
217 from math import floor | 217 from math import floor |