def readblendfromcsv_fps(csvname, fps=60): file = open(csvname) csvreader = csv.reader(file) blend_name_src = next(csvreader)[2:] blend_shape_value_src = [] times_vec = [] for row in csvreader: if len(row[2:]) > 0: time_now = time_convert(row[0]) times_vec.append(time_now) value = list(map(float, row[2:])) blend_shape_value_src.append(value) times_vec = np.array(times_vec) * fps times_vec = times_vec - times_vec[0] blend_shape_value_src = np.array(blend_shape_value_src) remap_len = int(times_vec[-1]) remapped_blend = np.zeros((remap_len, len(blend_shape_value_src[0]))) for i in range(remap_len): vect = times_vec < i # print(i, '######################################### ', np.sum(vect)) if np.sum(vect) == 0: id0 = 0 id1 = 1 else: id0 = np.sum(vect) - 1 id1 = np.sum(vect) time0 = times_vec[id0] time1 = times_vec[id1] # print("time0=", time0, " ", "time1=", time1) # print("i=", i) remapped_blend[i] = blend_shape_value_src[id0] * (time1 - i) + blend_shape_value_src[id1] * (i - time0) remapped_blend[i] = remapped_blend[i] / (time1 - time0) file.close() return blend_name_src, remapped_blend, times_vec