Commit 20b9d64e authored by Niels-Oliver Walkowski's avatar Niels-Oliver Walkowski
Browse files

improve frame2time helper function

turn return value into np.timedelta64
calculate timevalue by pd.Timedelta instead of divmod
parent 84a6a374
......@@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-
import numpy as np
import pandas as pd
import math
......@@ -56,10 +57,20 @@ def time2framenr(time, fps=4):
return in_sec * fps
def timelabels(val, pos):
min, sec = divmod(int(val), 60)
timelabel = "{0}:{1:02d}".format(min, sec)
return timelabel
def frame2time(val, fps=4):
"""transforms framenumbers into timecodes
val {int} -- number of frame in the movie
fps {int} -- time interval by which frames were extracted from the movie
np.datetime64 -- timecode of the frame in the movie
val = round(val/fps) # scale frame number to the unit of 1 sec
tstmp = pd.Timedelta(val, unit='s')
return tstmp
def luminance(img):
"""Creates an array of luminance value for each pixel of an image
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment