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 battery_str = driver.find_element_by_id('battery').text
f.write('{}\t{}\n'.format(t_local.isoformat(), battery_str[:-1])) f.write('{}\t{}\n'.format(t_local.isoformat(), battery_str[:-1]))
# Update counter # Update time counter
t.append(time.mktime(t_local.timetuple())) current_time = float(time.mktime(t_local.timetuple()))
if current_time not in t:
t.append(current_time)
# Count images collected # Count images collected
n = len(t) n = len(t)
if n > 1: if n > 2:
# Get frames per second # Get frames per second
fps = 1 / np.median(np.diff(t)) fps = 1 / np.median(np.diff(t))
# Count dropped frames # 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( msg = '{} total images: {} fps: {} dropped frames: {}'.format(
t_local.isoformat(), n, fps, n_dropped), t_local.isoformat(), n, fps, n_dropped)
end='\r', print(msg, end='\r', flush=True)
flush=True)
def main(): def main():

Loading…
Cancel
Save