def processVideo(vid,IDT_DIR,FV_DIR,gmm_list): """ Extracts the IDTFs, constructs a Fisher Vector, and saves the Fisher Vector at FV_DIR output_file: the full path to the newly constructed fisher vector. gmm_list: a list of gmms """ input_file = os.path.join(IDT_DIR, vid.split('.')[0]+'.bin') output_file = os.path.join(FV_DIR, vid.split('.')[0]+'.fv') if not os.path.exists(input_file): print '%s IDT Feature does not exist!' % vid return False if os.path.exists(output_file+'.mat'): print '%s Fisher Vector exists, skip!' % vid return False video_desc = IDT_feature.vid_descriptors(IDT_feature.read_IDTF_file(input_file)) computeFV.create_fisher_vector(gmm_list, video_desc, output_file) return True
def processVideo(vid, IDT_DIR, FV_DIR, gmm_list): """ Extracts the IDTFs, constructs a Fisher Vector, and saves the Fisher Vector at FV_DIR output_file: the full path to the newly constructed fisher vector. gmm_list: a list of gmms """ input_file = os.path.join(IDT_DIR, vid.split('.')[0] + '.bin') output_file = os.path.join(FV_DIR, vid.split('.')[0] + '.fv') if not os.path.exists(input_file): print '%s IDT Feature does not exist!' % vid return False if os.path.exists(output_file + '.mat'): print '%s Fisher Vector exists, skip!' % vid return False video_desc = IDT_feature.vid_descriptors( IDT_feature.read_IDTF_file(input_file)) computeFV.create_fisher_vector(gmm_list, video_desc, output_file) return True
import numpy as np from yael import ynumpy import IDT_feature from tempfile import TemporaryFile import argparse import computeFV """ computes a Fisher vector given an input stream of IDTFs Usage: stream_of_IDTFs | python computeFVstream.py fisher_path gmm_list ./DenseTrackStab video_file | python computeFVstream.py fisher_path gmm_list """ #The input is a stream of IDTFs associated with a single video. if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument("fisher_path", help="File to save the output Fisher Vector", type=str) parser.add_argument("gmm_list", help="File of saved list of GMMs", type=str) args = parser.parse_args() gmm_list = np.load(args.gmm_list+".npz")['gmm_list'] points = [] # a list of IDT features. for line in sys.stdin: points.append(IDT_feature.IDTFeature(line)) video_desc = IDT_feature.vid_descriptors(points) computeFV.create_fisher_vector(gmm_list, video_desc, args.fisher_path)