Mercurial Hosting > traffic-intelligence
changeset 395:6fba1ab040f1
minor modification to framestotime
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Fri, 26 Jul 2013 17:52:23 -0400 |
parents | 6567fee37c16 |
children | 167f6ec44ec5 |
files | python/utils.py |
diffstat | 1 files changed, 5 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/python/utils.py Fri Jul 26 17:24:33 2013 -0400 +++ b/python/utils.py Fri Jul 26 17:52:23 2013 -0400 @@ -3,6 +3,7 @@ #from numpy import * #from pylab import * +from datetime import time __metaclass__ = type @@ -144,11 +145,12 @@ def argMaxDict(d): return max(d.iterkeys(), key=(lambda key: d[key])) -def framesToTime(nFrames, frameRate, initialTime = (0.,0.,0.)): - 'returns hour, minutes and seconds' +def framesToTime(nFrames, frameRate, initialTime = time()): + '''returns a datetime.time for the time in hour, minutes and seconds + initialTime is a datetime.time''' from math import floor from datetime import time - seconds = int(floor(float(nFrames)/float(frameRate))+initialTime[0]*3600+initialTime[1]*60+initialTime[2]) + seconds = int(floor(float(nFrames)/float(frameRate))+initialTime.hour*3600+initialTime.minute*60+initialTime.second) h = int(floor(seconds/3600.)) seconds = seconds - h*3600 m = int(floor(seconds/60))