Convert times to floats to correctly calculate fps

master
Dan Howe 5 years ago
parent b604a9d5fa
commit e9b45ab886

@ -145,23 +145,25 @@ def get_next_image(driver, cookies):
battery_str = driver.find_element_by_id('battery').text
f.write('{}\t{}\n'.format(t_local.isoformat(), battery_str[:-1]))
# Update counter
t.append(time.mktime(t_local.timetuple()))
# Update time counter
current_time = float(time.mktime(t_local.timetuple()))
if current_time not in t:
t.append(current_time)
# Count images collected
n = len(t)
if n > 1:
if n > 2:
# Get frames per second
fps = 1 / np.median(np.diff(t))
# Count dropped frames
n_dropped = np.max([0, int(fps * (t[-1] - t[0]) - n + 1)])
n_expected = fps * (t[-1] - t[0])
n_dropped = np.max([0, int(n_expected - n + 1)])
print('{} total images: {} fps: {} dropped frames: {}'.format(
t_local.isoformat(), n, fps, n_dropped),
end='\r',
flush=True)
msg = '{} total images: {} fps: {} dropped frames: {}'.format(
t_local.isoformat(), n, fps, n_dropped)
print(msg, end='\r', flush=True)
def main():

Loading…
Cancel
Save