# HG changeset patch # User Nicolas Saunier # Date 1374875543 14400 # Node ID 6fba1ab040f16e916547ce68126c10c9fd731d7f # Parent 6567fee37c169c1f79a5ff225a8fe8bf84fceb0e minor modification to framestotime diff -r 6567fee37c16 -r 6fba1ab040f1 python/utils.py --- 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))