#!/usr/bin/env python import argparse import os import sys sys.path.insert(1, os.path.join(os.path.dirname(__file__), '../..')) from vdetlib.utils.common import stem from vdetlib.utils.protocol import vid_proto_from_dir, proto_dump if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument('vid_name') parser.add_argument('root_dir') parser.add_argument('out_file') args = parser.parse_args() if os.path.isfile(args.out_file): print "{} already exists.".format(args.out_file) sys.exit(0) vid = vid_proto_from_dir(args.root_dir, args.vid_name) save_dir = os.path.dirname(args.out_file) if not os.path.isdir(save_dir): os.makedirs(save_dir) proto_dump(vid, args.out_file)
videos[os.path.dirname(line[0])].append(int(line[1])) # sort frames inside each video for k in videos: videos[k].sort() vid_list = open(sys.argv[1]) vid_objs = {} for video_name in vid_list: vid_name = video_name.strip() print video_name print(vid_name) ## load vid tracks video_foler = VID_ROOT + vid_name vid = vid_proto_from_dir(video_foler, vid_name) print(len(vid['frames'])) anno_folder = ANNO_ROOT + vid_name annot = get_anno(anno_folder) # print (annot.keys()) # print (annot['video']) # print (len(annot['annotations'])) # find fids that are needed fids = videos[vid_name] # print (fids) ## match the gt with detection for each video objs = {} for frame_index, frame in enumerate(vid['frames']):