# use the openface 2 to get the action units before this # go to- valapil@hemera4:~/Programs/OpenFace$ # type- ./bin/FeatureExtraction -f "/home/valapil/Project/ForkCausal_Adithya/clipped_vid/pair_021/021S3o/021S3o.MTS_clipped.mp4" # also get the offset values import numpy as np import os AU = ["Person", "Case", "AU01", "AU02", "AU04", "AU05", "AU06", "AU07", "AU09","AU10","AU12","AU14","AU15","AU17","AU20","AU23", "AU25","AU26", "AU45"] off = ["Case", "Start", "End", "Person"] # folder where output csv files of OpenFace are stored folder = '/home/valapil/Project/ForkCausal_Adithya/csv_files' csv_files = [file for file in os.listdir(folder) if file.endswith('.csv')] def loadOffset(): """ get offset values for video frames :param basepath: path to where offset.csv is at :return: dictionary with {identifier: offset}('002S1g': 7} """ # opening the file where offset values are present with open(os.path.join('/home/valapil/Project/ForkCausal_Adithya/offset.csv'), 'r') as f: f.readline() # read header offset = {} for row in f: id, StartEnd, second, frame = row.split(' ')[0:4] if id not in offset: offset[id] = {} offset[id][StartEnd] = int(np.ceil(float(frame))) return offset for file in csv_files: base_name, extension = os.path.splitext(file) new_name = base_name.split('.')[0] f1 = new_name[:-2] f2 = new_name[-1:] file_path = os.path.join(folder, file) offset = loadOffset() if new_name[-5] != '0': offset_file = np.hstack((new_name[:-3] + new_name[-1], offset[new_name]['start'], offset[new_name]['end'], new_name)) else: offset_file = np.hstack((new_name[:-3] + new_name[-1], offset['0' + new_name]['start'], offset['0' + new_name]['end'], new_name)) off = np.row_stack((off, offset_file)) # file where offset values are stored as npy format np.save(f'/home/valapil/Project/ForkCausal_Adithya/offset_values.npy', off)