def collect_ssim(video_acked_results, postgres_cursor): # process InfluxDB data x = {} for pt in video_acked_results['video_acked']: expt_id = int(pt['expt_id']) expt_config = retrieve_expt_config(expt_id, expt_id_cache, postgres_cursor) # index x by (abr, cc) abr_cc = (expt_config['abr'], expt_config['cc']) if abr_cc not in x: x[abr_cc] = [] if pt['ssim_index'] is not None: ssim_index = float(pt['ssim_index']) x[abr_cc].append(ssim_index) # calculate average SSIM in dB and record number of chunks ssim = {} num_chunks = {} for abr_cc in x: num_chunks[abr_cc] = len(x[abr_cc]) avg_ssim_index = np.mean(x[abr_cc]) avg_ssim_db = ssim_index_to_db(avg_ssim_index) ssim[abr_cc] = avg_ssim_db return ssim, num_chunks
def collect_ssim(): d = {} # key: abr_cc; value: [sum, count] for s_str, e_str in datetime_iter(args.start_time, args.end_time): do_collect_ssim(s_str, e_str, d) # calculate average SSIM in dB for abr_cc in d: if d[abr_cc][1] == 0: sys.stderr.write('Warning: {} does not have SSIM data\n' .format(abr_cc)) continue avg_ssim_index = d[abr_cc][0] / d[abr_cc][1] avg_ssim_db = ssim_index_to_db(avg_ssim_index) d[abr_cc] = avg_ssim_db return d
def do_collect_ssim(video_acked_results, expt_id_cache, postgres_cursor): # process InfluxDB data x = {} for pt in video_acked_results['video_acked']: expt_id = get_expt_id(pt) expt_config = retrieve_expt_config(expt_id, expt_id_cache, postgres_cursor) abr_cc = get_abr_cc(expt_config) if abr_cc not in x: x[abr_cc] = [] ssim_index = get_ssim_index(pt) if ssim_index is not None: x[abr_cc].append(ssim_index) # calculate average SSIM in dB for abr_cc in x: avg_ssim_index = np.mean(x[abr_cc]) avg_ssim_db = ssim_index_to_db(avg_ssim_index) x[abr_cc] = avg_ssim_db return x
def collect_ssim(video_acked_results, postgres_cursor): # process InfluxDB data x = {} for pt in video_acked_results['video_acked']: expt_id = int(pt['expt_id']) expt_config = retrieve_expt_config(expt_id, expt_id_cache, postgres_cursor) # index x by (abr, cc) abr_cc = (expt_config['abr'], expt_config['cc']) if abr_cc not in x: x[abr_cc] = [] ssim_index = get_ssim_index(pt) if ssim_index is not None: x[abr_cc].append(ssim_index) # calculate average SSIM in dB ssim = {} for abr_cc in x: avg_ssim_index = np.mean(x[abr_cc]) avg_ssim_db = ssim_index_to_db(avg_ssim_index) ssim[abr_cc] = avg_ssim_db return ssim