diff python/utils.py @ 837:e01cabca4c55

minor modifications to merge-features
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Wed, 06 Jul 2016 10:58:18 -0400
parents 10dbab1e871d
children 15a82ebc62c4
line wrap: on
line diff
--- a/python/utils.py	Wed Jul 06 10:18:35 2016 -0400
+++ b/python/utils.py	Wed Jul 06 10:58:18 2016 -0400
@@ -238,6 +238,14 @@
 def argmaxDict(d):
     return max(d, key=d.get)
 
+def deltaFrames(t1, t2, frameRate):
+    '''Returns the number of frames between t1 and t2
+    positive if t1<=t2, negative otherwise'''
+    if t1 > t2:
+        return -(t1-t2).seconds*frameRate
+    else:
+        return (t2-t1).seconds*frameRate
+
 def framesToTime(nFrames, frameRate, initialTime = time()):
     '''returns a datetime.time for the time in hour, minutes and seconds
     initialTime is a datetime.time'''