Mercurial > hg > nsaunier > traffic-intelligence
comparison python/utils.py @ 262:a048066bd20f
correcting bug in framesToTime
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Wed, 25 Jul 2012 18:22:18 -0400 |
| parents | 4aa792cb0fa9 |
| children | aba9711b3149 |
comparison
equal
deleted
inserted
replaced
| 261:4aa792cb0fa9 | 262:a048066bd20f |
|---|---|
| 166 | 166 |
| 167 def framesToTime(nFrames, frameRate, initialTime = (0.,0.,0.)): | 167 def framesToTime(nFrames, frameRate, initialTime = (0.,0.,0.)): |
| 168 'returns hour, minutes and seconds' | 168 'returns hour, minutes and seconds' |
| 169 from math import floor | 169 from math import floor |
| 170 from datetime import time | 170 from datetime import time |
| 171 seconds = int(floor(float(nFrames)/float(frameRate))) | 171 seconds = int(floor(float(nFrames)/float(frameRate))+initialTime[0]*3600+initialTime[1]*60+initialTime[2]) |
| 172 h = int(floor(seconds/3600.)) | 172 h = int(floor(seconds/3600.)) |
| 173 seconds = seconds - h*3600 | 173 seconds = seconds - h*3600 |
| 174 m = int(floor(seconds/60)) | 174 m = int(floor(seconds/60)) |
| 175 seconds = seconds - m*60 | 175 seconds = seconds - m*60 |
| 176 return time(h+int(initialTime[0]), m+int(initialTime[1]), seconds+int(initialTime[2])) | 176 return time(h, m, seconds) |
| 177 | 177 |
| 178 def sortXY(X,Y): | 178 def sortXY(X,Y): |
| 179 'returns the sorted (x, Y(x)) sorted on X' | 179 'returns the sorted (x, Y(x)) sorted on X' |
| 180 D = {} | 180 D = {} |
| 181 for x, y in zip(X,Y): | 181 for x, y in zip(X,Y): |
